Total Length of an image

조회 수: 3 (최근 30일)
SANDRA COSTA
SANDRA COSTA 2020년 2월 27일
댓글: Image Analyst 2020년 2월 28일
Hello,
Is it possible to upload an image to Matlab and calculate the total length and area?
Thank you
  댓글 수: 2
Adam
Adam 2020년 2월 27일
편집: Adam 2020년 2월 27일
How do you define the 'length' of an image? Matlab defines it as the longest dimension of an array. If that is what you want then
doc length
gives you that.
When you load an image you get a 2d array so
doc size
will give you its size. Area is trivially calculated from that if all you mean is how many pixels does it have. If you mean the area of some object in the picture that is a whole different question!
SANDRA COSTA
SANDRA COSTA 2020년 2월 27일
I'm taking pictures of corals so I wanted to see if I could use matlab to measure the total length of the coral in the picture and the area.
The picture has around 5000x3000 pixels.

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

답변 (1개)

Image Analyst
Image Analyst 2020년 2월 27일
You'd have to do image analysis. This includes image segmentation to get a binary map of the coral alone, then you can either take the area fraction, or skeletonize it with bwskel() and then sum the image . But I'm sure the image segmentation is probably the hardest part, but you chose not to share any images so I'm not sure how tough that would be.
  댓글 수: 2
SANDRA COSTA
SANDRA COSTA 2020년 2월 27일
Thank you so much.
I was able to get the threshold, but not sure on how to get the total length and area with this.
I have uploaded the image, this is what I've got so far.
Image Analyst
Image Analyst 2020년 2월 28일
I'm sure by now you've tried what I suggested and have it solved already so go ahead and post your image and code. You probably got something like
binaryImage = imbinarize(grayImage);
area = sum(binaryImage(:))
% If binaryImage doesn't have the object as white on a black background, then do this
% binaryImage = ~imbinarize(grayImage);
skelImage = bwmorph(grayImage, 'skel', inf);
totalLength = sum(skelImage(:))

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by