MATLAB: Count and measure yeast cells from an image

edge detectionimage analysisimage processingImage Processing Toolboximage segmentation

Hello. I am trying to detect, count and measure yeast cells from various images like in this example,
First I made the background uniform using a morphological opening, followed by an increase of the contrast using "imadjust". Then, I found the edges of the image using the 'canny' function to create a mask that overlays on the adjusted image to remove all the background and some of the cells glow. Next, I turned the pixels below 50 into black and converted the image into a binary one. Finally, I cleaned the image and used the “watershed” transformation to separate the connected cells.
Here’s my code:
clear all
close all
se1=strel('disk',2);
X=imread('t132-1.png');
I=X(:,:,2);
figure
imshow(I)
title('original')
drawnow
%%background removal
background = imopen(I,strel('disk',15));
I2=I-background;
I3 = imadjust(I2);
% figure




% imshow(I3);
% title('Adjusted image')
% drawnow





%%edge detection
Iedge=edge(I3,'canny',0.3);
Iedge=bwmorph(Iedge,'dilate');
Iedge=bwmorph(Iedge,'bridge');
Iedge=imfill(Iedge,'holes');
% figure
% imshow(Iedge)
% title('edge')
% drawnow
Iclean=bwmorph(Iedge,'erode',2);
Iclean=bwareaopen(Iclean,500);
% figure
% imshow(Iclean);
% drawnow
%%Image masking
Icut=255-I3;
Icut(Iclean==0)=0;
figure;
imshow(Icut);
title('cut')
drawnow
Iadjust=Icut;
Iadjust(Iadjust<50)=0;
% figure
% imshow(Iadjust);
% title('black pixels below 50');
% drawnow
Ibw=im2bw(Iadjust,0.1);
% figure
% imshow(Ibw);
% title('BW');
% drawnow
Ibw=imerode(Ibw,se1);
Ibw=imdilate(Ibw,se1);
Iclean2=bwareaopen(Ibw,150);
% figure
% imshow(Iclean2);
% title('clean')
% drawnow
%%watershed function
D=-bwdist(~Iclean2);
mask=imextendedmin(D,7);
D2=imimposemin(D,mask);
Ld2=watershed(D2);
bw3=Iclean2;
bw3(Ld2==0)=0;
figure
imshow(bw3)
title('Final')
drawnow
I plan to make the measurements using the “regionprops” command. My problem is that the resulting image (shown below) lost many of the cells forms and have outter holes that difficult the measuring process. I’m wondering if you have any suggestion for a better general detection process that I could apply on all my 36 images, thanks in advance!

Best Answer

Maybe try either imfill() or bwconvhull().