How to calculate the area of an input image?

조회 수: 12 (최근 30일)
Elias Unk
Elias Unk 2017년 8월 14일
댓글: Image Analyst 2019년 8월 15일
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

채택된 답변

Star Strider
Star Strider 2017년 8월 14일
편집: Star Strider 2017년 8월 14일
If it is a binary image (so a 2D array), the numel (link) function will do what you want.
It is equivalent to prod(size(BI)), where ‘BI’ is your binary image.

추가 답변 (2개)

Image Analyst
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
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
Image Analyst 2019년 8월 15일
No, you can find the area directly. See my attached spatial calibration demo.

댓글을 달려면 로그인하십시오.


Jan
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?
  댓글 수: 1
Elias Unk
Elias Unk 2017년 8월 14일
Yes that partially did it now i need to multiply it's 2 elements how do i get it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by