How do I extract outer and inner contour in an image? Is there a inbuilt function available or do I have to do it from scratch?
6 次查看(过去 30 天)
显示 更早的评论
I am trying to extract inner contour of an Image. I tried to do this:
>> I3=imread('Image.jpg'); >> I2=bwboundaries(I3);
And I am getting error like this:
Error using bwboundaries Expected input number 1, BW, to be two-dimensional.
Error in bwboundaries>parseInputs (line 187) validateattributes(BW_in, {'numeric','logical'}, {'real','2d','nonsparse'}, ...
Error in bwboundaries (line 140) [BW, conn, findHoles] = parseInputs(args{:});
I tried to even convert the image to binary explicitly and then do it, but still I am getting a different error saying the image size is too large to perform the function.
I am trying to do this command window btw, I don't think that might be one of the problem anyway.
If I have to code it myself, can somebody explain how to do it?
Thanks in advance
0 个评论
回答(1 个)
Sayan Saha
2018-5-7
Here is an example of using "bwboundaries" to find the inner contours of an image based on the example in the documentation:
I = imread('coins.png');
imshow(I);
BW = imbinarize(I);
[B,L] = bwboundaries(BW,'noholes');
figure;
hold on;
for k=1:length(B)
boundary = B{k};
hold on;
plot(boundary(:,2), boundary(:,1));
end
Following MATLAB Answers post might also be relevant:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Filtering and Enhancement 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!