好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

用MATLAB实现频域平滑滤波以及图像去噪代码.pdf

5页
  • 卖家[上传人]:飞***
  • 文档编号:35347038
  • 上传时间:2018-03-14
  • 文档格式:PDF
  • 文档大小:48.97KB
  • / 5 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 用 MATLAB 实现频域平滑滤波以及图像去噪代码浏览次数: 2981 次悬赏分: 50| 解决时间: 2008-11-8 14:21|提问者: unitis是数字图象处理的实验,麻烦高人给个写好的代码,希望能在重要语句后面附上一定的说明,只要能在MATLAB 上运行成功,必然给分具体的实验指导书上的要求如下:频域平滑滤波实验步骤1. 打开 Matlab 编程环境;2. 利用 ’ imread ’函数读入图像数据;3. 利用 ’ imshow ’显示所读入的图像数据;4. 将图像数据由’ uint8 ’格式转换为 ’ double ’格式,并将各点数据乘以(-1)x+y 以便 FFT 变换后的结果中低频数据处于图像中央;5. 用’ fft2 ’函数对图像数据进行二维FFT 变换,得到频率域图像数据;6. 计算频率域图像的幅值并进行对数变换,利用’ imshow ’显示频率域图像;7. 在频率图像上去除滤波半径以外的数据(置0);8. 计算频率域图像的幅值并进行对数变换,利用’ imshow ’显示处理过的频域图像数据;9. 用’ ifft2 ’函数对图像数据进行二维FFT 逆变换,并用’ real ’ 函数取其实部,得到处理过的空间域图像数据;10. 将图像数据各点数据乘以(-1)x+y ;11. 利用 ’ imshow ’显示处理结果图像数据;12. 利用 ’ imwrite ’ 函数保存图像处理结果数据。

      图像去噪实验步骤:1. 打开 Matlab 编程环境;2. 利用 ’ imread ’函数读入包含噪声的原始图像数据;3. 利用 ’ imshow ’显示所读入的图像数据;4. 以3X3 大小为处理掩模,编写代码实现中值滤波算法,并对原始噪声图像进行滤波处理;5. 利用 ’ imshow ’显示处理结果图像数据;6. 利用 ’ imwrite ’函数保存图像处理结果数据即使不是按这些步骤来的也没关系,只要是那个功能,能实现就OK,谢谢大家最佳答案%%%%%%%%spatial frequency (SF) filtering by low pass filter%%%%%%%% % the SF filter is unselective to orientation (doughnut-shaped in the SF % domain). [FileName,PathName,FilterIndex] = uigetfile ; filename = fullfile(PathName, FileName) ; [X map] = imread(filename, fmt); % read image L = double(X); % transform to double %%%%%%%%%%%%% need to add (-1)x+y to L % calculate the number of points for FFT (power of 2) fftsize = 2 .^ ceil(log2(size(L))); % 2d fft Y = fft2(X, fftsize(1), fftsize (2)); Y = fftshift(Y); % obtain frequency (cycles/pixel) f0 = floor([m n] / 2) + 1; fy = ((m: -1: 1) - f0(1) + 1) / m; fx = ((1: n) - f0(2)) / n; [mfx mfy] = meshgrid(fx, fy); % calculate radius SF = sqrt(mfx .^ 2 + mfy .^ 2); % SF-bandpass and orientation-unselective filter filt = SF > k0; A_filtered = filt .* A; % SF filtering L_filtered = real(ifft2(ifftshift(A_filtered))); % IFFT L_filtered = L_filtered(1: size(L, 1), 1: size(L, 2)); %%%%%%%%%%need to add (-1)x + y to L_filtered % show figure(1); clf reset; colormap gray; % plot image subplot(2, 2, 1); imagesc(L); colorbar; axis square; set(gca, 'TickDir', 'out'); title('original image'); xlabel('x'); ylabel('y'); imwrite(L, fullfile(FilePath, 'original image.bmp'), 'bmp') ; % plot amplitude A = abs(A); A = log10(A); % spectral amplitude subplot(2, 2, 2); imagesc(fx, fy, A); axis xy; axis square; set(gca, 'TickDir', 'out'); title('amplitude spectrum'); xlabel('fx (cyc/pix)'); ylabel('fy (cyc/pix)'); imwrite(A, fullfile(FilePath, 'amplitude spectrum.bmp'), 'bmp') ; % filter in the SF domain subplot(2, 2, 3); imagesc(fx, fy, filt); axis xy; axis square; set(gca, 'TickDir', 'out'); title('filter in the SF domain'); xlabel('fx (cyc/pix)'); ylabel('fy (cyc/pix)'); imwrite(filt, fullfile(FilePath, 'filter in SF.bmp'), 'bmp') ; % filtered image subplot(2, 2, 4); imagesc(L_filtered); colorbar; axis square; set(gca, 'TickDir', 'out'); title('filtered image'); xlabel('x'); ylabel('y'); imwrite(filtered, fullfile(FilePath, 'filtered image.bmp'), 'bmp'); %%%%%%%%%%%%%%%%%median filter%%%%%%%%%%%%%%%% [FileName,PathName,FilterIndex] = uigetfile ; filename = fullfile(PathName, FileName) ; [LNoise map] = imread(filename, fmt); % read image L = medfilt2(LNoise, [3 3]); % remove the noise with 3*3 block figure ; imshow(LNoise) ; title('image before fitlering') ; figure imshow(L) title('filtered image') ; imwrite(FilePath, 'filtered image.bmp', bmp) 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.