Find the percentage of area occupied by an object
Show older comments
From the below image, how can I find - what percentage of the yellow region does the total pink region occupy?

1 Comment
Accepted Answer
More Answers (1)
Adam Danz
on 28 Dec 2022
1 vote
Assuming that this is an image and that the pink color is a single RGB color value, you could compute the number of pixels with that pink color and the size of the yellow rectangle to compute the percent area of the pink within the yellow.
percentArea = pinkPixelCount / yellowPixelCount * 100;
where yellowPixelCount is the height*width of the yellow rectangle. Compute the pinkPixelCount from the image data. If you need guidance with that, please provide more info about your image or upload a mat file containing your image data.
Categories
Find more on Red 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!