Skip to content

Implemented an FFT-based image correlation algorithm to detect and correct spatial shifts between images, validated with synthetic test data and visual error maps for accurate alignment.

Notifications You must be signed in to change notification settings

taranineelapu/Shift-Detection-using-Image-Correlation

Repository files navigation

Shift Detection using Image Correlation

Overview

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.

Objectives

  • 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.

Methodology

  • 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:
    1. Converted images to grayscale and float32 format.
    2. Applied 2D FFT to both images.
    3. Computed the normalized cross-power spectrum and applied inverse FFT to obtain the correlation surface.
    4. 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:
    1. Created overlays (red = original, green = corrected) to visually inspect alignment.
    2. Computed difference/error maps to quantify residual misalignment.
    3. Visualized results using Matplotlib plots.

Key Insights

  • 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.

Tools and Technologies

  • 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)

About

Implemented an FFT-based image correlation algorithm to detect and correct spatial shifts between images, validated with synthetic test data and visual error maps for accurate alignment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages