MATH590: C2examples, clustering of leukocytes

In this module homework you are invited to explore the use of clustering methods to determine different types of white blood cells

Blood image database

Read data and carry out visual examination of images

Choose directory of images to process

SetDirectory["/home/student/courses/MATH590/SETdata/BloodCells/JPEGImages"]

List the files in the current directory

f=FileNames[]; Nim=Length[f]

Manipulate[Import[f[[i]]],{i,1,Nim,1}]

Here are two typical images that differentiate between WBC and RBC by staining (WBC appear blue), and also show different morphology of WBCs.

{im1=Import[f[[1]]],im2=Import[f[[9]]]}

The image data can be separated into individual color channels, adjusted to cover the entire intensity scale (contrast enhancement)

{imR,imG,imB}=Map[ImageAdjust[#]&,ColorSeparate[im1]]

It can also be reduced to a grayscale image, again adjusted to cover the entire intensity scale

imBW = ImageAdjust[ColorNegate[ColorConvert[im1,"Grayscale"]]]

Isolating leukocytes by Wright-Giemsa staining

The additional information provided by chemical staining and the relative paucity of leukocytes (i.e., WBC are well separated in the blood smear data) allows straightforward identification of white blood cells.

Repeat the isolation of the individual color channels, and adjust for maximum contrast.

{imR1,imG1,imB1}=Map[ImageAdjust[#]&,ColorSeparate[im1]]

The green channel immediately furnishes a mask to eliminate the background fluid

mask1=ColorNegate[Binarize[imG1]]

Eliminate the background from the blue channel data

cellsB1=ImageMultiply[mask1,imB1]

Generate a mask for the leukocytes

Lmask1=FillingTransform[Binarize[cellsB1,0.6]]

Filter out small components from the mask

MaxCells = 100; MinPixels =Floor[Apply[Times,ImageDimensions[Lmask1]]/MaxCells];

FLmask1=Binarize[ColorConvert[Colorize[SelectComponents[Lmask1,#Count>MinPixels&]],"Grayscale"]]

Define the smallest possible image that contains just leukocytes

wbc=ImageCrop[ImageMultiply[FLmask1,im1]]

Encapsulate all these operations into a single function

Leukocytes[im_,t_]:=Module[{imR,imG,imB,mask,MaxCells,MinPixels,cellsB,Lmask,FLmask,wbc},
{imR,imG,imB}=Map[ImageAdjust[#]&,ColorSeparate[im]];
mask=ColorNegate[Binarize[imG]];
MaxCells = 100; MinPixels =Floor[Apply[Times,ImageDimensions[mask]]/MaxCells];
cellsB=ImageMultiply[mask,imB];
Lmask=FillingTransform[Binarize[cellsB,t]];
FLmask=Binarize[ColorConvert[Colorize[SelectComponents[Lmask,#Count>MinPixels&]],"Grayscale"]];
wbc=ImageCrop[ImageMultiply[FLmask,im]];
Return[wbc];
]

Leukocytes[im2,0.6]

Manipulate[Leukocytes[Import[f[[k]]],t],{k,1,Length[f],1},{{t,0.6},0.5,0.7}]

Homework questions

Question 1

Carefully read through the image processing carried out to remove Wright-Giemsa staining in C2examples.pdf. Identify at least five steps in which a clustering (i.e., set partitioning) technique was used. Refer to the step by the In[#] label, and comment on the type of clustering you think is being applied.

Question 2

Again with reference to the removal of Wright-Giemsa staining in C2examples.pdf, identify at least three steps in which the concepts of real analysis (perhaps in discretized form) are being used.

Question 3

Randomly choose 100 images. Isolate the leukocytes and find their size (binarize the image and count the number of ones). Identify clusters of leukocyte sizes.

Question 4

For the chosen 100 images, apply the GradientFilter operation to isolate the perimeter, and measure the perimeter by counting the number of edge pixels. Identify clusters of leukocytes by perimeter size.

Question 5

Finally define the circularity as the ratio of the equivalent disk perimeter to the measured perimeter. Identify clusters of leukocytes by circularity.