help image processing code
显示 更早的评论
Hi all
I want to display multiple images using GUI. I have 135 image. i want load 135 images in axes, then when i slide, it will show the image from 1 to 135. This is my code that i know to read 135 image:
P = zeros(256, 256, 135);
for K = 1 : 135
petname = sprintf('PET_I1001_PT%03d.dcm', K);
P(:,:,K) = dicomread(petname);
end
how to me write the command for 'load image button' and 'slider' in m file ??
hope anyone can help me

采纳的回答
Set up your scroll bar to have 135 as the max and 1 as the min. Then in the scrollbar callback function:
scrollBarValue = round(handles.scrollbar1.Value);
petName = sprintf('PET_I1001_PT%03d.dcm', scrollBarValue);
fullFileName = fullfile(folder, petName);
thisImage = dicomread(fullFileName);
imshow(thisImage);
No loop is needed.
4 个评论
then what is the command for load image??
This line is the line that loads the image from disk into a variable:
thisImage = dicomread(fullFileName);
This is the line that loads the image from a variable onto a rectangle on your screen:
imshow(thisImage);
this is my code, but still not work
function varargout = gui123(varargin)
% GUI123 MATLAB code for gui123.fig
% GUI123, by itself, creates a new GUI123 or raises the existing
% singleton*.
%
% H = GUI123 returns the handle to a new GUI123 or the handle to
% the existing singleton*.
%
% GUI123('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI123.M with the given input arguments.
%
% GUI123('Property','Value',...) creates a new GUI123 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui123_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui123_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help gui123
% Last Modified by GUIDE v2.5 28-Feb-2018 00:33:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui123_OpeningFcn, ...
'gui_OutputFcn', @gui123_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before gui123 is made visible.
function gui123_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to gui123 (see VARARGIN)
% Choose default command line output for gui123
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui123 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui123_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
scrollBarValue = round(handles.scrollbar1.Value);
petName = sprintf('PET_I1001_PT%03d.dcm', scrollBarValue);
fullFileName = fullfile('D:\Images PET and CT\CT', petName);
thisImage = dicomread(fullFileName);
imshow(thisImage);
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
if true
% code
end
is it true like this? but the GUI appear as picture attach
function varargout = gui123(varargin)
% GUI123 MATLAB code for gui123.fig
% GUI123, by itself, creates a new GUI123 or raises the existing
% singleton*.
%
% H = GUI123 returns the handle to a new GUI123 or the handle to
% the existing singleton*.
%
% GUI123('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI123.M with the given input arguments.
%
% GUI123('Property','Value',...) creates a new GUI123 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui123_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui123_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help gui123
% Last Modified by GUIDE v2.5 28-Feb-2018 00:52:21
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui123_OpeningFcn, ...
'gui_OutputFcn', @gui123_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before gui123 is made visible.
function gui123_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to gui123 (see VARARGIN)
% Choose default command line output for gui123
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui123 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui123_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
scrollBarValue = round(handles.scrollbar1.Value);
petName = sprintf('PET_I1001_PT%03d.dcm', scrollBarValue);
fullFileName = fullfile('D:\Images PET and CT\CT', petName);
thisImage = dicomread(fullFileName);
imshow(thisImage);
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
