How to find the Area for irregular shape in particular region of image?
19 次查看(过去 30 天)
显示 更早的评论
回答(2 个)
Jinal
2023-2-17
Hey Gowtham,
I understand that you wish to find the area of the regions covered by water body in the image you have provided.
You can do this by creating a mask (a b&w image) of the given image such that the regions covered by the water body are the objects in focus i.e. the waterbody covered regions will be white while the rest of the image region will be black.
Once you have the mask in the form of a binary image, the area of the regions covered by the waterbody can be calculated using regionprops function. The code for the same is as follows:
props = regionprops(maskbinaryimage, 'Area');
area = [props.Area];
To create the mask of an image you can use the Graph Cut feature in Image Segmenter. To access the Image Segmenter app you will require the Image Processing Toolbox (can be installed using MATLAB Get Add-Ons feature).
After loading the image in MATLAB Workspace, you will be required to open the Image Segmenter app from the Apps tab, under Image Processing and Computer Vision section. You can also open the app using the command : imageSegmenter(image);
After creating the mask save it by clicking Export. This will create two variables –
- Mask image data as an array
- Mask binary image as a logical array
Pass the binary image (logical array) to regionprops function in order to calculate the required area.
Hope this helps.
Image Analyst
2023-2-17
This looks like a pseudocolored image. Can you attach the original grayscale image(s)?
Then I'd determine the proper threshold using my interactive tool:
If (unfortunately) all you have is the pseudocolored image, I'd use the Color Thresholder on the Apps tab of the tool ribbon to find a mask based on color. Then you can use other functions like bwareafilt(), bwareaopen(), and imfill() to clean up the mask based on the color segmentation alone and get rid of non-water regions that got picked up just because they're the same color.
2 个评论
Image Analyst
2023-2-20
How do you know which pixels are water? Just by intensity? Do you want to say that all pixels darker than some gray level are water?
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!