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