필터 지우기
필터 지우기

How to calculate the area of this object in an image?

조회 수: 9 (최근 30일)
Muhammad Fiky
Muhammad Fiky 2023년 12월 11일
댓글: Image Analyst 2023년 12월 11일
  댓글 수: 2
Walter Roberson
Walter Roberson 2023년 12월 11일
Is the "object" everything that is black?
Is the "object" everything that is 8-connected to the largest black area -- so excluding the small stand-alone black areas?
Is the "object" the white area inside the black area?
Muhammad Fiky
Muhammad Fiky 2023년 12월 11일
the "object" is only the black-colored area surrounding the white circle. This means the "object" does not include the white circle area inside.

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 12월 11일
"area" could potentially refer to a physical quantity rather than just a pixel count.
In order to calculate as a physical quantity, either you have to have existing information about the physical sizes of the pixels, or else you need to have some reference information in the image that you can relate to physical quantities as a calibration. For example if there were a ruler in the image that was known to span 1 mm then the size of the ruler could be determined and knowing the associated physical size, the physical dimensions of the represented object could be calculated.
filename = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1565304/image.jpeg";
img = imread(filename);
bw = im2bw(img);
object_pixels_count = nnz(~bw)
object_pixels_count = 142307
%for the purposes of illustration, we will not assume that individual
%pixels are square, and we will assume that **somehow** you know the actual
%physical size of each pixel
pixel_height = 2.54/80;
pixel_width = pixel_height * 4/3;
%then
object_area = object_pixels_count * pixel_height * pixel_width
object_area = 191.2725
  댓글 수: 4
Muhammad Fiky
Muhammad Fiky 2023년 12월 11일
i use this code to obtain the number of pixels in a unit length.
d=imdistline;
the result is that line on the bottom left, showing 105.96 amount of pixels at 0.2 mm (actual length). With this in mind, and believing that my pixels are square-shaped, what are the changes on the MATLAB code above (pixel height and pixel width)?
The following is the actual picture taken from a digital microscope. I went to some lengths to transform the actual picture into black and white using Corel.
Image Analyst
Image Analyst 2023년 12월 11일
See my attached spatial calibration demo to convert pixels into mm.

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

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by