Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is that you are trying to treat newI and newJ as integer values while they are fractional. So every pixel of transformed image should be interpolation of number of pixels of original image. Note also that there number of interpolation methods in wrapAffine. Default one is linear interpolation. But you can choose other methods as well.

Another problem in your code is that the loops is over all pixels of original image. This is wrong for many reasons. Simplest of them (but not the only one) is that size of destination image may be different from size of original image. If destination image is bigger, some of its pixels will not be initialized. If destination image is smaller, you will initialize each pixel number of times. Instead the loop should be over all pixels of destination image. For each pixel you should calculate inverse transform to coordinates of original image, and take the values of relevant pixels.