image thumbnail

Image Section Generator

by

 

21 May 2009 (Updated )

Image Section Generator grabs cursor-designated linescans from microscope images

EnforceBounds(InputVector,InputHandles)
%--------------------------------------------------------------------%
%	    Alison Chaiken, sole author and maintainer     			     %
%        ------------------------------------------------------      %
%	    GUI-based Matlab and FEMLAB data analysis, instrument	     %
%	    control, statistical analysis, finite-element modelling,     %
%	    image acquisition and analysis          				     %
%       -------------------------------------------------------      %
%	    alchaiken@gmail.com			                    		     %
%	    http://www.exerciseforthereader.org/         			     %
%	    (001)650-279-5600					                         %
%--------------------------------------------------------------------%

function [xtemp ytemp] = EnforceBounds(InputVector,InputHandles) 
% make sure that coordinates chosen for the section doesn't place one of
% its termini outside the image boundaries

xtemp = InputVector(:,1);
ytemp = InputVector(:,2);

if (xtemp(1) < 1)
    xtemp(1) = 1;
elseif xtemp(1) > InputHandles.ImageWidth
        xtemp(1) = InputHandles.ImageWidth;
end
if (xtemp(2) < 1)
    xtemp(2) = 1;
elseif xtemp(2) > InputHandles.ImageWidth
        xtemp(2) = InputHandles.ImageWidth;
end

if (ytemp(1) < 1)
    ytemp(1) = 1;
elseif ytemp(1) > InputHandles.ImageHeight
    ytemp(1) = InputHandles.ImageHeight;
end
if (ytemp(2) < 1)
    ytemp(2) = 1;
elseif ytemp(2) > InputHandles.ImageHeight
    ytemp(2) = InputHandles.ImageHeight;
end
return

Contact us