0% found this document useful (0 votes)
21 views

Lecture 10-Image Segmentation

The document discusses image segmentation techniques. It introduces image segmentation and explains that the goal is to partition an image into meaningful regions. It then describes intensity-based segmentation methods like thresholding and shows an example of applying thresholding to segment coins from a background. Region-based methods and other techniques are also briefly mentioned.

Uploaded by

Tăng Hiền
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Lecture 10-Image Segmentation

The document discusses image segmentation techniques. It introduces image segmentation and explains that the goal is to partition an image into meaningful regions. It then describes intensity-based segmentation methods like thresholding and shows an example of applying thresholding to segment coins from a background. Region-based methods and other techniques are also briefly mentioned.

Uploaded by

Tăng Hiền
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

PART I

IMAGE PROCESSING
INSTRUCTOR: DR. NGUYEN NGOC TRUONG MINH
SCHOOL OF ELECTRICAL ENGINEERING, INTERNATIONAL UNIVERSITY (VNU-HCMC)

Ho Chi Minh City, Spring 2024


Lecture 10 – Image Segmentation 2

LECTURE X –
IMAGE SEGMENTATION
INSTRUCTOR: DR. NGUYEN NGOC TRUONG MINH
SCHOOL OF ELECTRICAL ENGINEERING, INTERNATIONAL UNIVERSITY (VNU-HCMC)

Ho Chi Minh City, Spring 2024


Lecture 10 – Image Segmentation 3

LECTURE CONTENT
• What is image segmentation and why is it relevant?

• What is image thresholding and how is it implemented in MATLAB?

• What are the most commonly used image segmentation techniques and how
do they work?

• Chapter Summary – What we have learned?

• Problems
Lecture 10 – Image Segmentation 4

10.1 INTRODUCTION
• Segmentation is one of the most crucial tasks in image processing and CV.
• As we may recall from our discussion in Lecture 1 (Section 1.5), image
segmentation is the operation that marks the transition between low-level
image processing and image analysis: the input of a segmentation block in a
machine vision system (MVS) is a preprocessed image, whereas the output is a
representation of the regions within that image.
• This representation can take the form of the boundaries among those regions
(e.g. when edge-based segmentation techniques are used) or information
about which pixel belongs to which region (e.g. in clustering-based
segmentation). Once an image has been segmented, the resulting individual
regions (or objects) can be described, represented, analyzed, and classified
with techniques.
Lecture 10 – Image Segmentation 5

10.1 INTRODUCTION

• Segmentation is defined as the process of partitioning an image into a set


of nonoverlapping regions whose union is the entire image. These regions
should ideally correspond to objects and their meaningful parts, and
background. Most image segmentation algorithms are based on one of
two basic properties that can be extracted from pixel values—
discontinuity and similarity—or a combination of them.
Lecture 10 – Image Segmentation 6

10.1 INTRODUCTION

• Segmentation of nontrivial images is a very hard problem—made even


harder by nonuniform lighting, shadows, overlapping among objects, poor
contrast between objects and background, and so on—that has been
approached from many different angles, with limited success to this date.

• Many image segmentation techniques and algorithms have been proposed


and implemented during the past 40 years and yet, except for relatively
“easy” scenes, the problem of segmentation remains unsolved.
Lecture 10 – Image Segmentation 7

10.1 INTRODUCTION

• Figure 10.1 illustrates the problem. At the top, it shows the color and
grayscale versions of a hard test image that will be used later in this
chapter.
• Segmenting this image into its four main objects (Lego bricks) and the
background is not a simple task for contemporary image segmentation
algorithms, due to uneven lighting, projected shadows, and occlusion
among objects. Attempting to do so without resorting to color
information makes the problem virtually impossible to solve for the
techniques described in this chapter.
Lecture 10 – Image Segmentation 8

10.1 INTRODUCTION
Lecture 10 – Image Segmentation 9

10.1 INTRODUCTION

• The bottom part of Figure 10.1 shows another test image, which is
considerably simpler and will probably lead to perfect segmentation with
even the simplest techniques.
• Although the original image has a few imperfections (particularly on one
coin that is significantly darker than the others), simple preprocessing
operations such as region filling using imfill function will turn it into an
image suitable for global thresholding and subsequent labeling of the
individual regions.
Lecture 10 – Image Segmentation 10

10.1 INTRODUCTION

• There is no underlying theory of image segmentation, only ad-hoc


methods, whose performance is often evaluated indirectly, based on the
performance of the larger system to which they belong.
• Even though they share the same goal, image segmentation techniques can
vary widely according to the type of image (e.g., binary, gray, color),
choice of mathematical framework (e.g., morphology, image statistics,
graph theory), type of features (e.g., intensity, color, texture, motion), and
approach (e.g., top-down, bottom-up, graph-based).
Lecture 10 – Image Segmentation 11

10.1 INTRODUCTION
• There is no universally accepted taxonomy for classification of image
segmentation algorithms either. In this lecture, we have organized the
different segmentation methods into the following categories:
⮚ Intensity-based methods, also known as non-contextual methods, work based
on pixel distributions (i.e., histograms). The best-known example of intensity-
based segmentation technique is thresholding.
⮚ Region-based methods, also known as contextual methods, rely on adjacency
and connectivity criteria between a pixel and its neighbors. The best-known
examples of region-based segmentation techniques are region growing and
split and merge.
⮚ Other methods, where we have grouped relevant segmentation techniques
that do not belong to any of the two categories above. These include
segmentation based on texture, edges, and motion, among others.
Lecture 10 – Image Segmentation 12

10.2 INTENSITY-BASED SEGMENTATION

• Intensity-based methods are conceptually the simplest approach to


segmentation.

• They rely on pixel statistics—usually expressed in the form of a


histogram—to determine which pixels belong to foreground objects and
which pixels should be labeled as background. The simplest method
within this category is image thresholding, which will be described in
detail in the remaining part of this section.
Lecture 10 – Image Segmentation 13

10.2.1 IMAGE THRESHOLDING

• The basic problem of thresholding is the conversion of an image with


many gray levels into another image with fewer gray levels, usually only
two (black/white).
• This conversion is usually performed by comparing each pixel intensity
with a reference value (threshold, hence the name) and replacing the pixel
with a value that means “white” or “black” depending on the outcome of
the comparison.
• Thresholding is a very popular image processing technique, due to its
simplicity, intuitive properties, and ease of implementation.
Lecture 10 – Image Segmentation 14

10.2.1 IMAGE THRESHOLDING


• Thresholding an image is a common preprocessing step in machine visual
systems in which there are relatively few objects of interest whose shape
(silhouette) is more important than surface properties (such as texture)
and whose average brightness is relatively higher or lower than the other
elements in the image.
• The test image in Figure 10.1c is an example of image suitable for image
thresholding. Its histogram (Figure 10.2) has two distinct modes, the
narrowest and most prominent one (on the left) corresponding to
background pixels, the broadest one (on the right) reflecting the intensity
distribution of pixels corresponding to the coins.
Lecture 10 – Image Segmentation 15

10.2.1 IMAGE THRESHOLDING


Lecture 10 – Image Segmentation 16

10.2.1 IMAGE THRESHOLDING


Lecture 10 – Image Segmentation 17

10.2.1 IMAGE THRESHOLDING

In MATLAB
• The IPT has a function to convert a grayscale image into a binary (black-
and-white) image, im2bw, that takes an image and a threshold value as
input parameters.
Lecture 10 – Image Segmentation 18

10.2.2 GLOBAL THRESHOLDING


• When the intensity distribution of an image allows a clear differentiation
between pixels of two distinct predominant average gray levels, the
resulting histogram has a bimodal shape (such as the one in Figure 10.2),
which suggests that there may be a single value of T that can be used as a
threshold for the entire image. For the case of a single image, the choice
of the actual value of T can be done manually, in typical trial and error
fashion, as follows:
1. Inspecting the image’s histogram (using imhist).
2. Select an appropriate value for T.
3. Apply the selected value (using im2bw) to the image.
4. Inspect the results: if they are acceptable, save resulting image. Otherwise,
make adjustments and repeat steps 2–4.
Lecture 10 – Image Segmentation 19

10.2.2 GLOBAL THRESHOLDING


Lecture 10 – Image Segmentation 20

10.2.2 GLOBAL THRESHOLDING


Lecture 10 – Image Segmentation 21

10.2.2 GLOBAL THRESHOLDING


• Optimal Thresholding Many optimal strategies for selecting threshold
values have been suggested in the literature. These strategies usually rely
on assumed statistical models and consist of modeling the thresholding
problem as a statistical inference problem.
• Unfortunately, such statistical models usually cannot take into account
important factors such as borders and continuity, shadows, nonuniform
reflectance, and other perceptual aspects that would impact a human user
making the same decision. Consequently, for most of the cases, manual
threshold selection by humans will produce better results than statistical
approaches would.
Lecture 10 – Image Segmentation 22

10.2.2 GLOBAL THRESHOLDING


Lecture 10 – Image Segmentation 23

10.2.3 THE IMPACT OF ILLUMINATION AND NOISE


ON THRESHOLDING
Lecture 10 – Image Segmentation 24

10.2.3 THE IMPACT OF ILLUMINATION AND NOISE


ON THRESHOLDING
Lecture 10 – Image Segmentation 25

10.2.3 THE IMPACT OF ILLUMINATION AND NOISE


ON THRESHOLDING
Lecture 10 – Image Segmentation 26

10.2.3 THE IMPACT OF ILLUMINATION AND NOISE


ON THRESHOLDING
Lecture 10 – Image Segmentation 27

10.2.3 THE IMPACT OF ILLUMINATION AND NOISE


ON THRESHOLDING
Lecture 10 – Image Segmentation 28

10.2.4 LOCAL THRESHOLDING

• Local (also called adaptive) thresholding uses block processing to


threshold blocks of pixels, one at a time. The size of the block is usually
specified by the user, with the two extreme conditions being avoided:
blocks that are too small may require an enormous amount of processing
time to compute, whereas large blocks may produce results that are not
substantially better than the ones obtained with global thresholding.
In MATLAB
• The block processing technique is implemented using the blkproc
function.
Lecture 10 – Image Segmentation 29

EXAMPLE 10.1
Lecture 10 – Image Segmentation 30

EXAMPLE 10.1
Lecture 10 – Image Segmentation 31

10.3 REGION-BASED SEGMENTATION


Lecture 10 – Image Segmentation 32

10.3 REGION-BASED SEGMENTATION


Lecture 10 – Image Segmentation 33

10.3 REGION-BASED SEGMENTATION


Lecture 10 – Image Segmentation 34

10.3 REGION-BASED SEGMENTATION


Lecture 10 – Image Segmentation 35

10.3.1 REGION GROWING

• The basic idea of region growing methods is to start from a pixel and
grow a region around it, as long as the resulting region continues to
satisfy a homogeneity criterion. It is, in that sense, a bottom-up approach
to segmentation, which starts with individual pixels (also called seeds) and
produces segmented regions at the end of the process.
• The key factors in region growing are as follows:
⮚The Choice of Similarity Criteria: For monochrome images, regions are
analyzed based on intensity levels (either the gray levels themselves or
the measures that can easily be calculated from them, for example,
moments and texture descriptors) and connectivity properties.
Lecture 10 – Image Segmentation 36

10.3.1 REGION GROWING

⮚The Selection of Seed Points: These can be determined interactively (if


the application allows) or based on a preliminary cluster analysis of the
image, used to determine groups of pixels that share similar properties,
from which a seed (e.g., corresponding to the centroid of each cluster)
can be chosen.
⮚The Definition of a Stopping Rule: A region should stop growing when
there are no further pixels that satisfy the homogeneity and connectivity
criteria to be included in that region.
Lecture 10 – Image Segmentation 37

10.3.1 REGION GROWING

Let f(x,y) be the input image Let Mi be the mean gray level of pixels in Ri
Define a set of regions R1, R2, ..., Rn, each if the neighbor is unassigned and
|f(x,y) - Mi| <= Delta then
consisting of a single seed pixel Add neighbor to Ri
repeat Update Mi
for i=1to n do end if
for each pixel p at the border of Ri do end for
end for
for all neighbors of p do end for
Let (x,y) be the neighbor’s coordinates until no more pixels can be assigned to regions
Lecture 10 – Image Segmentation 38

EXAMPLE 10.2
Lecture 10 – Image Segmentation 39

EXAMPLE 10.2
Lecture 10 – Image Segmentation 40

EXAMPLE 10.3

• Figure 15.8 shows the results of applying a region growing algorithm to


the two test images originally introduced in Figure 15.1. Part (a) shows
the hard input image with the seed points (specified interactively by the
user) overlaid. Part (b) shows the results of using region growing
(pseudocolored for easier visualization): four regions plus background.

• A quick inspection shows that the results are virtually useless, primarily
due to poor contrast between the two darker and two brighter bricks
and the influence of projected shadows.
Lecture 10 – Image Segmentation 41

EXAMPLE 10.3

• For comparison purposes, we ran the same algorithm with an easy input
image (Figure 15.8c) in unsupervised mode, that is, without specifying any
points to be used as seeds (or even the total number of regions that the
algorithm should return).

• The results (Figure 15.8d) are good, comparable to the ones obtained
using global thresholding earlier in this chapter.
Lecture 10 – Image Segmentation 42

EXAMPLE 10.3
Lecture 10 – Image Segmentation 43

10.3.1 REGION GROWING

Limitations of Region Growing The basic region growing algorithm


described in this section has several limitations, listed below:
• It is not very stable: significantly different results are obtained when
switching between 4-connectivity and 8-connectivity criteria.
• Segmentation results are very sensitive to choice of logical uniformity
predicate.
• The number of seeds provided by the user may not be sufficient to assign
every pixel to a region.
• If two or more seeds that should belong to the same region are
incorrectly provided to the algorithm, it will be forced to create distinct
regions around them although only one region should exist.
Lecture 10 – Image Segmentation 44

10.3.2 REGION SPLITTING AND MERGING

• Region splitting is a top-down approach to image segmentation. It starts


from the entire image and partitions it into smaller subimages until each
resulting region is considered homogeneous by some criteria.

• At the end of the process, it is guaranteed that the resulting regions satisfy
the homogeneity criterion. It is possible, however, that two or more
adjacent regions are similar enough that should be combined into one.

• This is the goal of the merging step: to merge two or more adjacent
regions into one if they satisfy a homogeneity criterion.
Lecture 10-Image Segmentation

10.3.2 REGION SPLITTING AND MERGING



Lecture 10 – Image Segmentation 46

10.3.2 REGION SPLITTING AND MERGING


Lecture 10 – Image Segmentation 47

10.4 WATERSHED SEGMENTATION

• In this section, we describe a popular application of the morphological


watershed transform in image segmentation. The watershed transform is
a morphological technique that derives its name from an expression in
geography, where watershed is defined as the ridge that divides areas
drained by different river systems. A related term, catchment (or
drainage) basin, is used to represent the geographical area that drains into
a river or reservoir.
• In morphological image processing, the watershed transform is used to
represent regions in a segmented image (equivalent to catchment basins)
and the boundaries among them (analogous to the ridge lines).
Lecture 10 – Image Segmentation 48

10.4 WATERSHED SEGMENTATION

In MATLAB
• The IPT function watershed implements the watershed transform. It takes
an input image and (optionally) a connectivity criterion (4- or 8-
connectivity) as input parameters and produces a labeled matrix (of the
same size as the input image) as a result.
• Elements labeled 1 and higher belong to a unique watershed region,
identified by their number, whereas elements labeled 0 do not belong to
any watershed region.
Lecture 10 – Image Segmentation 49

10.4.1 THE DISTANCE TRANSFORM

• The distance transform is a useful tool employed in conjunction with the


watershed transform. It computes the distance from every pixel to the
nearest nonzero-valued pixel. It is implemented in MATLAB by function
bwdist, which allows specification of the distance method (Euclidean
distance being the default) to be used.
Lecture 10 – Image Segmentation 50

EXAMPLE 10.4

• This example shows the creation of a test matrix of size 5x5 and the
results of computing the distance transform using bwdist and two
different distance calculations:
• Euclidean and city block.
>>a = [0 1 1 0 1; 1 1 1 0 0; 0 0 0 1 0; 0 0 0 0 0; 0 1 0 0 0];
a=
0 1 1 0 1
1 1 1 0 0
0 0 0 1 0
0 0 0 0 0
0 1 0 0 0
Lecture 10 – Image Segmentation 51

EXAMPLE 10.4
>> b = bwdist(a)
b=
1.0000 0 0 1.0000 0
0 0 0 1.0000 1.0000
1.0000 1.0000 1.0000 0 1.0000
1.4142 1.0000 1.4142 1.0000 1.4142
1.0000 0 1.0000 2.0000 2.2361
>> b = bwdist(a,’cityblock’)
b=
1 0 0 1 0
0 0 0 1 1
1 1 1 0 1
2 1 2 1 2
1 0 1 2 3
Lecture 10 – Image Segmentation 52

EXAMPLE 10.5

• Figure 10.10 shows an example of segmentation using watershed. It uses


a binarized and postprocessed version of the coins test image as input (a).
Part (b) shows the results of the distance transform calculations. Part (c)
shows the ridge lines obtained as a result of applying the watershed
transform.

• Finally, part (d) shows the overlap between parts (a) and (c), indicating
how the watershed transform results lead to an excellent segmentation
result in this particular case.
Lecture 10 – Image Segmentation 53

EXAMPLE 10.5
Lecture 10 – Image Segmentation 54

10.5 TUTORIAL: IMAGE THRESHOLDING

Goal
• The goal of this tutorial is to learn to perform image thresholding using
MATLAB and the IPT.
Objectives
• Learn how to visually select a threshold value using a heuristic approach.
• Explore the graythresh function for automatic threshold value selection.
• Learn how to implement adaptive thresholding.
Lecture 10 – Image Segmentation 55

10.5 TUTORIAL: IMAGE THRESHOLDING


Procedure Global Thresholding
The first method of thresholding that we will explore involves visually
analyzing the histogram of an image to determine the appropriate value of T
(the threshold value).
1. Load and display the test image.
I = imread(’coins.png’);
figure, imshow(I), title(’Original Image’);
2. Display a histogram plot of the coins image to determine what threshold
level to use.
figure, imhist(I), title(’Histogram of Image’);
Lecture 10 – Image Segmentation 56

10.5 TUTORIAL: IMAGE THRESHOLDING

Question 1. Which peak of the histogram represents the


background pixels and which peak represents the pixels
associated with the coins?
The histogram of the image suggests a bimodal distribution of grayscale
values. This means that the objects in the image are clearly separated from
the background. We can inspect the X and Y values of the histogram plot
by clicking the “inspect” icon and then selecting a particular bar on the
graph.
3. Inspect the histogram near the right of the background pixels by
activating the data cursor. To do so, click on the “inspect” icon.
Lecture 10 – Image Segmentation 57

10.5 TUTORIAL: IMAGE THRESHOLDING

• Figure 15.11 illustrates what the selection


should look like. The data cursor tool
suggests that values between 80 and 85
could possibly be used as a threshold,
since they fall immediately to the right of
the leftmost peak in the histogram.
• Let us see what happens if we use a
threshold value of 85.
Lecture 10 – Image Segmentation 58

10.5 TUTORIAL: IMAGE THRESHOLDING


4. Set the threshold value to 85 and generate the new image.
T = 85; I_thresh = im2bw(I,( T / 255));
figure, imshow(I_thresh), title(’Threshold Image (heuristic)’);
Question 2. What is the purpose of the im2bw function?
Question 3. Why do we divide the threshold value by 255 in the
im2bw function call?
You may have noticed that several pixels—some white pixels in the
background and a few black pixels where coins are located—do not belong
in the resulting image. This small amount of noise can be cleaned up using
the noise removal techniques discussed in chapter 12.
Lecture 10 – Image Segmentation 59

10.5 TUTORIAL: IMAGE THRESHOLDING

Question 4.Write one or more lines of MATLAB code to remove


the noise pixels in the thresholded image.
The thresholding process we just explored is known as the heuristic
approach. Although it did work, it cannot be extended to automated
processes. Imagine taking on the job of thresholding a thousand images
using the heuristic approach! MATLAB’s IPT function graythresh uses
Otsu’s method for automatically finding the best threshold value.
Lecture 10 – Image Segmentation 60

10.5 TUTORIAL: IMAGE THRESHOLDING

5. Use the graythresh function to generate the threshold value


automatically.

T2 = graythresh(I);
I_thresh2 = im2bw(I,T2);
figure, imshow(I_thresh2), title(’Threshold Image (graythresh)’);
Question 5. How did the graythresh function compare with the
heuristic approach?
Lecture 10 – Image Segmentation 61

10.5 TUTORIAL: IMAGE THRESHOLDING

Adaptive Thresholding
Bimodal images are fairly easy to separate using basic thresholding
techniques discussed thus far. Some images, however, are not as well
behaved and require a more advanced thresholding technique such as
adaptive thresholding. Take, for example, one of the images we used back in
Tutorial 6.1: a scanned text document with a nonuniform gradient
background.
6. Close all open figures and clear all workspace variables.
7. Load the gradient_with_text image and prepare a subplot.
I = imread(’gradient_with_text.tif’);
figure, imshow(I), title(’Original Image’);
Lecture 10 – Image Segmentation 62

10.5 TUTORIAL: IMAGE THRESHOLDING


Let us see what happens when we attempt to threshold this image using the
techniques we have learned so far.
8. Globally threshold the image.
I_gthresh = im2bw(I,graythresh(I));
figure, imshow(I_gthresh), title(’Global Thresholding’);
figure, imhist(I), title(’Histogram of Original’);
As you may have noticed, we cannot pick one particular value to set as the
threshold value because the image is clearly not bimodal. Adaptive
thresholding may help us in this instance. To properly implement adaptive
thresholding, we must use the blkproc function to perform an operation on
small blocks of pixels one at a time.
Lecture 10 – Image Segmentation 63

10.5 TUTORIAL: IMAGE THRESHOLDING


In order to use the function, we must specify what is to be done on each
block of pixels. This can be specified within a function that we will create
manually. Let us first set up this function.
9. Close all open figures.
10. Start a new M-File in the MATLAB Editor.
11. Define the function as well as its input and output parameters in the
first line.
function y = adapt_thresh(x);
This function will be used to define each new block of pixels in our image.
Basically all we want to do is perform thresholding on each block
individually, so the code to do so will be similar to the code we previously
used for thresholding.
Lecture 10 – Image Segmentation 64

10.5 TUTORIAL: IMAGE THRESHOLDING


Lecture 10 – Image Segmentation 65

10.5 TUTORIAL: IMAGE THRESHOLDING


14. Perform adaptive thresholding by entering the following command in
the command window. Note that it may take a moment to perform the
calculation, so be patient.
I_thresh = blkproc(I,[10 10],@adapt_thresh);
15. Display the original and new image.
figure
subplot(1,2,1), imshow(I), title(’Original Image’);
subplot(1,2,2), imshow(I_thresh), title(’Adaptive Thresholding’);
The output is not quite what we expected. If you look closely, however, the
operation was successful near the text, but everywhere else it was a
disaster.
Lecture 10 – Image Segmentation 66

10.5 TUTORIAL: IMAGE THRESHOLDING

This suggests that we need to add an extra step to our function to


compensate for this unwanted effect. Over the next few steps, let us
examine the standard deviation of the original image where there is text,
and where there is not.
16. Calculate the standard deviation of two 10x10 blocks of pixels; one
where there is text and another where there is not.
std_without_text = std2(I(1:10, 1:10))
std_with_text = std2(I(100:110, 100:110))
Lecture 10 – Image Segmentation 67

10.5 TUTORIAL: IMAGE THRESHOLDING

Question 6. What is the difference between the standard


deviation of the two blocks of pixels? Explain.
Since there is such a difference between a block with and without text, we
can use this information to improve our function. Let us replace the one
line of code we previously wrote with the new code that will include an if
statement: if the standard deviation of the block of pixels is low, then simply
label it as background; otherwise, perform thresholding on it. This change
should cause the function to only perform thresholding where text exists.
Everything else will be labeled as background.
Lecture 10 – Image Segmentation 68

10.5 TUTORIAL: IMAGE THRESHOLDING

17. Replace the last line of our function with the following code. Save the
function after the alteration.
if std2(x) < 1
y = ones(size(x,1),size(x,2));
else
y = im2bw(x,graythresh(x));
end
Question 7. How does our function label a block of pixels as
background?
Lecture 10 – Image Segmentation 69

10.5 TUTORIAL: IMAGE THRESHOLDING


18. Now rerun the block process (in the command window) to see the
result.
I_thresh2 = blkproc(I,[10 10],@adapt_thresh);
figure, subplot(1,2,1), imshow(I), title(’Original Image’);
subplot(1,2,2), imshow(I_thresh2), title(’Adaptive Thresholding’);
Question 8. How does the output of the new function compare
with the old?
Question 9.What is the main limitation of the adaptive
thresholding function developed in this tutorial?
Lecture 10 – Image Segmentation 70

WHAT HAVE WE LEARNED?

• Image segmentation is the process of grouping image pixels into


meaningful, usually connected, regions. It is an important (and often
required) step in many image processing solutions. It establishes the
transition between treating the image as a whole to processing individual
relevant regions.

• Image segmentation is a hard image processing problem: the quality of the


results will depend on the algorithm, careful selection of algorithm’s
parameters, and the input image.
Lecture 10 – Image Segmentation 71

WHAT HAVE WE LEARNED?

• Thresholding is an image processing technique by which an input


(grayscale) image is requantized to two gray levels, that is, converted to a
binary image. Each pixel in the original image is compared with a
threshold; the result of such comparison will determine whether the
pixel will be converted to black or white. The simplest thresholding
algorithm (global thresholding, im2bw in MATLAB) employs one value for
the entire image.
• Image segmentation techniques can be classified in three main groups:
intensity-based methods (e.g., thresholding), region-based methods (e.g.,
region growing and split and merge), and other methods (e.g.,
segmentation based on texture, edges, and motion).
Lecture 10 – Image Segmentation 72

PROBLEMS

Problem 1. Explain in your own words why the image on the top right of
Figure 15.1 is significantly harder to segment than the one on the bottom
left of the same figure.
Problem 2. Modify the MATLAB code to perform iterative threshold
selection on an input gray-level image (section 15.2.2) to include a variable
that counts the number of iterations and an array that stores the values of
T for each iteration.
Problem 3. Write a MATLAB script to demonstrate that thresholding
techniques can be used to subtract the background of an image.
Lecture 10 – Image Segmentation 73

END OF LECTURE 10

LECTURE 11 – COLOR IMAGE PROCESSING

You might also like