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.

 Respuesta aceptada

Image Analyst
Image Analyst el 9 de Ag. de 2018
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 comentarios

Tariqul
Tariqul el 9 de Ag. de 2018
Thanks a lot! It works nicely.
Umara Zafar
Umara Zafar el 13 de Nov. de 2018
what is depth 1 and depth 2 here?
Image Analyst
Image Analyst el 13 de Nov. de 2018
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;

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 9 de Ag. de 2018

Comentada:

el 9 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by