38
Introduction to Image Segmentation (Lecture #12) Antonio Zanotti Radiology Department 11/09/2012

Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

  • Upload
    vudung

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Introduction to Image Segmentation

(Lecture #12)

Antonio Zanotti Radiology Department

11/09/2012

Page 2: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Lecture Outline

• The role of segmentation in medical imaging

• Thresholding

• Erosion and dilation operators

• Region growing

• Snakes and active contours

• Level set method

Page 3: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Why doing image segmentation?

• The goal of image segmentation is to partition a volumetric medical image into separate regions, usually anatomic structures (tissue types) that are meaningful for a specific task

• So image segmentation is sub- division of image in different regions

Page 4: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Examples

• Carotid wall in angiographic/neorological studies.

• Lesion’s quantification (neoplasia,schlerosys, etc)

• Simulation and planning of a surgery

• To measure perimeters, surfaces and volumes

Page 5: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Flow chart

Original image

Recognition

Dynamic reduction

Shape recognition

Application of the appropriate filter/algorithm

A segmented image is always binary (except in some cases)

Based on different models, like phantoms

Page 6: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Very important to understand

There is no optimal algorithm for image segmentation It depends on the type of image, what we are looking for, to the accuracy needed.

Page 7: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Global Thresholding

When we have a bimodal histogram, we can establish a threshold value, and every pixel up that value is the object and every pixel behind that value is the background

1 if (a[m,n] > T) g[m,n] = 0 if (a[m,n] ≤ T)

Page 8: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Matlab example >> A=imread('im_00004.jpg');

>> imagesc(A), colormap gray

>> figure

>> imhist(A)

>> level = graythresh(A)

level =

0.3412

>> level*255

ans =

87

>> BW = im2bw(A,level);

>> figure

>> imagesc(BW), colormap gray

>> A=imread('im_00004.jpg');

>> imagesc(A), colormap gray

>> figure

>> imhist(A)

>> [x,y]=find(A>=87);

>> clear BW

>> BW=zeros(512,512);

>> for i = 1:length(x)

BW(x(i),y(i))=1;

end

>> imagesc(BW), colormap

gray

Page 9: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Non-global threshold

)},(),,(,,{( yxIyxpyxfT

The threshold T is global if only depends on f(x,y)

If T depends also of p(x,y), is called local threshold. For example, It depends on

the outcome of a kernel applied to the image.

If T depends also of (x,y), the threshold is dinamic. It depends on the location of

the pixel.

Page 10: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Dot detection

The detection of isolated points in the image and very diverse of the background is done by the following filter

Laplacian filter

If R = sum of the values of the product between filter coefficients and image T = Threshold (NON NEGATIVE) A point is part of the image if |R|≥ T

Page 11: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Line detection

Using the appropriates filters is possible to detect discontinuities in a certain direction. GRADIENT FILTERS

Horizontal +45º

-45º Vertical

A B

C D

Page 12: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Line detection

Ri: sum of the values of the product and coefficients of the i-th filter and the image A point is on the i-th line if |Ri|>|Rj| ∀ i≠j

Horizontal Vertical +45º -45º

Page 13: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Line detection

RA=40 RB=22 RC=4 RD=172

Page 14: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Morphological operators

They are called like this because they were made to recognise forms, like triangles, circles, etc. They are local operators and there are several possible geometries (lines, circles, squares, rings,…) each one to adjust on the image.

0 0 0 0 0 0 0

0 0 1 1 1 0 0

0 1 1 1 1 1 0

0 1 1 1 1 1 0

0 1 1 1 1 1 0

0 0 1 1 1 0 0

0 0 0 0 0 0 0

Page 15: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Erosion

The value of the output pixel is the minimum between all the pixels selected in the input image by the structural element

1 0 0 0 0 0

0 1 0 0 0 0

0 1 0 1 1 0

0 1 1 1 0 0

0 0 0 1 1 0

0 0

0

0

0

0

1 1 1

Structuring element

Input image Output image

Page 16: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Example of erosion

originalBW = imread('circles.png');

se = strel('disk',11);

erodedBW = imerode(originalBW,se);

imshow(originalBW), figure,

imshow(erodedBW)

Page 17: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Dilation

1 0 0 0 0 0

0 1 0 0 0 0

0 1 0 1 1 0

0 1 1 1 0 0

0 0 0 1 1 0

1 1

1

1

1

0

1 1 1

Structuring element

Input image Output image

The value of the output pixel is the maximum between all the pixels selected in the input image by the structuring element

Page 18: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Example of dilation

originalBW = imread('circles.png');

se = strel('disk',11);

erodedBW = imdilate(originalBW,se);

imshow(originalBW), figure,

imshow(erodedBW)

Page 19: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Opening and Closing Using the erode and dilate operators, we can obtain others, eg Opening = erode, then dilate Closing = dilate, then erode

The structural element remains the same for the erosion and for the dilation. The opening removes the smallest objects of the structural element preserving the background. The closure removes the background in favor of the objects -> very used to make "hole filling “

Page 20: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Example of Closing

closeBW = imclose(originalBW,se);

figure, imshow(closeBW)

Page 21: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Example of Opening

closeBW = imopen(originalBW,se);

figure, imshow(closeBW)

Page 22: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Region Growing

•Group of pixels or sub-regions into larger regions when homogeneity criterion is satisfied. •Regions grows around the seed point based on similar properties (gray level, textures, colors) PROS: •Better in noisy images where edges are hard to identify

CONS: •Seed point must be specified •Different seed point will give different results

Page 23: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Matlab example

[x y]=find(A<=(value+ amplitudT/2)&A>=(value-

amplitudT/2));

BW=zeros(size(A));

for i=1:length(x)

BW(x(i),y(i))=1;

end

%figure, imagesc(BW), colormap gray

cc = bwconncomp(BW);

labeled = labelmatrix(cc);

regionLabel=labeled(seedx,seedy);

clear x y BW

BW=zeros(size(A));

[x y]=find(labeled==regionLabel);

for i=1:length(x)

BW(x(i),y(i))=1;

end

% function to implement region

growing

%

% BW=region(A,seedx,seedy)

%

% input parameters

% A image to implement the

region growing

% seedx & seedy coordenates of

the seed

% output parameters

% BW is the black&white image

function [BW] =

region(A,seedx,seedy)

value=A(seedx,seedy);

amplitudT = 40;

Page 24: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Example

Values of threshold- min=200 max=300

Page 25: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Deformable Models The snakes are deformable curves under the effect of. a. Internal forces because of the curve itself b. External forces because of experimental data

The balance between the two forces is what determinates the adjustment of the snake to certain forms, objects, edges, or another image feature. There are two types • Parametric active contours • Geometric active contours

Page 26: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Continuity controlled model

Internal forces prevent the curve to break (elasticity) or to roll (tightness) . The model adjusts the best it cans to edges respecting the constraints imposed about tightness and elasticity External forces Gradients that attracts or rejects the curve

Page 27: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Snakes Two problems • The result depends a lot of the initial conditions • Local minimums

Continuity controlled model Representation of the snake in planar curvilinear coordinates

]1,0[

)](),([)(:

s

sysxsvs

The function to minimize is:

1

0

22))(())('')('(

2

1dssvEsvsvE ext

Page 28: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Internal Energy Imposes the regularity of the snake

1

0

22))(())('')('(

2

1dssvEsvsvE ext

The α and β coefficients control the regularity of the curve and weigh the two contributions: a. α modulates the elasticity/stretching b. β modulates the stiffness/bending

Page 29: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

External Energy

• Supose we have an image • Can compute the gradient •Edge strength at pixel (x,y) is •External energy of a contour point v=(x,y) could be:

•External energy term for the whole snake is:

),( yxI

),( yxI

),( yxI

22),()( yxIvIE

1

0

))(( dssvEE ext

Page 30: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Equation to minimize

1

0

22))(())('')('(

2

1dssvEsvsvE ext

Equivalent to say

0ds

dE

0int extFF

PROBLEM = LOCAL MINIMUM

Page 31: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set Method Proposed by Osher and Sethian

nxxC :,0)(|

Page 32: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set Method

The level set approach:

Define problem in 1 higher dimension Define level set function z = (x,y,t = 0) where the (x,y) plane contains the contour, and z = signed Euclidean distance transform value (negative means inside closed contour, positive means outside contour)

Page 33: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set Method

Contour = cross section at z = 0, i.e.,

{(x,y) | (x,y,t) = 0}

Page 34: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set Method

0y

Φ

x

ΦF

t

Φ

0ΦFt

Φ

2122

1. Define a velocity field, F, that specifies how contour points move in time. • Based on application-specific physics such as time, position, normal,

curvature, image gradient magnitude 2. Build an initial value for the level set function, (x,y,t=0), based on the initial

contour position 3. Adjust over time; contour at time t defined by (x(t), y(t), t) = 0

Page 35: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set Method Constraint: level set value of a point on the contour with motion x(t) must always be 0

(x(t), t) = 0

By the chain rule t + (x(t), t) · x(t) = 0

Since F supplies the speed in the outward normal direction x(t) · n = F, where n = / ||

Hence evolution equation for is t + F|| = 0

Page 36: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Speed Function F Two terms, one to attract it to discontinuities and another to smooth.

Page 37: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Speed Function F

There are different ways to define the sped function. Another, is the one proposed by Chan and Vese that make the model independent of edges and gradients

C1 = mean value of the pixels inside C C2 = mean value of the pixels outside C

Page 38: Introduction to Image Segmentation (Lecture #11)cai2r.net/sites/default/files/documents/BIGP_Docs/Courses_Lectures... · Introduction to Image Segmentation (Lecture #12) Antonio Zanotti

Level Set