i'm trying to enhanced image by gaussian high pass filter but it can't work... can you help me to repair my program? thangkyou before
1 回表示 (過去 30 日間)
古いコメントを表示
% function GaussianHighPass [m n]=size(image.jpg); f_transform=fft2(image.jpg); f_shift=fftshift(f_transform); x0=m/2; y0=n/2; D0=70; a=12.53; b=-4; for x=1:m; for y=1:n; D=sqrt((x-x0)^2+(y-y0)^2); hpf(x,y)=a*(1-exp(-(D^2)/(2*(D0^2))))+b; end end filter_apply=conv2(image.jpg,hpf,'same'); figure,imshow(filter_apply) image_orignal=ifftshift(filter_apply); image_filter_apply=abs(ifft2(image_orignal)); figure,imshow(image_filter_apply,[])
0 件のコメント
採用された回答
Jan
2013 年 8 月 16 日
編集済み: Jan
2013 年 8 月 16 日
As you are using imshow I'm guessing you have the image processing toolbox installed. In that case you might as well use the imfilter() function. The function
fspecial('Gaussian', hsize, sigma )
will generate a Gaussian lowpass filter.
High pass filtering can be achieved by subtracting the low pass filtered from the original image, e.g.
I = imread( 'peppers.png' );
I_filtered = I - imfilter( I, fspecial('Gaussian', 5, 1 ) );
imtool( I_filtered );
If you want to do the filtering explicitly, create the convolution matrix, e.g.
hp_filter_matrix = fspecial('Gaussian', 5, 1);
This gives you a 5 x 5 double matrix that you can convolve with your image to low pass filter it. As before, the high pass filtered representation can be obtained by subtraction.
2 件のコメント
Jan
2013 年 8 月 16 日
You are welcome! If that helped, you might want to mark it as 'Accepted Answer'.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!