Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 区分规则形状的水滴和不规则形状的水滴_Python_Matlab_Image Processing_Language Agnostic_Computer Vision - Fatal编程技术网

Python 区分规则形状的水滴和不规则形状的水滴

Python 区分规则形状的水滴和不规则形状的水滴,python,matlab,image-processing,language-agnostic,computer-vision,Python,Matlab,Image Processing,Language Agnostic,Computer Vision,我有一组连接的blob,我想区分更规则的(a,c和d,在图中)和更不规则的blob,如b 我尝试使用卷积区域(在blob_区域/卷积的blob_区域上设置一个阈值),但它们都不能很好地区分d和香蕉形状。您建议使用哪些参数?谢谢 我想到的一个想法是,可以使用每个水滴大小的角数来确定规则性/不规则性。测试结果似乎也符合我们的假设。这是密码- im = imread(input_image_path); bw= im2bw(im); %// Parameter for cutting into fo

我有一组连接的blob,我想区分更规则的(
a
c
d
,在图中)和更不规则的blob,如
b

我尝试使用卷积区域(在blob_区域/卷积的blob_区域上设置一个阈值),但它们都不能很好地区分
d
和香蕉形状。您建议使用哪些参数?谢谢


我想到的一个想法是,可以使用
每个
水滴大小的
角数
来确定
规则性/不规则性
。测试结果似乎也符合我们的假设。这是密码-

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的输入图像-


Link-

一个快速而肮脏的可能解决方案:计算周长/面积,并设置一个阈值。@albus_c我确实考虑过,但那样的话,你会把像香蕉和直细棒这样的细长物体视为不规则的物体,我想你不想要它,是吗?我同意你的看法。我认为计算角点作为一种解决方案要好得多!