![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176561/image.png)
How to find regions of any image using active contour
1 view (last 30 days)
Show older comments
komal kella
on 28 May 2017
Edited: MathReallyWorks
on 28 May 2017
I = imread('toyobjects.png'); imshow(I) hold on title('Original Image'); mask = false(size(I)); mask(50:150,40:170) = true; contour(mask,'Color','b'); w = activecontour(I, mask, 200, 'edge'); contour(bw,'Color','r'); title('Initial contour (blue) and final contour (red)');
0 Comments
Accepted Answer
MathReallyWorks
on 28 May 2017
Edited: MathReallyWorks
on 28 May 2017
Hello Komal,
Please make your code readable. And you forgot to attach your image as well.
For detecting regions in an image, you can use this method as well:
clc;
close all;
grayImage = imread('random.png');
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
grayImage = grayImage(:, :, 2);
end
subplot(2, 1, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
binaryImage = grayImage > 128;
binaryImage = imclearborder(binaryImage);
binaryImage = bwareaopen(binaryImage, 1000);
subplot(2, 1, 2);
imshow(binaryImage, []);
title('Binary Image');
It works pretty well and is able to detect all type of regions.
I have attached my image as well. Use that for proper understanding.
Result:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176561/image.png)
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!