Why I get a warning while using active contour in MATLAB?
Warning: Iterations terminated prematurely because no part of the contour lies within the image domain. If the range of pixel values in the input image is small (such as 0-1)

8 件のコメント

Adam Danz
Adam Danz 2020 年 12 月 31 日
The warning tells you why it's appearing. We cannot explain why this is happening without more info such as the image, inputs to activecontour, etc.
Tamoor Aziz
Tamoor Aziz 2021 年 1 月 1 日
Thank you so much for your answer. I am using the following code,
{
mask = logical(Image);
bw = activecontour(Image,mask,500,'Edge','SmoothFactor',1.5);
}
The contour method cannot converge towards the edge of the dark object beacuse of premature termination of the iterations.
Adam Danz
Adam Danz 2021 年 1 月 1 日
What is "Image"? I see that there's an attachment named Image.png and I assume the variable Image stores the image data of that file but how are you reading it in?
Since you're applying logical() I assume the image data are binary.
Tamoor Aziz
Tamoor Aziz 2021 年 1 月 2 日
Thank you so much for your prompt reply and apology for my mistake.
The mask is the bounding box of the dark object and is logical. I want to segment the dark object using active contour segmentation. It works, but due to premature termination of iteration, it can't converge to the object exactly.
mask = logical(BoundingBox);
bw = activecontour(Image,mask,500,'Edge','SmoothFactor',1.5);
Image Analyst
Image Analyst 2021 年 1 月 2 日
Exactly? Do you mean that there is an exact solution? Where exactly is the border of that blurry smooth shape? Can you indicate it in a red curve? It looks like a judgment call to me. What about simply thresholding and calling bwboundary()?
boundary = bwboundaries(grayImage < someGrayLevel);
Adam Danz
Adam Danz 2021 年 1 月 2 日
Now I have the same question for "BoundingBox". What is it? I understand it was created using mask.png and that it's probably a binary matrix but we can't be sure without having the line of code you used to read in that file and create 'BoundingBox'.
Image Analyst
Image Analyst 2021 年 1 月 2 日
The mask is some initial shape for the activecontour() function. See my attached demo.
Adam Danz
Adam Danz 2021 年 1 月 2 日
You've always got great demos, Image Analyst.
I'd like the OP to share how BoundinBox was created to eliminate that step as a possible cause of the problem and to ensure that we're identically replicating the problem. That would only be 2-3 lines from your demo,
grayImage = imread(fullFileName);
mask = grayImage > thresholdValue;
And for the composite mask,
mask = bwconvhull(mask, 'Union');

サインインしてコメントする。

 採用された回答

Tamoor Aziz
Tamoor Aziz 2021 年 1 月 3 日
編集済み: Tamoor Aziz 2021 年 1 月 3 日

0 投票

@Image Analyst, thank you so much for your reply. Exactly, My problem is the same as you described in https://www.mathworks.com/matlabcentral/answers/705903-active-contour-run-time-warning#comment_1240593.
According to my understanding, if you increase the number of iteration then you will get the accurate final outer boundary of the object in the "Original Grayscale Image".
But, I don't have problem about the contour segmentation. Please help me with my problem. If I use 400 number of iterations, the contour segmentation process stops before than 400 iterations and it generates the warning! Why I get a warning while using active contour in MATLAB?
Warning: Iterations terminated prematurely because no part of the contour lies within the image domain. If the range of pixel values in the input image is small (such as 0-1)

その他の回答 (0 件)

質問済み:

2020 年 12 月 31 日

編集済み:

2021 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by