from
Handling Large Images with Image Processing Toolbox Webinar
by Alan Hwang
Code demos for the Handling Large Images with Image Processing Toolbox Webinar.
|
| Demo1.m |
%% Segmentation of a cell
% Display image
I = imread('AT3_1m4_10_small.tif');
imshow(I)
%% Interactive visualization
imtool(I)
%% Edge detection
BW = edge(I,'sobel');
imshow(BW);
%% Dilation
se = strel('square',5);
BWdil = imdilate(BW,se);
imshow(BWdil)
%% Fill in holes
BWfil = imfill(BWdil,'holes');
imshow(BWfil)
%% Visual inspection
imtool(BWfil)
%% Remove small objects
BWopen = bwareaopen(BWfil,140);
imshow(BWopen)
%% Region properties
% Label blobs
cc = bwconncomp(BWfil);
L = labelmatrix(cc);
imshow( ind2rgb(L, jet(47)) )
%% Calculate statistics
stats = regionprops(L,'Area');
idx = find([stats.Area] > 130);
% Filter out by area
BWopen = ismember(L, idx);
imshow(BWopen)
%% Erode edges
BWfinal = imerode(BWopen,se);
imshow(BWfinal)
%% Calculate perimeter
BWoutline = bwperim(BWfinal);
imshow(BWoutline)
%% Overlay on original
y = I;
y(BWoutline) = 255;
imshow(y)
% Copyright 2005-2009 The MathWorks, Inc.
|
|
Contact us at files@mathworks.com