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 Ansichten (letzte 30 Tage)
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

Antworten (1)

Sayan Saha
Sayan Saha am 7 Mai 2018
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:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by