Matlab中的分水岭算法 [英] watershed algorithm in matlab

查看:289
本文介绍了Matlab中的分水岭算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何在matlab中编写函数来分割单元格并计算平均值 使用分水岭算法? 任何帮助将非常感激.谢谢!

anyone knows how to write a function in matlab to segment the cells and compute the average cell area using the watershed algorithm? any help would be much appreciated. Thank you!

这是酵母细胞的图像

推荐答案

这是使用分水岭分割图像的一种方法.您还可以做更多的事情(例如,如果细胞尚未完成胞质分裂,则将其与两个细胞核融合),但是以下步骤应该为您提供第一个思路.

Here's one way to segment the image using watershed. There's plenty more you could do (e.g. fuse cells with two nuclei if they haven't completed cytokinesis yet), but the steps below should give you a first idea.

(1)确定细胞本底阈值,细胞核阈值

(1) Determine cell-background threshold, cell-nucleus threshold

%# read image
img = imread('http://i.stack.imgur.com/nFDkX.png');
%# normalize to 0...1
imgN = double(img-min(img(:)))/(max(img(:)-min(img(:))));
th1=graythresh(imgN);
th2 = graythresh(imgN(imgN>th1));

cellMsk = imgN>th1;
nucMsk = imgN>th2;

figure,imshow(cellMsk+nucMsk,[])

(2)平滑原始图像(以避免过度分割),并施加最小的原子核

(2) Smooth the raw image (to avoid oversegmentation) and impose nuclei as minima

[xx,yy]=ndgrid(-5:5,-5:5);
gf = exp((-xx.^2-yy.^2)/20);
filtImg = conv2(imgN,gf,'same');

figure,imshow(filtImg,[])

filtImgM = imimposemin(-filtImg,nucMsk);

(3)分水岭,掩盖单元格并显示

(3) Watershed, mask cells, and display

ws = watershed(filtImgM);
ws(~cellMsk) = 0;

lblImg = bwlabel(ws);

figure,imshow(label2rgb(lblImg,'jet','k','shuffle'));

(4)现在,您可以在 REGIONPROPS 上使用带标签的图像以提取所需的统计信息.

(4) Now you can use REGIONPROPS on the labeled image to extract the statistics you want.

这篇关于Matlab中的分水岭算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆