# How can I segment depth images

1 view (last 30 days)
Zara Khan on 12 Oct 2021
Commented: Zara Khan on 14 Oct 2021
I have read depth imges and converted them into grayscale. Now how to segment the hand region properly.

yanqi liu on 12 Oct 2021
clc; clear all; close all;
bw = imclose(bw, strel('line', 5, 0));
bw = imclearborder(bw);
bw = bwareafilt(bw, 1);
bw = imclose(bw, strel('line', 25, 0));
bw = imfill(bw, 'holes');
bw = imopen(bw, strel('line', 15, 0));
bw = bwareafilt(bw, 1);
[r,c] = find(bw);
rect = [min(c) min(r) max(c)-min(c) max(r)-min(r)];
figure; imshow(img);
hold on; rectangle('position', rect, 'EdgeColor', 'g', 'LineWidth', 2)
yanqi liu on 14 Oct 2021
clc; clear all; close all;
bw = imclose(bw, strel('line', 5, 0));
bw = imclearborder(bw);
bw = bwareafilt(bw, 1);
bw = imclose(bw, strel('line', 25, 0));
bw = imfill(bw, 'holes');
bw = imopen(bw, strel('line', 15, 0));
bw = bwareafilt(bw, 1);
[r,c] = find(bw);
rect = [min(c) min(r) max(c)-min(c) max(r)-min(r)];
figure; imshow(img);
hold on; rectangle('position', rect, 'EdgeColor', 'g', 'LineWidth', 2)
figure; imshow(bw)
img1 = img; img2 = img; img3 = img;
img1(~bw) = 0; img2(~bw) = 0; img3(~bw) = 0;
imgr = cat(3, img1, img2, img3);
figure; imshow(imgr);
Zara Khan on 14 Oct 2021
Mask is not working well. Still have some background portion. Any other idea?