f=imread('cameramantif'); % 读图
f=im2double(f); % 转化为double型数据
[r c]=size(f);%设置矩阵的行列数,图的大小
h=fspecial('gaussian',[r c],05); % 模糊核
g=imfilter(f,h,'circular'); % 图像模糊
a=01;
b=0000000000001;
n=a+brandn(r,c); % 噪声,均值为01,方差为b^2
g=g+n; % 模糊图像加噪声
F=fft2(f); % 清晰图像频谱
G=fft2(g); % 加噪图像频谱
H=psf2otf(h); % PSF->OTF
N=fft2(n); % 噪声频谱
H2=conj(H)H;
N2=conj(N)N;
F2=conj(F)F;
NF=N2/F2; % 噪信比
huv=H2/(H2+NF);
tuv=(1/(H+eps))huv; % 频域滤波器
RA=tuvG;
ra=real(ifft2(RA)); % 降噪图像
MN=sum(sum(N2));
MF=sum(sum(F2));
sr=MN/MF;
huv=H2/(H2+sr);
tuv=(1/(H+eps))huv; % 另一个频域滤波器
RC=tuvG;rc=real(ifft2(RC)); % 另一幅降噪图像
figure,imshow(f);title('原始图像');
[y,fs,bits]=wavread('E:\MATLA\work\hnistwav');
sound(y,fs,bits); %回放该音频
Y=fft(y,4096); %进行傅立叶变换
subplot(2,1,1);
plot(y);
title('声音信号的波形');
subplot(2,1,2)
plot(abs(Y));
title('声音信号的频谱');
%%%%%%%%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 imagebmp'), '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 spectrumbmp'), '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 SFbmp'), '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 imagebmp'), '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 33 block
figure ;
imshow(LNoise) ;
title('image before fitlering') ;
figure
imshow(L)
title('filtered image') ;
imwrite(FilePath, 'filtered imagebmp', bmp)
W=fft(w,N);
thisfilter(1:17)=001;
thisfilter(18:499)=1;
thisfilter(500:N)=001;%%%W对应的50Hz的峰值最大,找到对应的两个最大峰值的位置
thispy3=thisfilterW;%滤波
1、首先打开Matlab,鼠标点击图上的图标。
2、然后在d出的对话框中找到图中的位置。
3、点击图中的filter designs。
4、看图中绿色的部分(Analog Filter Design)就是模拟滤波器。
5、然后点击左上角的图标会d出窗口,拖进来。
6、双击上图的图标出现模拟滤波器的设置项。
以上就是关于求大神帮忙给这段matlab程序加上注释,跪谢,急求!全部的内容,包括:求大神帮忙给这段matlab程序加上注释,跪谢,急求!、用MATLAB对语音信号做时域和频谱分析。要求有详细的程序,谢谢了。、在线等matlab高手,帮忙改下程序实现图片简单(频域平滑滤波,图像去噪,自适应滤波)处理!~~请留下邮箱等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)