Reputation: 671
I recorded a sequence of depth images using Kinect v2. But the background brightness is not constant. But It keeps changing from dark to light and light to dark (i.e) .
So I was thinking to use Histogram normalization of each image in a sequence to normalise the background to the same level. Can anyone please tell me how I can do this?
Upvotes: 0
Views: 716
Reputation: 2469
Matlab has a function for histogram matching and their site has some great examples too
Just use any frame as the reference (I suggest using the first one, but there is no real reason to do so), and keep it for all the remaining frames. If you want to decrease processing time you can also try lowering the number of bins. For a uint8
image there are usually 256 bins, but as you'll see in the link reducing it still produces favorable results
I don't know if kinect images are rgb or grayscale, for this example Im assuming they are grayscale
kinect_images = Depth;
num_frames = size(kinect_images,3); %maybe 4, I don't know if kinect images
%are grayscale(3) or RGB(4)
num_of_bins = 32;
%imhistmatch is a recent addition to matlab, use this variable to
%indicate whether or not you have it
I_have_imhistmatch = true;
%output variable
equalized_images = cast(zeros(size(kinect_images)),class(kinect_images));
%stores first frame as reference
ref_image = kinect_images(:,:,1); %if rgb you may need (:,:,:,1)
ref_hist = imhist(ref_image);
%goes through every frame and matches the histof
for ii=1:1:num_frames
if (I_have_imhistmatch)
%use this with newer versions of matlab
equalized_images(:,:,ii) = imhistmatch(kinect_images(:,:,ii), ref_image, num_of_bins);
else
%use this line with older versions that dont have imhistmatch
equalized_images(:,:,ii) = histeq(kinect_images(:,:,ii), ref_hist);
end
end
implay(equalized_images)
Upvotes: 1