python - 区分规则和不规则形状的 Blob

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

我有一组相连的 Blob ,我想区分图中更规则的(acd )来自更不规则的,例如 b

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

enter image description here

最佳答案

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

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

链接 - /image/uPpUU.jpg

关于python - 区分规则和不规则形状的 Blob ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25608619/

相关文章:

python - 将图像从 float64 转换为 uint8 使图像看起来更暗

c# - C#检测黑白图像中的多边形点

php - 性能改进 PHP GD 调整大小和修剪图像背景以保持正确的比例

string - 输入必须是字符串 MATLAB 使用 cellstr(sentiment) 时出现错误

python - 将 HTTPResponse 对象转换为字典

python - 以通用方式从 scipy.stats 获取 pdf

python - python 2 函数在没有任何导入的情况下运行所需的时间;是否可以?

MATLAB 按自定义条件排序

matlab - 在 Simulink 中为步行机器人的地板/地面建模

python - 如何在 CentOS8 上安装 Ansible