1. The detection of isolated points embedded in the areas of constant or
nearly constant intensity in an image is straightforward in principle.
2. The point detection approach can be implemented by using command:
g = abs (imfilter (double (f), w)) >= T
3. The other approach is to find the points in all neighborhoods for which
the difference of the maximum and minimum pixel values exceeds a
specified value of T.
4. The function ordfilt2 can be used to implement this approach, having
g = imsubtract (ordfilt2 (f, m*n, ones (m, n), . . .
ordfilt2 (f, 1, ones (m, n)));
1. Line detection is the next level of
2. If mask in figure (a) were moved
around an image, it would
respond more strongly to lines
3. Similarly, second mask responds
to lines oriented at +45 degrees
(fig. (b)), third mask to vertical
lines (fig. (c)), and fourth mask to
lines at -45 degrees (fig. (d)).
– 45 degree
1. Edge detection is the most common approach for detecting meaningful
discontinuities in intensity values.
2. Several edge estimators are provided by function edge, having syntax:
[g, t] = edge (f, ‘method’, parameters)
3. Edge detectors available in function edge are:
d. Laplacian of Gaussian
e. Zero crossings
Line Detection using Hough Transform
1. Hough transform is the approach of linking line segments in an image.
2. Function hough has either the default syntax:
[H, theta, rho] = hough (f)
or, [H, theta, rho] = hough (f, ‘ThetaRes’, val1, ‘RhoRes’, val2)
3. Specified number of peaks are found by using function houghpeaks,
peaks = houghpeaks (H, NumPeaks)
or, peaks = houghpeaks (. . . , ‘Threshold’, val1, ‘NHoodSize’, val2)
4. To determine meaningful line segments associated with peaks an to get
the information of lines start and end, function houghlines is used, having
lines = houghlines (f, theta, rho, peaks)
or, lines = houghlines (. . . , ‘FillGap’, val1, ‘MinLength’, val2)
1. Image thresholding has a central position in applications of image
segmentation because of its intuitive properties and simplicity of
2. Basic global thresholding
a. Visual inspection of the image histogram is one of the way of
choosing a threshold
b. The preferred approach is to use an algorithm capable of choosing
the threshold automatically based on image data.
c. One such approach is as following:
i. Select an initial estimate for the global threshold, T.
ii. Segment the image using T.
iii. Compute the average intensity values for the pixels.
iv. Compute a new threshold value using averahe intensity values.
v. Repeat steps 2 through 4.
vi. Use function im2bw to segment the image as:
g = im2bw (f, T/den)
3. Optimum global thresholding using Otsu’s method
a. Function graythresh is used to compute the Otsu’s threshold, having
[T, SM] = graythresh (f)
4. Using image smoothing to improve global thresholding
a. Noise can turn a simple thresholding problem into unsolvable one.
b. When noise cannot be reduced at the source, and thresholding is the
segmentation method of choice, image smoothing is done prior to
thresholding to enhance the performance.
5. Using edges to improve global thresholding
a. Following algorithm is used to describe this process:
i. Compute an edge image from the input image.
ii. Specify a threshold value, T.
iii. Threshold the edge image to produce a binary image which is
used as marker image.
iv. Compute the histogram using only the pixels in input image that
correspond to the locations of 1-valued pixels in binary image.
v. Use the histogram to segment input image globally using Otsu’s
b. percentile2i function is used to compute an intensity value
corresponding to specified percentile, P, having syntax:
I = percentile2i (h, P)
6. Variable thresholding based on local statistics
a. Local thresholding is illustrated using the standard deviation and
mean of the pixels in a neighborhood of every point in an image.
b. Function stdfilt is used to compute the local standard deviation,
g = stdfilt (f, nhood)
7. Image thresholding using moving averages
a. A special case of the local thresholding method is based on
computing a moving average along scan lines of an image.
b. Function movingthresh is used to compute this, having syntax:
g = movingthresh (f, n, K)
1. Region growing
a. It is a procedure that groups pixels or subregions into larger region
based on predefined criteria for growth.
b. The basic approach is to start with a set of seed points and from
these grow regions by appending to each seed those neighboring
pixels that have predefined properties similar to the seed.
c. Function regiongrow is used to do basic region growing, having
[g, NR, SI, TI] = regiongrow (f, S, T)
2. Region splitting and merging
a. In this the image is subdivided initially into a set of arbitrary,
disjointed regions and the merge and split the regions.
b. Function splitmerge is used for the same, having syntax:
g = splitmerge (f, mindim, @predicate)
Segmentation using Watershed Transform
1. Watershed segmentation using distance transform
a. Distance transform is useful tool with the watershed transform for
b. Function bwdist is used to compute the distance transform, having
D = bwdist (f)
c. Function watershed is used to compute the negative of the distance
transform, having syntax:
L = watershed (A, conn)
2. Watershed segmentation using gradient
a. The gradient magnitude is used often to preprocess a gray-scale
image prior to using the watershed transform for segmentation.
b. The gradient magnitude image has high pixel values along object
edges, and low pixel values everywhere else.
c. Then the watershed transform would result in watershed ridge lines
along object edges.