Region-based segmentation. Corresponding matlab code. % Read image img =
imread('brain.png'); img = double(img(:,:,1));. % Selection of pixels ...
[email protected]
Digital Image Processing Image Analysis: Part 2
IMESI - 2009
Summary I. II. III. IV.
Introduction Digital image fundamentals Discrete 2D processing Image improvement
V. Image analysis
(6 houres)
Département GE - TI - Olivier Bernard
2
Image analysis Books Gonzales : Digital Image Processing, Prentice Hall (3th Ed.)
Département GE - TI - Olivier Bernard
3
Summary V. Image Analysis
Part 1
Mathematical Morphology Contour detection and analysis
Part 2
Region-based segmentation
Part 3
Shape analysis Shape recognition Département GE - TI - Olivier Bernard
4
Summary V. Image Analysis
Part 1
Mathematical Morphology Contour detection and analysis
Part 2
Region-based segmentation
Part 3
Shape analysis Shape recognition Département GE - TI - Olivier Bernard
5
Region-based segmentation Context
Definition Principle
Two kinds of methodology
Histogram based Region transformation based
Département GE - TI - Olivier Bernard
6
Region-based segmentation Context - Definition Segmentation consists on partitioning an image into a set of connected regions
Find homogeneous regions according to a specific criterion (intensity value, texture)
Département GE - TI - Olivier Bernard
7
Region-based segmentation Context - Definition The aim of region detection is to provide the possibility to characterize the detected object by parameter analysis (shape, position, size...)
Example of the need of region-based segmentation: object labeling
Département GE - TI - Olivier Bernard
8
Region-based segmentation Context - Definition Region segmentation is an ill-posed problem the perfect segmentation does not exist The choice of a particular method is linked to the nature of the image (texture, intensity, ...) the shape of the object to extract The time constrain
Département GE - TI - Olivier Bernard
9
Region-based segmentation Context – Two different methods Region-based Segmentation
Region transformation based
Histogram based
- Region growing - Region splitting - Region merging Département GE - TI - Olivier Bernard
10
Region-based segmentation Context
Definition Principle
Two kinds of methodology
Histogram based Region transformation based
Département GE - TI - Olivier Bernard
11
Region-based segmentation Context – Two different methods Region-based Segmentation
Region transformation based
Histogram based
- Region growing - Region splitting - Region merging Département GE - TI - Olivier Bernard
12
Region-based segmentation Histogram-based methods - Example The main idea is to individually select each specific histogram mode, and then select the corresponding area by thresholding
B A C
Initial image
Separation of A and B classes from class C (background)
Département GE - TI - Olivier Bernard
13
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram Detection of the corresponding area by thresholding Among the different area that contribute to this mode, select the biggest connected region from high level tools (for example: mathematical morphology) Apply this scheme for each histogram mode
Département GE - TI - Olivier Bernard
14
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram
Initial image
Image histogram Département GE - TI - Olivier Bernard
15
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram
Département GE - TI - Olivier Bernard
16
Region-based segmentation Histogram-based methods - Example Detection of the corresponding area from thresholding
Département GE - TI - Olivier Bernard
17
Region-based segmentation Histogram-based methods - Example Selection of the biggest connected region
Proposed scheme - Hysteresis thresholding - Mathematical morphology (erode, fill, close)
Département GE - TI - Olivier Bernard
18
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1)); % Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
19
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1));
Selection of pixels mode
% Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
mask 20
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1));
Region erosion
% Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
maskErode 21
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1));
Hysteresis thresholding
% Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
maskHyst 22
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1));
Fill holes
% Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
maskFill 23
Region-based segmentation Corresponding matlab code % Read image img = imread(‘brain.png'); img = double(img(:,:,1));
Region closing
% Selection of pixels corresponding to the selected histogram mode e = find(img>118); mask = zeros(size(img)); mask(e) = 255; % Region erosion through math morph se = strel('disk',3); maskErode = imerode(mask,se); % Hysteresis thresholding maskHyst = hysteresis(mask,maskErode); % Fill holes through math morpho maskFill = imfill(maskHyst,'holes'); % Region closing through math morpho se = strel('disk',1); final = imclose(maskFill,se);
Département GE - TI - Olivier Bernard
final 24
Region-based segmentation Histogram-based methods - Example
Département GE - TI - Olivier Bernard
25
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram
Département GE - TI - Olivier Bernard
26
Region-based segmentation Histogram-based methods - Example Detection of the corresponding area from thresholding
Département GE - TI - Olivier Bernard
27
Region-based segmentation Histogram-based methods - Example Selection of the biggest connected region
Proposed scheme - Hysteresis thresholding - Mathematical morphology (erode, close)
Département GE - TI - Olivier Bernard
28
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram
Département GE - TI - Olivier Bernard
29
Region-based segmentation Histogram-based methods - Example Detection of the corresponding area from thresholding
Département GE - TI - Olivier Bernard
30
Region-based segmentation Histogram-based methods - Example Selection of the biggest connected region
Proposed scheme - Hysteresis thresholding - Mathematical morphology (erode, close)
Département GE - TI - Olivier Bernard
31
Region-based segmentation Histogram-based methods - Example Extraction of a specific mode of the histogram
Département GE - TI - Olivier Bernard
32
Region-based segmentation Histogram-based methods - Example Detection of the corresponding area from thresholding
Département GE - TI - Olivier Bernard
33
Region-based segmentation Histogram-based methods - Example Selection of the biggest connected region
Proposed scheme - Mathematical morphology (erode, fill holes)
Département GE - TI - Olivier Bernard
34
Region-based segmentation Histogram-based methods - Example Final result
Initial image
Segmented image
Département GE - TI - Olivier Bernard
35
Region-based segmentation Histogram-based methods – choice of the threshold value What is the best way to choose a threshold value ? There exist a lot of methods based on probability Example: thresholding from learning
Département GE - TI - Olivier Bernard
36
Region-based segmentation Histogram-based methods – choice of the threshold value Example: thresholding from learning thresh = 94 object back
Goal: Separate the two modes, by choosing the minimum histogram value between two extremities Département GE - TI - Olivier Bernard
37
Region-based segmentation Histogram-based methods – Analytic method Model each mode through a priori distributions (for example two Gaussian models p1 et p2) Maximization of the following energy function s
N
0
s
Γ( s ) = ∫ p1 (n)dn + ∫ p2 (n)dn Γ( s ) = 1 − F2 (n = s ) + F1 (n = s ) where
Fi is a cumulative function Département GE - TI - Olivier Bernard
38
Region-based segmentation Histogram-based methods – Analytic method Maximization of function Γ( s )
thresh = 91
Approximation of the continuous integral by a discrete version Département GE - TI - Olivier Bernard
39
Region-based segmentation Histogram-based methods – Empirical method Find the threshold value which minimize the variance of the corresponding two classes Let h[n] be a histogram function G is the center of gravity of one class
∑ nh[n]
Gi ( s ) =
n∈Ci
∑ h[n]
var is the variance of one class vari ( s ) =
2 ( n − G ) h[n] ∑ i
n∈Ci
n∈Ci
Département GE - TI - Olivier Bernard
40
Region-based segmentation Histogram-based methods – Empirical method Find the threshold value that minimize the variance sum
sopt = arg min(var1 ( s ) + var2 ( s )) s
After simplification, the previous problem is equivalent to maximize the following energy criterion 2 2 J(s) : ∑ nh[n] ∑ nh[n] n∈C1 n∈C2 J ( s) = + ∑ h[n] ∑ h[n] n∈C1
n∈C 2
Département GE - TI - Olivier Bernard
41
Region-based segmentation Histogram-based methods – Empirical method Minimization of function
sopt
thresh = 102
Approximation of the continuous integral by a discrete version Département GE - TI - Olivier Bernard
42
Region-based segmentation Histogram-based methods – properties Implementation is quite simple Performance relatively low because of the non use of spatial coherence Method to be used when: images have regions which are easily separable (objects with high contrast) images are defined on multi-channels (multispectral images) which gives more information on the corresponding histogram Département GE - TI - Olivier Bernard
43
Region-based segmentation Context
Definition Principle
Two kinds of methodology
Histogram based Region transformation based
Département GE - TI - Olivier Bernard
44
Region-based segmentation Context – Two different methods Region-based Segmentation
Region transformation based
Histogram based
- Region growing - Region splitting - Region merging Département GE - TI - Olivier Bernard
45
Region-based segmentation Region transformation based methods Step that consists on splitting an image into subsets Ri called regions
Département GE - TI - Olivier Bernard
46
Region-based segmentation Region transformation based methods Methods based on a similarity criterion P and an elementary partition One has to define a test function that allows to validate the similarity criterion
Département GE - TI - Olivier Bernard
47
Region-based segmentation Region transformation based methods Similarity criterion in segmentation: region Ri is homogeneous Test function used to verify the previous similarity criterion Region contrast
P ( Ri ) = true ⇔ max Ri [ I ( x, y )] − min Ri [ I ( x, y ) ] < σ
Département GE - TI - Olivier Bernard
48
Region-based segmentation Region transformation based methods Similarity criterion in segmentation: region Ri is homogeneous Test function used to verify the previous similarity criterion Region standard deviation P( Ri ) = true ⇔ where
1 N
2 ( I ( x , y ) − m ) 0 ) if ( in1(i-1,j) > 0 ) out(i-1,j) = 255; count = count + end if ( in1(i+1,j) > 0 ) out(i+1,j) = 255; count = count + end if ( in1(i,j-1) > 0 ) out(i,j-1) = 255; count = count + end if ( in1(i,j+1) > 0 ) out(i,j+1) = 255; count = count + end end end end k = k + 1; end Département GE - TI - Olivier Bernard
1;
1;
1;
1;
91