Depth Image background changes

208 Views Asked by At

I am using Kinect v2 to record the sequence of depth images. when i plot the images in MATLAB, then images color is changing a lot. like this images Image1 Imag2

In matlab the variable uint16 type.

My question is why it is changing? and how can i fix it? Here is the code for plotting the images

for i=1:52
    imagesc(Depth(:,:,i));colormap gray; 
    pause(0.1);
end
1

There are 1 best solutions below

5
On

You should not scale the depth images independently of each other, if you want to visualize in a sequence that's visually consistent. All the more so considering that colormap(gray) gives you only 20 different levels.

Try something like:

m = min(Depth(:));
M = max(Depth(:));
scale = 1.0 / (M - m);
colormap(gray(256))
for i=1:52
  d = scale .* (Depth(:,:,i) - m);
  imagesc(d);
  pause(0.1);
end