1
我有一组连接的斑点,我想区分更规则的(a
,c
和d
)与更不规则的区域,如b
。区分正常和不规则形状的斑点
我尝试过使用卷积区域(在blob_area/convolved_blob_area上设置阈值),shape factor and roundness,但没有一个可以很好地区分d
和香蕉形状。你会建议使用哪些参数?谢谢!那我脑子里浮现
我有一组连接的斑点,我想区分更规则的(a
,c
和d
)与更不规则的区域,如b
。区分正常和不规则形状的斑点
我尝试过使用卷积区域(在blob_area/convolved_blob_area上设置阈值),shape factor and roundness,但没有一个可以很好地区分d
和香蕉形状。你会建议使用哪些参数?谢谢!那我脑子里浮现
一个想法是,你可以使用number of corners
每size 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去除的符号输入图像 -
一个快速和肮脏的可能的解决方案:calcu晚'周长/面积',并为此设置了一个门槛。 – 2014-09-01 18:49:50
@albus_c我确实考虑过这个问题,但这样你就会像香蕉那样伸长的物体和被认为是不规则的细棒,我不认为你需要这样或者你会这样吗? – Divakar 2014-09-01 18:52:22
我同意你的意见。我认为数角作为解决方案要好得多! – 2014-09-03 20:49:42