Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

I want to compare a bunch of depth images coming from Kinect and eliminate the similar ones. Those images present posture of a single user sitting on the chair (depicted in).

enter image description here

My idea is to create a function which will return the difference in range [0,1] between two postures. This means, I want to compare only a posture for given two images (a grey region). For example, if I pass images to my function, the result will be 0 (because postures are the same, but not at the same position on the picture).

Hence, I need to modify the following code (and find something to replace "correlation"):

a = imread('image_user_depth_000041.jpg');  %first img
b = imread('image_user_depth_000042.jpg');  %second img
a = RGB2IND(a,16);
b = RGB2IND(b,16);

c = corr2(a,b);           %finding the correlation 
if c==1
 disp('The images are same') % display
 disp('the images are not same')

Do you have any suggestions? My regards and thanks!

share|improve this question
It would benefit you to look into machine learning, more specifically neural networks. What you are looking at is a classification. 1 if this pattern matches what I am looking for. 0 if this pattern doesn't. Andrew Ng has a free course on it. Google coursera for more detail. –  CyberMen Apr 19 '12 at 19:10
@CyberMen, Machine learning is not the way to go about this kind of problems. You can't built/train an accurate classifier that does that. You will only make things more complicated for no reason. –  Roronoa Zoro Apr 23 '12 at 13:25
Could you post or upload+link the two original images? I'd like to test out some code on them. Thanks! –  Atav32 Jun 28 '12 at 3:46
How did you the get the depth images from Kinect ?? I need it for my project.. please help me out –  user8097 Mar 2 at 9:16

1 Answer 1

You can borrow from techniques used by the image stitching community, where they have to deal with registering translated and rotated images. Your mistake was that you calculated the correlation before finding the optimal translation. The Wikipedia article should give you enough information to help yourself.

Mathematica Example

First, I split the picture above into frame1.png and frame2.png. Then I shifted the second one to align with the first, and trimmed both to retain their intersection. Finally, I compute the correlation coefficient by flattening the matrix into a vector.

img1 = ColorConvert[Import["frame1.png"], "Grayscale"]
img2 = ColorConvert[Import["frame2.png"], "Grayscale"]
im2t = ImageAlign[img1, img2, "Transformation" -> "Translation"]
imgtr = FindGeometricTransform[img1, img2, "Transformation" -> "Translation"]
{trx, try} = Part[TransformationMatrix@Last@imgtr, {1, 2}, 3]
{trim1, trim2} = ImageTake[#, {1, Floor@try}, {1, Floor@trx}] & /@ {img1, im2t}
{cimg1, cimg2} = Flatten@First@ImageData[#, "Interleaving" -> False] & /@ {trim1, trim2};
Correlation[cimg1, cimg2]

The result I got was 0.967834, indicating a close match. If necessary I would have considered scaling and rotation to better align the images but it was not necessary here.

Here is a MATLAB example.

share|improve this answer
"FindGeometricTransform" = wow. Mathematica. You've convinced me to switch –  Atav32 Jun 28 '12 at 3:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.