24
ANIRUDH MUNNANGI DAVID DRAKE Thresholding and Counting

Cell calculation

Embed Size (px)

DESCRIPTION

One of the important application in image processing is to be able to judge the different edges in an image and be able to distinguish various parts of it. Clearly, this is an application dependent task and results and analysis will vary as per the situation. These slides show a general description on how to calculate the number of cells in a microscopic tissue. There are two version one being the over-stained tissue and the other being the better one. We see how the algorithm is able to calculate the number of cells.

Citation preview

Page 1: Cell calculation

A N I R U D H M U N N A N G I

D A V I D D R A K E

Thresholding and Counting

Page 2: Cell calculation

Overview

Objectives

Background

Matlab

Importing the Image

Thresholding

Inverse Mapping

Image Subtraction

Counting the Number of Cells

Conclusion

Page 3: Cell calculation

Objectives

Segment cells from the background media in a digitized microscopy slide image using a basic thresholding technique

Count the total amount of cells segmented from the background media

Page 4: Cell calculation

Background

Basic Thresholding

Background pixels have intensity values grouped into two dominant modes

Select a threshold, T, that separates these modes

Segmented image:

Tyxfif

Tyxfifyxg

),(

),(

0

1),(

(Gonzalez & Wood, 2008)

Page 5: Cell calculation

Background

Global Thresholding

1. Select an initial estimate for the global threshold, T

2. Segment the image using the previous equation

3. Compute the average (mean) intensity values m1 and m2 for the pixels G1 and G2, respectively

4. Compute a new threshold value:

5. Repeat steps 2 through 4 until optimum threshold determined

(Gonzalez & Wood, 2008)

)(2

121 mmT

Page 6: Cell calculation

Background

Otsu’s Method Digital image with M x N pixels has {0, 1, 2, …., L – 1} Intensity Levels

Normalized histogram

T(k) = k, 0 < k < L-1; separate pixels into two classes C1 and C2

Probability that a pixel is assigned to class C1 and C2

The mean intensity value of the pixels assigned to C1 and C2

(Gonzalez & Wood, 2008)

NMnp ii / 0,11

0

i

L

i

i pp

k

i

ipkP0

1 )( )(1)( 1

1

1

2 kPpkPL

ki

i

k

i

iipkP

km01

1

)(

1)(

1

12

2

)(

1)(

L

ki

iipkP

km

Page 7: Cell calculation

Background

Otsu’s Method Evaluate k using normalized, dimensionless metric

Introduce variable k into the previous equation

Obtain maximum threshold value k*, by maximizing σ2B, then apply to basic

thresholding equation

2

2

G

B

)1(

)(

11

212

PP

mPmG

B

1

0

2

.

2 )(L

i

iGG pmi

2

2 )()(

G

B kk

))(1)((

)]()([

11

212

kPkP

kmkPmG

B

(Gonzalez & Wood, 2008)

)(max*)( 2

10

2 kk BLk

B*),(

*),(

0

1),(

kyxfif

kyxfifyxg

Page 8: Cell calculation

Importing the Images

In Matlab:

img_gs=imread('Normal1.jpg'); %Load the image

figure

imshow(img_gs); %Plot the original image

title('Original Image: Grayscale');

Page 9: Cell calculation

Importing the images

X: 349 Y: 270

Index: 173

RGB: 0.529, 0.529, 0.529

Original Image: Grayscale

X: 456 Y: 546

Index: 171

RGB: 0.514, 0.514, 0.514

X: 746 Y: 388

Index: 176

RGB: 0.553, 0.553, 0.553

Page 10: Cell calculation

Thresholding

In Matlab:

ith=175/255; %Determine threshold by cursor

img_t=im2bw(img_gs,th); %Convert to binary

figure

imshow(img_t); %Plot the image

title('Thresholded Image');

Page 11: Cell calculation

Thresholding

Thresholded Image

Page 12: Cell calculation

Thresholding

Due to cell staining and digitization of the microscopy slides, the corners of the slides were darkened towards the color of the individual cells

This will cause tremendous error in our counting algorithm, so it must be removed using inverse mapping and image subtraction

Page 13: Cell calculation

Inverse Mapping

In Matlab:

imginv=~img_t; %Take the inverse of the binary map

figure

imshow(imginv); %Plot the inversed binary image

title('Threshold Image-Color Inverted');

Page 14: Cell calculation

Inverse Mapping

Threshold Image-Color Inverted

Page 15: Cell calculation

Image Subtraction

In Matlab:%Find large connected parts

subimg=bwareaopen(imginv,400);

%Best approximation of threshold is 400 after trial and error

figure

imshow(subimg); %Plot the image

title('image after small pixels removed');

Page 16: Cell calculation

Image Subtraction

image after small pixels removed

Page 17: Cell calculation

Image Subtraction

In Matlab:%Subtract the corners from the inverse binary map

newimg=imginv-subimg;

figure

imshow(newimg); %Plot the image

title('Image of the individual cells);

Page 18: Cell calculation

Image Subtraction

Image of the individual cells

Page 19: Cell calculation

Counting the Number of Cells

Important to approximate the exact number of cells

Results will be used in a statistical analysis comparing repaired tissue with controls

Counting error will most likely occur

How much fluorescence is absorbed by the cells determines the appropriate threshold parameter (some cells excluded)

Elimination of the corner areas (more exclusion of cells)

Each slide differs in the amount of staining

Page 20: Cell calculation

Counting the Number of Cells

In Matlab:%Count the number of cells by finding groups of largely %connected pixels

b=bwboundaries(img_t);

figure

hold on

imshow(img_t); %Plot the image

title('Threshold Image-Color Inverted');

text(10,10, strcat('\color{green}Objects Found:', …

num2str(length(b)))); %Add count no. to image

hold off

Page 21: Cell calculation

Counting the Number of Cells

Threshold Image-Color Inverted of the Original Tissue Section

Objects Found:668

Page 22: Cell calculation

Counting the Number of Cells

Threshold Image-Color Inverted of the Repaired Tissue Section

Objects Found:1667

Page 23: Cell calculation

Conclusion

Algorithm successfully thresholds and counts cells from a digitized microscopy slide, thus able to show that repaired tissue sections show more cells than original tissue sections

Future work Approximation of the cell count percent error

Automation for calculating the threshold parameter

(i.e Global thresholding)

Applying different thresholding algorithms

(i.e. Otsu’s method)

Page 24: Cell calculation

References

Gonzalez, R.C, Woods, R.E., Digital Image Procesing, 3rd Edition, Pearson Prentice Hall, 2008.

Images obtained from bioinstrumentation lab UC