This looks like the 2D reasample I had in my "pixelation_sampling(5bQAQA2).mcd" sheet. The explanation there, repeated here, was obviously not very clear.
This is an interpolation using DFT's.Here's the explanation in 1-D. For a given sample spacing xs corrrsponding to a spatial frequency fs = 1/xs, a sampled system can represent only spatial frequencies from 0 to a spatial freq fNyquist = fs/2. The spectrum is periodic at fs, and the spectrum from fs/2 to fs is the conjugate mirror of the spectrum from 0 to fs/2.
Having a denser spatial sampling grid means a higher spatial sampling frequency. Using a numeric example, let fs = 10 correspond to 0.1 mm = 100 micron sample spacing. Anything represented by this sampling grid has unique frequenncy components from 0-5, with the spectrum from 5-10 being the conjugate mirror. If we want the same function with the same spectrum but sampled at 20 micron spacing, then we need fs=50.
Create a new spectrum as follows:
freq 0-5: use orig 0-5 spectrum
freq 5-45: add zero intermediate values
freq 45-50: use orig 5-10 spectrum
This new spectrum has the same freq components as the original, but the mirror is now withrespect to 50, not f=10. Take the inverse DFT, and you have the original bandlimited function, but now sampled at a higher finer spatial pitch (sampling freq is higher).
Now what I hope is a bit clearer:
Take a simple example of a, 5 point, 1D "image" (a vector) with a DFT = (2,4+2j,7-j,7+j,4-2j). Note the conjugate symmetry, assuming the original fct. is real. Assume these correspond to frequencies(spatial or temporal - take your pick) 0,1,2,3,4, with a sampling freq fs =5. The spectrum repeats for both positive and negative freq's. The complete spectrum is:
frq DFT value
...
-2 7+j
-1 4-2j
0 2
1 4+2j
2 7-j
3 7+j
4 4-2j
5 2
6 4+2j
...
Only the one period is need for the description. The resampling preserves the frequency components that are already present, but increases the sampling frequency to get more points covering the same span.The unique components here are at freq's 0,1,2. The components at freq=-1,-2 are the conjugates of the f=1,2 components. Since the DFT is periofdic at f=5, the f=-2,-1 components are the same as the f=+3,+4 components. Only freq's up to fn = fs/2, called the Nyquist freq., can be uniquely defined as result of the periodicity and conjugate symmetry constraints. In our example , this is up to 2.5, (=2 for the discrete DFT case).
Let's resample to fs=8, so that we will have 8 "pixels covering the same overall image span, rather than the original 5. We need to preserve the conjugae symmetry and periodicity, so if we need to keep the f=0,1,2 components, then for fs=8, we already know what the fs=8,7,6 components will be. fn is now 8/2 = 4, so we have additional components we can define. since we don't want to add new, nonzero freq componets, we make all the new ones zero.
The resampled period becomes:
frq DFT value
...
0 2
1 4+2j
2 7-j
3 0
4 0
5 0
6 7+j
7 4-2j
8 2 (repeat of f=0)
...
The inverse DFT of this will have more spatial sample points, but the identical frequency content, of the original.
If there is a component exactly at fs/2 (fct. of odd vs. even # points), then this component need to be split in half when inserting the new zero components, part going to the upper half and part to the lower half. Here are simple examples:
orig 5 pt spectrum(no pt at fn): 5,3,9,9,3
new 10 pt spectrum:5,3,9,0,0,0,0,0,9,3 (,5...)
orig 6 pt spectrum(pt at fn with val = 8): 5,3,9,8,9,3
new 10 pt spectrum: 5,3,9,4,0,0,0,4,9,3 (,5...)
The bulk of the routine is taking care of the odd/even logistics, and doing it for both rows and cols. Hope this is a bit clearer. Follow a simple example yourself.
Lou