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

GaussEdgeSmoothingInterp.txt

## GaussEdgeSmoothingInterp.txt

number width, height, h2,w2
number Gwidth = 4; // width of Gaussian in pixels in reciprocal space
number Nedge = 150; // width of smoothed edge in pixels
image img3
complexImage img2

// obtain selected image and get its size:
Image img=getFrontImage()
getSize(img,width,height)
h2 = height/2;
w2 = width/2;

// produce a Gaussian of equal size
ComplexImage Gauss:=ExprSize(width,height,exp(-((irow-h2)**2+(icol-w2)**2)/(Gwidth**2)))

// convolute image with Gaussian
if (0) {// use DM FFT routines
img2 = realifft(realfft(img)*Gauss)
}
else { // use FFTW
img2 := ComplexImage("Smoothed Image",8,width,height)
img2[] = img[]
Gauss = T_shiftImageCenterComplex(Gauss)
T_fft_C2C(img2,img2)
img2 *= Gauss/(width*height)
T_ifft_C2C(img2,img2)
}

if (0) {
// replace edge of original image with smoothed image:
img3 = tert((abs(icol-w2)<w2-Nedge)&&(abs(irow-h2)<h2-Nedge),img,img2)
}
else {
// produce a gradual transition from the smooth image to the sharp one:
// For this we will create a mask image the edges of which fall off to zero:
Image rampX = ExprSize(width,height,w2-abs(icol-w2))/Nedge
Image rampY = ExprSize(width,height,h2-abs(irow-h2))/Nedge