# Code Discrete Fourier Transform Image

Hello everybody, I have found the code for Discrete Fourier Transform of an image here : OpenCV: Discrete Fourier Transform
However I don’t get how they croped the spectrum when it has an odd number of columns or rows that is : magI.cols & -2 and/or magI.rows & -2 inside the Rect…
I found that the & is a bitand operator that is it compares each bits of what is before the & to the bits of what is after the & and if both are 1 it keeps it at 1. Else it puts the bit to 0.
My Question is why do we compare the bits of magI.cols and magI.rows to those of -2 and not simply 2 ? Does anyone can explain ?

Thank you for reading

``````>>> bin(np.uint8(-2))
'0b11111110'
>>> a = np.arange(-5, +6)
>>> np.column_stack([a, a & -2])
array([[-5, -6],
[-4, -4],
[-3, -4],
[-2, -2],
[-1, -2],
[ 0,  0],
[ 1,  0],
[ 2,  2],
[ 3,  2],
[ 4,  4],
[ 5,  4]])
``````

that’s unrelated to OpenCV. that’s just how computers work, how integer arithmetic works.

Thank you crackwitz. I now understand how it works, it returns the closest lower even value.
bin(np.uint8(-2))=bin(np.uint8(254))…