4
$\begingroup$

I have an image, I, sampled on a uniform grid:

$\ x_i = i*\Delta x, y_j = j*\Delta y, $

I need to resample this image to a grid rotated counterclockwise by an angle $\ \theta$ around $\ (x_0,y_0)$:

$\ u_i = i*\Delta u, v_j = j*\Delta v $

$\ x(u_i,v_j) = x_0 + cos(\theta)*u_i - v_j*sin(\theta)$

$\ y(u_i,v_j) = y_0 + sin(\theta)*u_i + v_j*cos(\theta)$

How do I best do this?

I understand that I can e.g. do bilinear interpolation to find I from the 4 (x,y) corners around each $\ (u_i,v_j)$.

However I am not free to choose $\ \Delta u $ and $\ \Delta v $ as I wish.

What is the Nyquist criterion for this rotated grid?

Am I right in assuming that it will be?:

$\ \Delta u = cos(\theta)*\Delta x + sin(\theta)*\Delta y$

$\ \Delta v = -sin(\theta)*\Delta x + cos(\theta)*\Delta y$

$\endgroup$
  • $\begingroup$ Am I correct in thinking that this would be an equivalent operation to image rotation? $\endgroup$ – Jason R Oct 26 '12 at 12:03
  • $\begingroup$ Yes! Glad you asked about this. $\endgroup$ – Andy Oct 26 '12 at 12:29
5
$\begingroup$

You should read about image transformations. Anyhow, the idea is quite simple:

  1. Compute the inverse transform $T(x,y)$.
  2. For each point $(x,y)$ on the re-sampled grid:

    • Calculate $T(x,y)$, and find the 4 closest points on the original grid.
    • Apply interpolation technique (For example, bi-linear) on the neighbors, and put the value in the re-sampled grid.

Some references:

http://www.cis.rit.edu/class/simg782/lectures/lecture_02/lec782_05_02.pdf http://www.imageprocessingbasics.com/geometric-transforms/

$\endgroup$
  • 1
    $\begingroup$ There's also a nice discussion of 2d interpolation in Numerical Recipes. $\endgroup$ – nibot Oct 27 '12 at 16:02
  • $\begingroup$ @ Andrey: thank you for your help. You gave me 1/2 of the solution. The other 1/2 consist of deciding the sampling in the rotated coordinate system. $\endgroup$ – Andy Oct 30 '12 at 12:51
  • $\begingroup$ @Andy, I don't understand. Please elaborate $\endgroup$ – Andrey Rubshtein Oct 30 '12 at 14:10
  • $\begingroup$ @Andrey: If I choose to large Delta u and Delta v this may cause aliasing. Choosing to small Delta u and Delta v on the other hand is not a problem. The upper limit on Delta u and Delta v is given by Nyquist. $\endgroup$ – Andy Oct 30 '12 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.