www.pudn.com > image_mva_0.rar > profiles.m


function varargout = profiles(varargin) 
% GUI for plotting profiles for image arrays 
%   Plots Z-profile (through stack of images for a chosen pixel) 
%   Plots line profile for line drawn in an image, and plots 
%   profiles for the same coordinates for different images in array 
%    
% INPUT: 
%   images - array to threshold images (can be a single image as well) 
%   'N' - image to display  
% 
% to run: 
% 
%   profile(images,'1')    
% 
%  created by K.Artyushkova 
%  January 2004 
 
% Kateryna Artyushkova 
% Postdoctoral Scientist 
% Department of Chemical and Nuclear Engineering 
% The University of New Mexico 
% (505) 277-0750 
% kartyush@unm.edu 
 
% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',       mfilename, ... 
                   'gui_Singleton',  gui_Singleton, ... 
                   'gui_OpeningFcn', @profiles_OpeningFcn, ... 
                   'gui_OutputFcn',  @profiles_OutputFcn, ... 
                   'gui_LayoutFcn',  [] , ... 
                   'gui_Callback',   []); 
if nargin & isstr(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 profiles is made visible. 
function profiles_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 profiles (see VARARGIN) 
 
% Choose default command line output for profiles 
handles.output = hObject; 
 
% Update handles structure 
axes(handles.axes1); 
cla 
data= varargin{1}; 
n=varargin{2}; 
n=str2double(n); 
colormap(gray) 
[m,p,q]=size(data); 
set(handles.im1,'string',1); 
set(handles.imN,'string',q); 
set(handles.imi,'string',n); 
axes(handles.axes1) 
iptsetpref('ImshowAxesVisible', 'on') 
imshow(data(:,:,n),[min(min(data(:,:,n))) max(max(data(:,:,n)))]) 
handles.data=data; 
handles.n=n; 
h = msgbox('To plot Z profile push Z PROFILE button and then click by mouse on the image for which pixel to plot the profile'); 
uiwait(h) 
h = msgbox('To plot line profile push LINE PROFILE button and draw the line with mouse. By sliding the slider you can see the profile for the same line for different images in array'); 
uiwait(h) 
guidata(hObject, handles); 
 
% UIWAIT makes profiles wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 
 
 
% --- Outputs from this function are returned to the command line. 
function varargout = profiles_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 button press in zprofile.
function zprofile_Callback(hObject, eventdata, handles)
% hObject    handle to zprofile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
data=handles.data; 
 
[X,Y] = ginput; 
X=round(X); 
Y=round(Y); 

[n,p,q]=size(data); 
for i=1:q 
    z_profile(i)=data(Y,X,i); 
end 
axes(handles.axes2); 
plot(z_profile) 


% --- Executes on button press in line_profile.
function line_profile_Callback(hObject, eventdata, handles)
% hObject    handle to line_profile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.axes1)
[CX,CY,C,xi,yi]=improfile; 
data=handles.data; 
n=handles.n; 
I=data(:,:,n); 
axes(handles.axes2) 
improfile(I,xi,yi) 
handles.xi=xi; 
handles.yi=yi; 
guidata(hObject,handles) 
 

% --- Executes during object creation, after setting all properties.
function slice_select_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slice_select (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, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement. 
function slice_select_Callback(hObject, eventdata, handles) 
% hObject    handle to slice_select (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
 
% Hints: get(hObject,'Value') returns position of slider 
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider 
data=handles.data; 
[m,p,q]=size(data); 
step=1/q; 
set(handles.im1,'string',1); 
set(handles.imN,'string',q); 
slider_step(1)=step; 
slider_step(2)=step; 
set(handles.slice_select, 'SliderStep', slider_step, 'Max', q, 'Min',0) 
i=get(hObject,'Value'); 
i=round(i); 
    if i==0 
        i=1; 
    elseif i>=q 
        i=q; 
    else i=i; 
    end 
    set(handles.imi,'string',i); 
    axes(handles.axes1); 
   iptsetpref('ImshowAxesVisible', 'on') 
imshow(data(:,:,i),[min(min(data(:,:,i))) max(max(data(:,:,i)))]) 
 
handles.N1=i; 
 
xi=handles.xi; 
yi=handles.yi; 
axes(handles.axes2) 
improfile(data(:,:,i),xi,yi) 
guidata(hObject,handles)