next up previous contents
Next: Feature Extraction - Zernike Up: HeLa Data Previous: mb_imgproc.m

mb_imgcrop.m

 function mb_imgcrop(dicfile, cropfile)
% MB_IMGCROP generate a binary cropfile
% MB_IMGCROP(DICFILE, CROPFILE), 
%     prompts the user to crop DICFILE using ROIPOLY and 
%     then saves a binary mask of the cropped region in 
%     CROPFILE.  If CROPFILE='', then the cropfile is 
%     written to DICFILE with the .dat extension changed
%     to .crop.
%
% 25 Aug 98 - M.V. Boland

% $Id: mb_imgcrop.m_tmp,v 1.1 1999/06/26 14:16:35 boland Exp $

if (nargin ~=2)
	error('mb_imgcrop requires two arguments.  
	Use '' for any undefined file names') ;
end

if ~(ischar(dicfile) & ischar(cropfile))
	error('All arguments must be strings.  
	Use '' for any undefined file names') ;
end

if (isempty(dicfile))
	error('You must specify a DIC file for cropping') ;
end


%
% If the DIC file is specified, use it for cropping
%
dicimage = mb_tclread(dicfile) ;
if (~isempty(dicimage))
	cropimage = roipoly(mb_imgscale(dicimage)) ;
else
	error('Unable to read your DICFILE') ;
end
%
% if the crop file is specified, use that name for output
%
if (~isempty(cropfile))
	imwrite(cropimage, cropfile, 'tiff') ;
else
	imwrite(cropimage, ...
	strrep(strrep(dicfile,'.dat','.tif'),'dic','crop'), 'tiff') ;
end
 



Copyright ©1999 Michael V. Boland
1999-09-18