tse*_*ios 2 matlab image image-processing imagej
我想自动计算这种类型图像中斑点彼此非常接近的斑点数量,以便将许多斑点视为单个斑点:
我想过使用MATLAB的局部最大值函数/算法,imregionalmaxima但这会返回具有最大值的像素数(二进制矩阵中的像素数).我只想测量黑色循环中包含的白点数.
我在这里也找到了这个主题:如何计算此图像中的斑点数量?并使用ImageJ软件.它无法检测到斑点,在我看来它也检测到具有最大值的像素.
另一种计算图像中有多少白点的简单方法是首先将图像转换为黑白图像,删除白色边框,然后计算剩余的图像数量.使用bwlabel并确定第二个输出变量中看到的值.要清除白色边框,请使用imclearborder.顺便说一句,这假设你有图像处理工具箱:
%// Read image directly from StackOverflow
im = im2bw(imread('http://i.stack.imgur.com/9hU5O.png'));
%// Remove white border surrounding image
im = imclearborder(im);
%// Count how many white spots there are
[~,num] = bwlabel(im);
Run Code Online (Sandbox Code Playgroud)
我明白了:
>> num
num =
18
Run Code Online (Sandbox Code Playgroud)
现在,就你的真实例子而言,你有一些嘈杂的像素.有几种方法可以摆脱那些孤立的条纹.对我有用的是使用5 x 5方形结构元素的形态开口.执行此操作后,将删除面积小于5 x 5的任何噪声像素,并留下面积大于5 x 5形状的任何形状.使用的组合imopen,并strel帮助你做到这一点:
%// Read in the new image and convert to black and white
im = im2bw(imread('http://i.stack.imgur.com/HCvAa.png'));
%// Clear the border
im = imclearborder(im);
%// Define the structuring element
se = strel('square', 5);
%// Open the image
out = imopen(im, se);
%// Now count the objects
[~,num] = bwlabel(out);
Run Code Online (Sandbox Code Playgroud)
我明白了:
>> num
num =
18
Run Code Online (Sandbox Code Playgroud)
此外,如果您感到好奇,这就是清理后的图像:
>> imshow(out);
Run Code Online (Sandbox Code Playgroud)
此处理是在您发布的新图像上完成的,您可以看到由于打开操作已删除了嘈杂的白色像素.