On Sep 17, 12:28�am, kevinjmc...@netscape.net wrote:
> On Sep 16, 4:06�pm, "dpjones0" <dpjon...@comcast.net> wrote:
> > Hi,
> > I have been using FFTW to do some image processing, including cross
> > correlations, etc. �I have found it to be very useful. �I've used the r2c/
> > c2r combination as well as forward and reverse fftw_plan_dft_1d, based on
> > examples I have found online. �I have been reading this discussion group
> > that has helped me figure a lot of things out. �However, in my latest
> > application, I still seem to be stuck on one issue. �
> > I really need to know the exact frequency values that each index in the
> > FFT resultant complex represents. �At this point, speed is not that much of
> > an issue, as much as understanding what I'm doing. �So for example, I set
> > the input data to an NxN (e.g. 64x64) size image and use an out-of-place
> > fftw_plan_dft_1d setting the input imaginary data to 0 and the real data to
> > the pixel values. �I then end up with an NxN size FFTW complex, where the
> > DC value is at index 0,0. �Does this also imply that in the unshifted FFTW
> > frequency domain data, the first entire column has a horizontal frequency
> > of 0 and the first entire row has vertical frequency of 0???. �I presumed
> > this was the case, since the index 0,0 corresponded to 0 vertical freq and
> > 0 horizontal freq, but at this point it's not clear to me. �Does this mean
> > that for instance, along row=0, the horizontal frequency would go from:
> > (row,col) � � � horiz. freq. � � � vert. freq.
> > (0,0) � � � � � � 0 � � � � � � � � � � �0 � �\
> > (0,1) � � � � � � 1*1/N � � � � � � � � �0 � � |-> 32 indices f=0 to
> > .5-1/N
> > (0,N/2 - 1) � � � (N/2-1)*1/N � � � � � �0 � �/
> > (0,N/2) � � � � � - (N/2)*1/N � � � � � �0\
> > (0,N-1) � � � � � - (1/(N/2) � � � � � � 0/ �--> 32 indices f= -.5 to
> > -1/N
> > The reason I ask this is I got confused by trying to center the DC
> > component. �To look at power spectrums, etc with DC centered, in this
> > discussion group and elsewhere online, it is suggested to move the DC
> > component to N/2,N/2, and swap the quadrants (e.g. 1 and 4, 2 and 3). �
> > So, after doing that the DC component is now at row=N/2, col=N/2 (e.g.
> > 32,32 for my 64x64 input image). �Then, the horizontal frequencies increase
> > from coordinate row=32,col=32 to coordinate row=32,col=63 essentially from
> > DC (0 freq) to PI/32 in 32 pixels. �However, the conjugate symmetric data
> > for the negative frequencies now occurs from coordinates row=31,col=31 to
> > row=31,col=1, with an extra value at row=31, col=0. �Why is the conjugate
> > symmetric data offset by a row? �What are the frequencies for each of the
> > points surrounding the center DC position row=32,col=32?
> > Alternatively, it was also posted that you could just multiply the input
> > image pixels at coordinates (i,j) by (-1)^(i+j) for instance. �The problem
> > that I have is that these two options do not present the same results. �If
> > I do that, there is no DC value at N/2,N/2. �In other words, the data from
> > row=32,col=32 to row=32,col=63 equals the conjugate symmetric data from
> > row=32,col=31 to row=32,col=1, with an oddball number in the 0 column.
> > I think I'm missing something fundamental, b/c this seems a lot more
> > confusing than it should be...
> > Thanks for any help in these matters.
> > -Dan
> > dpjones0
> Consider an 8x8 example. �Consider just the FFT of one row. �You'll
> 0f, 1f, 2f, 3f, 4f, -3f, -2f, -1f
> You go from low frequency to high frequency and then back to low
> (considering -3f to be higher than -1f). �All of the rows will have
> that frequency arrangement. �Now consider the FFT of one column,
> You'll have:
> All the columns will have the same frequency arrangement. �Now
> consider the 4,4 point in the output - that's the (4f,4f) location -
> your highest frequency. �The 0,0 point is DC - your lowest frequency.
> The 3,3 point is (3f,3f), 2,2 is (2f,2f), etc. �But because of the
> negative frequencies, the point 7,7 is actually (-1f,-1f). �Similarly,
> point 6,7 is (-2f,-1f). Before centering the DC point, the 4,4 point
> is the highest frequency, and you go from high frequencies to low
> frequencies as you move towards the edges.
> When you center the DC output, you are in fact exchanging the data in
> the 4 quadrants. �For N even, each one of those quadrants contains (N/
> 2)x(N/2) points.
> For the N = 8x8 case, with the DC output centered (or rotated) to 4,4,
> the surrounding points are (row, column):
> (-1f, -3f) �(0f, -1f) �(1f, -1f)
> (-1f, �0f) � �DC � � �(1f, 0f)
> (-1f, �1f) �(0f, 1f) � (1f, 1f)
> OW! �My head hurts! �It really is confusing. For instance, before
> centering, columns 0, 1 and 2 have the following frequency
> 0f0f � �1f0f � �2f0f
> 0f1f � �1f1f � �2f1f
> 0f2f � �1f2f � �2f2f
> 0f3f � �1f3f � �2f3f
> 0f4f � �1f4f � �2f4f
> 0f-3f � 1f-3f � 2f-3f
> 0f-2f � 1f-2f � 2f-2f
> 0f-1f � 1f-1f � 2f-1f
> After centering, the arrangement gets a lot more confusing because of
> the quadrant swapping.
> I've also seen the multiply outputs bit, and I think it actually does
> work, because I saw some code that used it. �But I've always just used
> 2 'for' loops to get it done.
> I hope all of the above shows up with proper spacing and no serious
> wrap around problems.- Hide quoted text -
> - Show quoted text -
Oops. The point to the upper left of DC after centering is the 7,7
point, which is (-1f,-1f), not (-1f,-3f). And yes, you're right about
the symmetry. Think in terms of an 8 point 1D FFT - there's no
conjugate for the 0f and 4f points. And then consider the 2D case.