I have 2 depth images where the a rectangular shaped object is present. I’d like to extract the rectangular object from the images. I have attached here the original depth images and below I show the converted 8 bit image for the purpose of visualization.
Image-1:
Image-2:
I think I have to use binary image and then use bounding box to extract the object. However, I can’t figure out how exactly I should proceed with the coding.
It would be great to have any suggestions.

 채택된 답변

Image Analyst
Image Analyst 2018년 8월 9일

0 개 추천

You can simply threshold at whatever depths you believe the object to be at, then call regionprops():
binaryImage = depthImage > depth1 & depthImage < depth2;
binaryImage = bwareafilt(binaryImage, 1); % Extract largest blob only.
props = regionprops(binaryImage, 'BoundingBox');
boundingBox = props.BoundingBox

댓글 수: 4

Tariqul
Tariqul 2018년 8월 9일
Thanks a lot! It works nicely.
Umara Zafar
Umara Zafar 2018년 11월 13일
what is depth 1 and depth 2 here?
Image Analyst
Image Analyst 2018년 11월 13일
It's whatever you want them to be. Like if you want depths or distances between 160 and 170 cm, then they'd be 160 and 170. To get surfaces at a certain depth/distance you must know what depths/distances you're interested in of course. Otherwise you have the entire image with all depths.
That code should work to read whatever variables were in 'depth.mat' into a structure called depthImage. It's not an image but a structure. Leave the semicolon off to see what variables are in it. Maybe the variable was called depthImage, so you'd do:
storedStructure = load('depth.mat')
depthImage = storedStructure.depthImage;

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

추가 답변 (0개)

질문:

2018년 8월 9일

댓글:

2020년 4월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by