Geoscience Reference
In-Depth Information
h e following example for object segmentation illustrates the segmentation,
measuring, and counting of objects using the watershed segmentation
algorithm (Fig. 8.9). We i rst read an image of coarse lithic grains of dif erent
sizes and store it in the variable
I1
. h e size of the image is 284-by-367 pixels
and, since the width is 3 cm, the height is 3 cm∙284/367=2.32 cm.
clear
I1 = imread('grainsize.tif');
ix = 3; iy = 284 * 3 / 367;
imshow(I1,'XData',[0 ix],'YData',[0 iy])
title('Original Image')
Here,
ix
and
iy
denote the coordinate axes used to calibrate the image
I1
to
a centimeter scale. h e true number of objects counted in this image is 236,
including three grains that overlap the borders of the image and will therefore
be ignored in the following exercise. We reject the color information of the
image and convert
I1
to grayscale using the function
rgb2gray
.
I2 = rgb2gray(I1);
imshow(I2,'XData',[0 ix],'YData',[0 iy])
title('Grayscale Image')
h is grayscale image
I2
has a relatively low level of contrast. We therefore
use the function
imadjust
to adjust the image intensity values. h e function
imadjust
maps the values in the intensity image
I2
to new values in
I3
, such
that 1% of the data is saturated at low and high intensities. h is increases the
contrast in the new image
I3
.
I3 = imadjust(I2);
imshow(I3,'XData',[0 ix],'YData',[0 iy])
title('Adjusted Intensity Values')
We next determine the background of the
I3
image, which means basically
the texture of the black foil on which the grains are located. h e function
imopen(im,se)
determines objects in an image
im
with a specii c shape
se
(a l at structuring element such as a circular disk) and size (expressed as a
specii c number of pixels), as dei ned by the function
strel
. We then produce
a background-free image,
I4
.
I4 = imopen(I3,strel('disk',1));
imshow(I4,'XData',[0 ix],'YData',[0 iy])
title('No Background')
We subtract the background-free image
I4
from the original grayscale image
I3
to observe the background
I5
that has been eliminated.