How to find the Area for irregular shape in particular region of image?
조회 수: 20 (최근 30일)
이전 댓글 표시
I Need to find the area of the water body in this image
댓글 수: 1
DGM
2023년 2월 20일
If you want to save images without losing information, save them using imwrite(), not by creating screenshots or by saving the figure (which is essentially a screenshot).
답변 (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!