You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How can I best segment yeast cells in this picture?
5 views (last 30 days)
Show older comments
Hi,
I have tried some of the algorithms I found online without much success.I am wondering what is the best approach to segment cells automatically in this picture.
Any help in terms of how to approach this problem will be greatly appreciated. Please help!
Accepted Answer
Image Analyst
on 26 Jun 2015
Steve's blog on marker controlled watershed segmentation might help you: http://www.mathworks.com/help/images/examples/marker-controlled-watershed-segmentation.html
13 Comments
Tianyu Yang
on 1 Jul 2015
Thank you for your reply.
I have tried to utilize this algorithm, and I encountered some problem. The gradient graph is pretty promising(image attached).
The problem was, the yeast cells in my datasets aren't necessarily brighter than the background. This brings problem to both foreground and background marker generation.
For the foreground, generating use the procedure gave me a very wrong regional maxima. Many yeasts are missed and some background are recognized as foreground. (image attached) I did modify the disc size for morphological opening to incorporate the smaller image size.
For the background the problem is even worse. The first step of generating background markers is generating the bw image from the open-close-by-reconstruction graph using automatic grey value threshold. And in my image, the lightest part of imaging is the rim of cell wall (see the original imaging). Also some of the background is actually very light. The result is nothing close to what we want (image attached).
I feel like this is the right way to go, but I probably need some other way to find the markers. Is that possible you tell me what you think on this? Thank you for your help!
Image Analyst
on 1 Jul 2015
Well I only had about 10 minutes so this is about as far as I got.
% Demo to find cells.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
% Read in a standard MATLAB gray scale demo image.
folder = pwd;
baseFileName = 'sample.png';
%===============================================================================
% Read in a demo image.
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
% Make sure it's gray scale.
if numberOfColorBands > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the original gray scale image.
subplot(2, 3, 1);
imshow(grayImage, []);
axis on;
title('Original Grayscale Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
subplot(2, 3, 2);
bar(grayLevels, pixelCount); % Plot it as a bar chart.
grid on;
title('Histogram of original image', 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
sdImage = stdfilt(grayImage, ones(9));
% Display the image.
subplot(2, 3, 3);
imshow(sdImage, []);
axis on;
title('Std DevImage', 'FontSize', fontSize, 'Interpreter', 'None');
% Let's compute and display the histogram.
[pixelCount, grayLevels] = histcounts(sdImage(:));
subplot(2, 3, 4);
bar(pixelCount); % Plot it as a bar chart.
grid on;
title('Histogram of StDev image', 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Threshold.
binaryImage = sdImage < 7;
% Get rid of background
binaryImage = imclearborder(binaryImage);
% Fill Holes
binaryImage = imfill(binaryImage, 'holes');
% Display the image.
subplot(2, 3, 5);
imshow(binaryImage, []);
axis on;
title('Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Compute Euclidean distance transform.
edtImage = bwdist(~binaryImage);
% Display the image.
subplot(2, 3, 6);
imshow(edtImage, []);
axis on;
title('Distance Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Compute the watershed.
edtImage = -edtImage;
edtImage(~binaryImage) = -Inf;
wsImage = watershed(edtImage, 8);
% Display the image.
subplot(2, 3, 6);
imshow(wsImage, []);
axis on;
title('Watershed Image', 'FontSize', fontSize, 'Interpreter', 'None');
Tianyu Yang
on 7 Jul 2015
Hi,
Thank you very much for your help. This algorithm works for many cases. But now I understand why the original post talk about generating front markers.
This algorithm deal with background quite well. But when the cell is not a good "circle", there will be multiple local minimums in the distance map generated from the graph. There is one of the example.
Original Image and the bw image generated from stdfilt and thresholding. I write some code to recover those cells on the border that get cleared by imclearborder :
The local minimum in the distance map and the result watershed:
Do you have any idea how I can fix this problem?
My idea is, for local minimums, draw a path between them and process the value the path cross. If the pixel value on the path has a small std value, it is probably in the same cell and I get rid of one. Even with that I need to figure somehow to smooth the distance map. Otherwise get rid one local minimum, some other point in the same basin will just pop up as the new local minimum
Image Analyst
on 7 Jul 2015
Do you just want to keep partial cells touching the border? Why? They're partial. So any measurements on them will not be accurate.
Tianyu Yang
on 7 Jul 2015
Oh, sorry I didn't mention that. The measurement is not the purpose. The purpose is rather count the number of the cells and get an approximate location of their centers.
But that is not the problem though. Even those cells not on the border can have multiple local minimums within them.
Tianyu Yang
on 7 Jul 2015
I also tried to use morphological close to smooth the bw image. But that didn't work too well. I think the shape of the cell is more dominate on this problem.
Tianyu Yang
on 8 Jul 2015
Let me try to re-elaborate that. The problem I have hard time solving is, there will be multiple local minimum in one cells from the generated distance map, and it seems to be caused by in-regular cellular ( or the bw image component) shape. Multiple local minimums will eventually cause the cell be over segmented by the watershed algorithm. (See the attached pictures from previous comment)
I wish to figure out a way to avoid the over segmentation. I have some ideas, for example for every adjacent watershed region, calculate the sum of pixel value along their ridge. And merge two region if the sum is higher than certain value. But they seem to be hard to implement. Do you know if there is any easier algorithm that can solve this problem?
The most interested data for me is "how many cells are in this frame". That is why I preserved the border cells.
Tianyu Yang
on 8 Jul 2015
activecontour() will diminish the advantage of watershed though. Some dumbbell shaped cells that contact each other will be recognize as one cell if I try to use activecontour.
Image Analyst
on 8 Jul 2015
Try published methods:
Cho, S.B.[Sung-Bae], Yoo, S.H.[Si-Ho],
Fuzzy Bayesian validation for cluster analysis of yeast cell-cycle data,
PR(39), No. 12, December 2006, pp. 2405-2414.
WWW Link. 0609
Fuzzy clustering; Fuzzy c-means algorithm; Fuzzy Bayesian validation method; Yeast cell-cycle data BibRef
Jafari-Khouzani, K., Soltanian-Zadeh, H., Fotouhi, F., Parrish, J.R., Finley, Jr., R.L.,
Automated Segmentation and Classification of High Throughput Yeast Assay Spots,
MedImg(26), No. 10, October 2007, pp. 1401-1411.
IEEE DOI 0711
Fachada, N.[Nuno], Figueiredo, M.A.T.[Mário A.T.], Lopes, V.V.[Vitor V.], Martins, R.C.[Rui C.], Rosa, A.C.[Agostinho C.],
Spectrometric differentiation of yeast strains using minimum volume increase and minimum direction change clustering criteria,
PRL(45), No. 1, 2014, pp. 55-61.
Elsevier DOI 1407
Liu, J.S.[Jin-Shuo], van der Putten, P.[Peter], Hagen, F.[Ferry], Chen, X.[Xinmeng], Boekhout, T.[Teun],
Detecting Virulent Cells of Cryptococcus Neoformans Yeast: Clustering Experiments,
ICPR06(I: 1112-1115).
IEEE DOI 0609
Tianyu Yang
on 9 Jul 2015
Some of the papers are not describing same problem. But anyway, thank you very much for your help. I can't make it this far without your initial help.
Image Analyst
on 9 Jul 2015
Here's a page showing tricks to improve watershed segmentation. http://cmm.ensmp.fr/~beucher/wtshed.html
And a blog post by the leader of the imaging team at the Mathworks for how to reduce oversegmentation: http://blogs.mathworks.com/steve/2013/11/19/watershed-transform-question-from-tech-support/ I think this will help you.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)