MATLAB: How to calculate the distance between matching points of two different images

distancedotsImage Processing Toolboximages

Hello,
I'm having trouble to find an easy and automatic way to calculate the distance between possibly matching points in two different images.
I had an original BW image and its corresponding binary matrix. I applied an affine transformation (a shear) to the image, to get two new images: one shifted to the left and the other one to the right. Now the image matrices are no longer binary as I have values ranging from 0 to 1 due to the transformation. I'd like to calculate the distance between the possible matching points in the two images, that is the points that have approximately the same location in both images, and not only the two points that corresponded to one point in the original image (before the transformation). To do so, I thought I first had to get the centre of each "dot" in both images and then do something to calculate the distance between several points. I tried the centroid method of the regionprops function and the imfindcircles but as the dots are not really circular and can overlap, both methods are far from giving me the centres of the dots. So i'm currently stuck here, and don't manage to think of another way to do it! It'd be very nice if someone had any idea about how to handle this problem!!
Some of the code I use to create the new images (left/right):
for frame_ndx = 1 : length(frame_cond) frame_ndx se = strel('disk',4);
x = linspace(-1,1,sz);
[X,Y] = meshgrid(x,x);
[T,R] = cart2pol(X,Y);
threeshold = 1 - (Dot_nb / sz^2);
Rd = double(rand(sz,sz)>threeshold);
Rd(R>0.95 | R<0.06)=0;
Rd = imdilate(Rd,se);
if (frame_cond(frame_ndx) == 1) % creates a decorrelated pattern for the right image

Rd_decor = double(rand(sz,sz)>threeshold);
Rd_decor(R>0.95 | R<0.06)=0;
Rd_decor = imdilate(Rd_decor,se);
end
slant_coeff = 0.0361; % this value gives a Shear angle of 4.13°
if (frame_cond(frame_ndx) == 2)
tform_l = maketform('affine',[1 0 0; slant_coeff 1 0; 0 0 1]);
tform_r = maketform('affine',[1 0 0; -slant_coeff 1 0; 0 0 1]);
else
tform_l = maketform('affine',[1 0 0; -slant_coeff 1 0; 0 0 1]);
tform_r = maketform('affine',[1 0 0; slant_coeff 1 0; 0 0 1]);
end
Rd_l = imtransform(Rd,tform_l,'size',size(Rd),'FillValues',0);
Rd_r = imtransform(Rd,tform_r,'size',size(Rd),'FillValues',0);
if (frame_cond(frame_ndx) == 1) % creates a decorrelated pattern for the right image
Rd_r = imtransform(Rd_decor,tform_r,'size',size(Rd_decor),'FillValues',0);
end

Best Answer

Presumably the affine shear just made it so the two images are aligned and they are still both of the same size and have the same coordinate system. So you did not enlarge the canvas of one when you sheared it. So just get the coordinates of the two points and use the Pythagorean theorem. What's the difficulty? Perhaps we'd know if you attached your images. I'm guessing that you'd just find the point in each image and compute the Euclidean distance. Is that wrong?