别人给了一小段程序,好象是C++写的,但是格式不对,不能运行,请帮忙改一下.谢谢了!
// First Calculate The PS of the front image// This script calculates the diffractogram of the topmost image. // A region with sides a power of two must be selected with the selection tool.// Procedure for calculation of diffractogram:// Step 1: subtract mean of selection of image.// Step 2: multiply selection with appropriately sized Hanning window.// Step 3: perform a Fourier transform.// Step 4: Display the log of the amplitude.// use script help for help on individual calculator commandsimage imgnumber top, left, bottom, rightif( !GetFrontImage(img) ){ OkDialog("You must have an image to operate on!") exit(0)}GetSelection(img,top,left,bottom,right) // uses whole image rectangle if no selection is presentnumber width = right - leftnumber height = bottom - topcompleximage FFTImage := RealFFT(img)number zoom = 512/widthif (zoom > 1) zoom = 1SetZoom(FFTImage,zoom)SetName(FFTImage, "FFT")KeepImage(FFTImage)image windowedImg := CreateFloatImage("",width,height)windowedImg = ( 1-cos(2*pi()*icol/width) ) * ( 1-cos(2*pi()*irow/height) ) * (img[]-average(img[]))compleximage diffractogram := RealFFT(windowedImg)deleteimage(windowedImg)image ps := modulus(diffractogram)SetName(ps, "Power Spectrum")deleteimage(diffractogram)SetZoom(ps,zoom)ShowImage(ps)
--------------------next---------------------
阅读(1402) | 评论(0) | 转发(0) |