We're doing some simple image registration, where we calculate:
r = F^-1 ( ( F(A) * conj(F(B)) ) / magn( F(A) * conj(F(B)) ) )
where A is one image, B is the other image, F() is the Fourier transform, F^-1 is the inverse Fourier transform, conj() is the conjugate, magn() is the magnitude and all multiplications and divisions are per-element.
The DFT and FFT functions in IPP return packed data. The library also provides some function to work directly on packed data. So, we can calculate F(A) * conj(F(B)) by ippiMulPackConj (which also returns a packed image - I'll call this t1) and the magnitude of t1 by ippiMagnitudePack (which returns a normal image - I'll call this t2).
At this stage, I have no other option than to start doing ugly things. Two alternatives:
1. Calculate 1/t2, convert that to a complex image, convert that to a packed image and multiply it by t1 (ippiMulPack), then do the inverse Fourier.
2. Convert t2 to a complex image, convert t1 to a complex image, do the division, convert the result to a packed image, then do the inverse Fourier.
In the first case, I'm looking for a way to calculate 1/t2 (problem 1) and to do the conversion from a real image to a complex image (problem 2). In the second case, the conversion from a real image to a complex image (problem 1) is also needed.
For problem 1, I can create an image filled with ones, and do ippiDiv, which seems inefficient. Alternatively, I can use ippsInv or ippsDivCRev, but these are not ippi functions, so I have to handle the step size at the end of the line myself.
For problem 2, I again have to revert to ipps and use ippsRealToCplx, as there seems to be no ippi function to do this.
Given the problems that I encounter, I'm wondering whether I'm using the right approach. Any comments?