This project focuses on detecting and correcting spatial shifts between two images using image correlation techniques. By using Fast Fourier Transform (FFT)-based cross-correlation, the project identifies translational misalignments, estimates the shift, and applies correction to restore alignment. Such methods are valuable in fields like computer vision, remote sensing, and medical imaging, where precise image registration is essential.
- To implement an FFT-based image correlation algorithm for detecting translational shifts.
- To evaluate the accuracy of shift detection using synthetic test images.
- To correct detected shifts and validate alignment through visual overlays and error maps.
- To demonstrate the potential application of image correlation in real-world alignment tasks.
- Data Preparation: Generated synthetic test images with controlled shifts (e.g., shifting a rectangle by 15 pixels horizontally and 25 pixels vertically).
- Image Correlation using FFT:
-
- Converted images to grayscale and float32 format.
- Applied 2D FFT to both images.
- Computed the normalized cross-power spectrum and applied inverse FFT to obtain the correlation surface.
- Detected the peak in the correlation map to estimate the translational shift.
- Shift Correction: Applied an affine transformation (warpAffine) to realign the shifted image.
- Validation & Visualization:
-
- Created overlays (red = original, green = corrected) to visually inspect alignment.
- Computed difference/error maps to quantify residual misalignment.
- Visualized results using Matplotlib plots.
- FFT-based correlation effectively estimates translational shifts between images.
- Synthetic testing confirmed accurate recovery of known shifts (e.g., 15 pixels right, 25 pixels down).
- Overlay visualization highlights alignment improvements after correction.
- Error maps serve as an effective diagnostic tool for assessing correction accuracy.
- The approach is computationally efficient and generalizable to real-world image registration problems.
- Programming Language: Python
- Libraries: OpenCV (cv2) (for Image manipulation and affine transformations), NumPy (FFT operations and numerical computations), Matplotlib (Visualization of images, overlays, and error maps)