Direkt zum InhaltDirekt zur SucheDirekt zur Navigation
▼ Zielgruppen ▼

Humboldt-Universität zu Berlin - Faculty of Mathematics and Natural Sciences - Strukturforschung / Elektronenmikroskopie

FourierInterpolate.txt

number width, height, h2,w2
number widthNew,heightNew,hn2,wn2
number interpFactor = 1.5;
number top,left,bottom,right

// Obrtain user input, exit, if the user pressed "Cancel"
if (!GetNumber("Please enter the interpolation factor: ",interpFactor,interpFactor)) {
exit(0)
}

// obtain selected image and get its size:
ComplexImage img=getFrontImage()[]
GetSelection(img, top, left, bottom, right)
width = right - left
height = bottom - top

// compute the center of the selected image:
h2 = height/2;
w2 = width/2;

// generate size of even sized new image
widthNew = 2*floor(0.5*interpFactor*width)
heightNew = 2*floor(0.5*interpFactor*height)
hn2 = heightNew/2;
wn2 = widthNew/2;

// generate the new image
ComplexImage img2:=CreateComplexImage("Interpolated Image",widthNew,heightNew);

// Compute FFT of current image (selection)
T_fft_C2C(img,img)
img = T_shiftImageCenterComplex(img)

// place the FFT of the current image into the new image
img2[hn2-h2,wn2-w2,hn2+h2,wn2+w2] = img
img2 = T_shiftImageCenterComplex(img2)

// inverse FFT the bigger image:
T_ifft_C2C(img2,img2);

Image img3=real(img2)
showimage(img3)

// clean up memory:
deleteImage(img2);