二维离散傅立叶(DFT)变化及其反傅立叶变换(IDFT)
傅立叶变换通用形式
对通用形式来讲,c=1,s=-1即为傅立叶变化(图像空间域转频域);c=1/MN,s=1即为逆变换(频域转空间域)
halcon算子fft_generic(Image : ImageFFT : Direction, Exponent, Norm, Mode, ResultType : ) 通过参数设置可实现图像的频域和空间域的互转。
fft_generic(Image,ImageFFT,'to_freq',-1,'sqrt','dc_center','complex') *等效 fft_image(Image : ImageFFT : : ) fft_generic(Image,ImageFFT,'from_freq',1,'sqrt','dc_center','byte') *等效 fft_image_inv(Image : ImageFFTInv : : )
构建一个理想低通滤波器(ILPF)
read_image (Image, 'D:/halcon work/fft/图.bmp') rgb1_to_gray (Image, GrayImage) get_image_size (GrayImage, Width, Height) gen_image_const (Image1, 'complex', Width, Height) //生成一幅圈黑的与原图等大的图 gen_circle (Circle, Height/2, Width/2,30) //确定保留的低通区域 paint_region (Circle, Image1, ImageResult_paint,1.3566e-5, 'fill') //产生低通滤波器 fft_generic (GrayImage, ImageFFT1, 'to_freq', -1, 'none', 'dc_center', 'complex') convol_fft (ImageFFT1, ImageResult_paint, ImageConvol1) fft_generic(ImageConvol1,ImageResult1,'from_freq',1,'none','dc_center','byte')
以上步骤主要突出了建立滤波器过程
halcon中有直接构建低通滤波器的算子gen_lowpass( : ImageLowpass : Frequency, Norm, Mode, Width, Height : )
read_image (Image, 'D:/halcon work/fft/有票.bmp') rgb1_to_gray (Image, GrayImage) get_image_size (GrayImage, Width, Height) gen_lowpass(Lowpass,0.2,'n','dc_center',Width,Height) fft_generic(GrayImage,ImageFFT2,'to_freq',-1,'none','dc_center','complex') convol_fft(ImageFFT2,Lowpass,ImageConvol2) fft_generic(ImageConvol2,ImageResult2,'from_freq',1,'none','dc_center','byte')
布特沃斯低通滤波器
高斯低通滤波器
rgb1_to_gray (Image, GrayImage) get_image_size (GrayImage, Width, Height) gen_gauss_filter (ImageGauss, 0.1, 0.1, 0, 'n', 'dc_center',Width, Height) fft_generic(GrayImage,ImageFFT2,'to_freq',-1,'none','dc_center','complex') convol_fft(ImageFFT2,ImageGauss,ImageConvol2) fft_generic(ImageConvol2,ImageResult2,'from_freq',1,'none','dc_center','byte')
---------------------
作者:pengjc2001
来源:CSDN
原文:https://blog.csdn.net/pengjc2001/article/details/54092323
版权声明:本文为博主原创文章,转载请附上博文链接!

