How to select a random POINT on one image than find its corresponding POINT on the other image using cross correlation?
So basically I have image1, I want to select a point on it (automaticaly) then find its corresponding/similar point on image2.
Thanks,

 Akzeptierte Antwort

Image Analyst
Image Analyst am 8 Mär. 2014

3 Stimmen

You can't do it for a point. Let's say the point in image1 has a value of 100. Well there are lots of points in image2 that might have that value. So you need to look at either the whole image or a window/patch. To look at the whole image and align the two, use imregister(). To look at just a small part of image1 (a template) and find it in image2, use normalized corss correlation, as illustrated in my attached demo.

12 Kommentare

Ramo
Ramo am 8 Mär. 2014
I want to get 4 points if possible, and want them to be as seperated as possible. I have tried something like C_1 = normxcorr2(image1, image2); however C_1 changes size then you cant get the actual points on image1 and 2. even if i use a template It would still change the size of C_1
Image Analyst
Image Analyst am 8 Mär. 2014
Please illustrate with screenshots, diagrams, figures, etc. Because as I see it, to get the 4 points as separated as possible you'd just take the 4 corners of the image.
Ramo
Ramo am 8 Mär. 2014
Ramo
Ramo am 8 Mär. 2014
each image is 1700by2300 and C_1 is 4500, If i take the peak I cant show it on image 1 or 2
Image Analyst
Image Analyst am 8 Mär. 2014
Somehow I managed to do it. Study my code and see how I located the white onion in the original image.
Ramo
Ramo am 8 Mär. 2014
xPeak and yPeak are not the coordinates of the onion on the actual image (peppers.png). Its the point on the NCC output, which is not the same.
Image Analyst
Image Analyst am 8 Mär. 2014
See the code for how I turned the location of the peak location of the correlation image into a location on the original image. You know I did it - you can see it right there . Look how the green box is correctly positioned. It's not an impossible task - I did it.
Ramo
Ramo am 8 Mär. 2014
I have tried doing the same thing, which is basically subtracting the size of the template, but still wouldnt work for my images?
Image Analyst
Image Analyst am 8 Mär. 2014
Do you want me to do anything to help?
Ramo
Ramo am 8 Mär. 2014
Bearbeitet: Ramo am 8 Mär. 2014
I want the point of the bright spot on the NCC graph on the actual image.
imgray = rgb2gray(image);
imgray2 = rgb2gray(image2);
template = imgray(200:600,540:end);
C_1 = normxcorr2(template, imgray);
C_2 = normxcorr2(template, imgray2);
[y1, x1] = find(C_1 == max(abs(C_1(:))));
[y2, x2] = find(C_2 == max(abs(C_2(:))));
so here i took the highest point of C_1 and C_2, but they are not actual points on image1 and image2. i have subtracted the template size but still wont give me the right points?
Image Analyst
Image Analyst am 8 Mär. 2014
When you correlate, the output image is larger. So coordinates are not the same. If you want, you can crop out the central part that is the same size as the large image. If you crop it out correctly (watch out because it may be off a pixel or so depending on exactly where you crop and if the image size is even or odd), then the coordinates should be the same.
Ramo
Ramo am 9 Mär. 2014
Bearbeitet: Ramo am 9 Mär. 2014
the image is 1728by2304, template 1251by955 and C_1 is 2978by3258

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 8 Mär. 2014

Bearbeitet:

am 9 Mär. 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by