Code covered by the BSD License  

Highlights from
Mia 2.4

image thumbnail

Mia 2.4

by

 

02 Apr 2004 (Updated )

Medical Image Analysis GUI.

mia_improfile(action)
function mia_improfile(action)
% mia_improfile
%
% Compute pixel-value cross-sections along line segments.
% Click left mouse button to start, and right button 
% to finish up a line segment
%
% Matlab library function for mia_gui utility. 
% University of Debrecen, PET Center/LB 2003

global gVOIpixval

CurrentAxes = gVOIpixval.CurrentAxes;
CurrentImage = get(CurrentAxes,'children');
CurrentFigure = get(CurrentAxes,'parent');

switch action
    
case 'start' 
    set(CurrentImage,'ButtonDownFcn','mia_improfile initialize');
    SetData = setptr('circle'); set(CurrentFigure,SetData{:});
    AxData.x0 = 0;
	AxData.y0 = 0;
	AxData.line = [];
	set(CurrentAxes,'UserData',AxData);
    %get(CurrentFigure,'pointer')
    %get(CurrentFigure)
    
case 'initialize'
    AxData = get(CurrentAxes,'UserData');
    if ishandle(AxData.line)
        delete(AxData.line);
    end
    % Set the initial point (x0,y0)
	pt = get(CurrentAxes, 'CurrentPoint');
	AxData.x0 = pt(1,1);
	AxData.y0 = pt(1,2);
	AxData.line = line('Parent', CurrentAxes, ...
       'erasemode', 'xor', ...
       'color', [1 0 0], ...
       'Xdata', [AxData.x0 AxData.x0], ...
       'Ydata', [AxData.y0 AxData.y0],'LineWidth',2);
	set(CurrentAxes,'UserData',AxData);
    set(CurrentFigure,'WindowButtonMotionFcn','mia_improfile move');
    set(CurrentFigure,'WindowButtonUpFcn','mia_improfile moveoff');
    mia_improfile('move');
    
case 'move'
    AxData = get(CurrentAxes,'UserData');
    pt = get(CurrentAxes, 'CurrentPoint');
	x = pt(1,1); y = pt(1,2);
    set(AxData.line, 'XData', [AxData.x0 x], 'YData', [AxData.y0 y]);
    
    % select the Image Profile figure window
    if isempty(findobj('name','Image Profile'))
        ScreenSize = get(0,'ScreenSize');
        Pos = [0.6*ScreenSize(3)    0.1*ScreenSize(4)    0.4*ScreenSize(3)    0.35*ScreenSize(4)];
        fh = figure('name','Image Profile','NumberTitle','off','Position',Pos,'doubleBuffer','on');
        %default plot
        plot([0:200]);xlabel('Distance along profile');
        %handles.hf_improfile = fh;
        % Update handles structure
        %guidata(hObject, handles);
    else
        fh = findobj('name','Image Profile');
	end
    %figure(fh);
    lh = get(get(fh,'children'),'children');%get the line handler
    %plot the profile
    if diff([AxData.x0 x]) ~= 0
        [cx,cy,c] = improfile(double(gVOIpixval.CurrentImage),[AxData.x0 x],[AxData.y0 y]);
        xalongprof = linspace(0,sqrt((cx(1)-cx(end))^2 + (cy(1)-cy(end))^2),length(c))';
        set(lh,'YData',c,'Xdata',xalongprof);
        drawnow;
    end
    figure(CurrentFigure);
    %mia_improfile('move');

case 'moveoff'
    set(CurrentFigure,'WindowButtonMotionFcn','');
    set(CurrentFigure,'WindowButtonUpFcn','');
    
case 'stop'
    AxData = get(CurrentAxes,'UserData');
    %if ishandle(AxData.line)
    if ~isempty(AxData)
        delete(AxData.line);
    end
    SetData=setptr('arrow');set(CurrentFigure,SetData{:}); 
    set(CurrentFigure,'WindowButtonMotionFcn','');
    set(CurrentFigure,'WindowButtonUpFcn','');
    set(get(CurrentAxes,'children'),'ButtonDownFcn','');
end

Contact us