【发布时间】:2013-11-17 10:50:42
【问题描述】:
我正在尝试使用imfill 在matlab 中填充“手”对象。该对象未在底部连接,因此我画了一条线并将其保存。现在对象已完成,我正在尝试使用imfill( ,'holes'); 填充它,但它不起作用。请有人在这里帮我....
这是图片:
还有我的代码:
I = imread('45Hand.jpg');
im=rgb2gray(I);
[junk threshold] = edge(im, 'sobel');
fudgeFactor = 2;
BWs = edge(im,'sobel', threshold * fudgeFactor);
%figure, imshow(BWs), title('binary');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title('dilated gradient mask');
hold on
p1=[700,100];
p2=[700,1200];
plot([p1(2),p2(2)],[p1(1),p2(1)],'Color','w','LineWidth',4);
f = getframe(gca);
BWsdil = frame2im(f);
imwrite(BWsdil, 'image2.jpg');
img = imread('image2.jpg');
figure, imshow(img);
BWdfill = imfill(img, 'holes');
figure, imshow(BWdfill);
【问题讨论】:
-
更明确地说什么不起作用?简单地说它不是描述性的。