L
L
Lerby2016-04-03 12:01:11
Mathematics
Lerby, 2016-04-03 12:01:11

How to correctly resize an image for Fourier transforms?

Hello!
I started experimenting with Fourier Transforms to work with images within opencv and couldn't find an answer to the question - what is the correct method to scale an image to prepare it for Fourier work?
For DPF or FFT2, the image should be scaled so that the side is 2 to some extent.
Of course, opencv has a getOptimalDFTSize function that allows you to find out the desired value. I am confused by the need to compress or stretch the image since the pixel values ​​are changed by various scaling algorithms. And most importantly - it is not clear by what logic this function gives the answer)))
Let's say we have a grayscale image of 80x80 pixels.
You can:
1) Reduce to 64x64 pixels
2) Stretch to 128x128
3) Make a black background 128x128 and draw the original in the center
Questions:
1 - How much does the scaling of the image affect the original information in it?
1a - which resizing algorithm corrupts the data less?
2 - Why is option 1 better than option 2? The fact that 80 is closer to 64?
2a - is it correct to stretch the image to the value 2^n, which is closer to the original one? how to do for example for 96x96 (the middle between 128 and 64)?
3 - what is bad and good option 3 with a frame?
3b - if the frame is a good solution, then are there methods in which the color of the frame is not just black, but is calculated
by the original image for any optimization reasons? (unless of course it matters and the answer to question 3 does not exclude this sub-question)
Thanks in advance for the answers.
p / s if I did not describe any scaling option, then please add it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Skusnov, 2016-04-03
@Lerby

The third option is the fastest and, it seems, does not introduce distortions. At least many FFT functions pad the data with zeros if the length is not a power of two (called zero padding). From here there are two conclusions: to take exactly black color (zeroes) and it is not necessary to shift the image to the center, you can leave it in the upper left edge (if the origin is there).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question