我有一堆皮氏培养皿充满了点,我想在 Matlab 中计数。
例如,该板有 352 个菌落
我试过 ImageJ,但需要做相当多的裁剪出边界,并获得可变的结果。
你有什么建议吗?
我对这个问题的方法如下:
使用 Hough 变换识别与培养皿相对应的圆。
使用 Otsu 的方法进行全局阈值处理,仅限于菜肴。
将菌落计数为原始图像的区域最大值,这些最大值在分割图像中表示。
这个file exchange toolbox为我们提供了一个工作循环霍夫变换。
function [count,colonies,bw] = colony_count(I)
I = rgb2gray(im2double(I)); %# Color-to-gray conversion.
[m,n] = size(I);
%# Uncomment this if you have might have some images with light background
%# and dark colonies. It will invert any that seem that way.
%#if graythresh(I) < 0.5
%# I = imcomplement(I);
%#end
bw = I > graythresh(I); %# Otsu's method.
radii = 115:1:130; %# Approx. size of plate, narrower range = faster.
h = circle_hough(bw,radii,'same','normalise'); %# Circular HT.
peaks = circle_houghpeaks(h, radii, 'npeaks', 10); %# Pick top 10 circles.
roi = true(m,n);
for peak = peaks
[x, y] = circlepoints(peak(3)); %# Points on the circle of this radius.
x = x + peak(1); %# Translate the circle appropriately.
y = y + peak(2);
roi = roi & poly2mask(x,y,m,n); %# Cumulative union of all circles.
end
%# Restrict segmentation to dish. The erosion is to make sure no dish pixels
%# are included in the segmentation.
bw = bw & bwmorph(roi,'erode');
%# Colonies are merged in the segmented image. Observing that colonies are
%# quite bright, we can find a single point per colony by as the regional
%# maxima (the brightest points in the image) which occur in the segmentation.
colonies = imregionalmax(I) & bw;
%# Component labeling with 4-connectivity to avoid merging adjacent colonies.
bwcc = bwconncomp(colonies,4);
count = bwcc.NumObjects;
我们使用这样的代码:
I = imread('http://i.stack.imgur.com/TiLS3.jpg');
[count,colonies,mask] = colony_count(I);
我还上传了colony_count
函数on the file exchange。
您可以检查分割(mask
)和菌落标记(colonies
)以查看错误的位置:
%# Leave out the changes to mask to just see the colony markers.
%# Then you can see why we are getting some false colonies.
R = I; R(mask) = 255; R(colonies) = 0;
G = I; G(mask) = 0; G(colonies) = 255;
B = I; B(mask) = 0; B(colonies) = 0;
RGB = cat(3,R,G,B);
imshow(RGB);
您可以使用一种称为连接组件标签的技术,该技术可以用来区分图像中的不同对象。
首先,您需要通过某种阈值处理使图像二进制化。标记是通过扫描每个像素行两次完成的,一次从左到右,一次从右到左。我们正在寻找对象像素,即值为 1 的像素。
在从左到右的扫描中:对于每个像素p:如果p是对象像素,则从上方或左侧复制标签。如果p是背景像素或p具有标签,则不执行任何操作。
对于从右到左的扫描:对于每个像素p:如果p是对象像素,则从右侧复制标签,否则设置新标签。如果p是背景像素或p有标签,则不执行任何操作。如果存在标签并且p的右侧的像素使 a 不同
例如(来自http://webstaff.itn.liu.se/~bjogu/TNM087-2012/Fo7-2012-AH.pdf的演讲幻灯片):
扫描完整个图像后,合并已记录的所有标签(它们连接到同一对象),然后计算不同标签的数量,您将获得计数。
我会做的是:
将图像转换为binary image,这可以使用一些threshold on the Intensity来完成。注意点更浅,因此在取阈值后可以执行1-binaryImage
。我不知道你为什么说它们是黑色的,但是无论它们是什么颜色,它都是相同的想法。
之后,您可以使用Hough transform并绘制rho and theta
的histogram
在该直方图上,您可能会在 rho = = 半径上取第二个阈值。
Added: Detect circles with various radii in grayscale image via Hough Transform本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(73条)