next up previous contents
Next: mb_imgcrop.m Up: HeLa Data Previous: mb_imgshift.m

mb_imgproc.m

 function imageproc = mb_imgproc(image, cropimage)
% MB_IMGPROC - background subtract, threshold, clean, crop
% MB_IMGPROC(IMAGE, CROPIMAGE), where iamge is the IMAGE 
%    to be processed and CROPIMAGE is a binary mask defining
%    a region of interest.  Use CROPIMAGE=[] to process the 
%    entirity of IMAGE.  
%
%    Steps in processing:
%      1. subtract background using mb_imgbgsub.m
%      2. identify and apply a threshold
%      3. clean up the thresholded image using majority()
%      4. crop the image using CROPIMAGE
%
% 03 Mar 1999

% $Id: mb_imgproc.m,v 1.2 1999/03/03 20:10:52 boland Exp $

%
% Subtract the background from IMAGE
%
image = mb_imgbgsub(image, 'common') ;

%
% Use the thresholding technique from NIH image (REF?)
%
Iscaled = mb_nihscale(image) ;
Timage = mb_nihthreshold(Iscaled) ;
Ithresh = im2bw(Iscaled, Timage) ;

%
% The majority filter works well empirically to remove extraneous objects
%
mask = bwmorph(Ithresh, 'majority') ;

%
% Set all pixels in IMAGE that are outside of MASK to 0
%
imageproc = roifilt2(0, image, ~mask) ;

%
% If the crop image exists, make all pixels outside the crop area
%   equal to 0.
%
if (~isempty(cropimage))
        imageproc = roifilt2(0, image, ~cropimage) ;
end

 



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