0

In Matlab, I have two similar images, but one has a pixels shift compare to the other. how can I calculate the the offset (amount of pixels) for axis x and y?

Image Center

Image Shift

bla
  • 25,846
  • 10
  • 70
  • 101
Nir
  • 1

1 Answers1

0

The general problem is called image registration. You can use cross-correlation to find the subpixel image registration, for example by the function dftregistration on the file exchange.

To register the two images A and B within 0.1 pixels by specifying an upsampling parameter of 10

A=(imread("img1.png"));
B=(imread("img2.png"));

upsamplingfactor = 10;
output  = dftregistration(fft2(A),fft2(B),upsamplingfactor );
disp(output),

0.2584    0.0000   75.5000  -85.5000

We get an image shifted by y=75.5 and x=-85.5 pixels with an uncertainty of 0.258 pixels. This can get more accurate if you process the image before to reduce noise via applying a threshold or blurring)

bla
  • 25,846
  • 10
  • 70
  • 101