How to calculate the area of an input image?
2 次查看(过去 30 天)
显示 更早的评论
I want to calculate the area of the FULL binary image the user inputs is it as simple as heightXwidth if so what function does it
0 个评论
采纳的回答
Star Strider
2017-8-14
编辑:Star Strider
2017-8-14
It is equivalent to prod(size(BI)), where ‘BI’ is your binary image.
0 个评论
更多回答(2 个)
Image Analyst
2017-8-14
If you want the number of rows and columns of the binary image, you can do this:
[rows, columns] = size(binaryImage);
If you want the number of pixels (sum total, no matter whether black or white), you can do this:
numPixels = row * columns;
or you can use numel():
numPixels = numel(binaryImage);
If you want the area of just the white/1/true pixels, then you can do
foregroundArea = sum(binaryImage(:)); % Result is in pixels.
backgroundArea = numel(binaryImage) - foregroundArea;
Hopefully one of those examples will give you what you want, because we're not 100% sure what you want.
2 个评论
Warid Islam
2019-8-15
Hi Image Analyst,
I want to find the area of an RGB image. I was wondering if i need to convert it to grayscale image and then find the area or I can find the area of the RGB image directly? Thank you.
Image Analyst
2019-8-15
No, you can find the area directly. See my attached spatial calibration demo.
Jan
2017-8-14
This sounds like a job for the size() command. But what does "FULL" mean here and how does the user "inputs" the image?
另请参阅
类别
在 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!