Extract object from depth image.

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.
Image Analyst
Image Analyst 2020 年 4 月 9 日
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by