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

readImg.txt

number t,dx,dy,cFlag,width,height,w,h,w2,h2;
compleximage imgc
realimage img
number oversample = 1;
complexImage outImg, outImgS, imgc2
string filename, comment

T_setverbose(0)

if (OpenDialog(filename)) {

result("Filename: "+filename+"\n");
if (GetNumber("Number of pixels for oversampling",oversample,oversample)) {

imgc := T_readImg(filename,t,dx,dy,cFlag,comment);
// Result("Sampling: "+dx+" x "+dy+"\n");


string name = getname(imgc); // result("Name: "+name+"\n");
if (oversample > 1) {
getsize(imgc,width,height)
outImg := ComplexImage("reciprocal space Image", 8, width, height)

T_fft_SetEstimate()

T_fft_C2C(imgc,outImg)
deleteImage(imgc)

outImgS := T_shiftImageCenterComplex(outImg)
deleteImage(outImg)
w2 = oversample*width;
h2 = oversample*height;
imgc := ComplexImage("smoothed img", 8, w2, h2)
imgc[0,0,h2, w2] = 0;

complexsubarea portion := imgc[height*(oversample-1)/2,width*(oversample-1)/2,(height*(oversample+1)/2),(width*(oversample+1)/2)];
portion = outImgS;
outImg := T_shiftImageCenterComplex(imgc)
T_ifft_C2C(outImg,imgc)
imgc = imgc/(width*height);
}

if (cflag) {
setname(imgc,comment+" t="+t+"A (x"+oversample+")");
if (oversample > 1) {
SetScale(imgc,dx/oversample,dy/oversample);
setname(imgc,comment+" t="+t+"A (x"+oversample+")");
}
else {
SetScale(imgc,dx,dy);
setname(imgc,comment+" t="+t+"A");
}
showimage(imgc);
}
else {
img = real(imgc);
deleteimage(imgc);

if (oversample > 1) {
SetScale(img,dx/oversample,dy/oversample);
setname(img,comment+" t="+t+"A (x"+oversample+")");
}
else {
SetScale(img,dx,dy);
setname(img,comment+" t="+t+"A");
}
showimage(img);
}

// Result("Image name: "+comment+" t="+t+" dx="+dx+"A dy="+dy+"A, cflag="+cFlag+"\n");
}
}