区分规则和不规则形状的斑点

时间:2014-09-01 15:01:58

标签: python matlab image-processing language-agnostic computer-vision

我有一组连接的blob,我想区分更常规的(acd)和更不规则的blob,例如{ {1}}。

我尝试使用卷积区域(在blob_area / convolved_blob_area上设置一个阈值)shape factor and roundness,但它们都不能很好地区分b和类似香蕉的形状。您建议使用哪些参数?谢谢!

enter image description here

1 个答案:

答案 0 :(得分:1)

我想到的一个想法是,您可以使用number of cornerssize of blob来确定regularity/irregularity。测试结果似乎也符合我们的假设。这是代码 -

im = imread(input_image_path);
bw= im2bw(im);

%// Parameter for cutting into four slices into the third dimsensions 
%// corresponding to the four objects
common_width = 270; 

%// Threshold to decide between regular and irregular ones
factor1_th = 0.01;

bw1 = bw(:,1:common_width*floor(size(bw,2)/common_width)); %// Cropped image
objs =reshape(bw1,size(bw1,1),common_width,[]);%//Objects stored as dim3 slices
for objc=1:size(objs,3) %// Object counter
    disp(['-------------- Processing Obj #' num2str(objc)]);
    obj = objs(:,:,objc);
    corners = corner(obj);
    factor1 = size(corners,1)/nnz(obj)
    if factor1 > factor1_th
        disp('This is an irregular one.'); %//'
    else
        disp('This is a regular one.'); %//'
    end
end

输出 -

-------------- Processing Obj #1
factor1 =
    0.0050
This is a regular one.
-------------- Processing Obj #2
factor1 =
    0.0109
This is an irregular one.
-------------- Processing Obj #3
factor1 =
    0.0052
This is a regular one.
-------------- Processing Obj #4
factor1 =
    0.0078
This is a regular one.

如果有人对运行代码感兴趣,请输入符号a,b,c,d的输入图像 -

enter image description here

链接 - http://i.stack.imgur.com/uPpUU.jpg