當前位置:編程學習大全網 - 源碼下載 - 用MATLAB實現頻域平滑濾波和圖像去噪的代碼

用MATLAB實現頻域平滑濾波和圖像去噪的代碼

%%%%%%%%空間頻率(SF)低通濾波器濾波%%%%%%%

% SF濾波器對方向無選擇性(SF中的環形

%域)。

[文件名,路徑名,篩選索引]= ui getfile;

filename = fullfile(路徑名,文件名);

[X map] = imread(文件名,fmt);%讀取圖像

l = double(X);%轉換為雙精度

%%%%%%%%%%%需要將(-1)x+y加到L上

%計算FFT的點數(2的冪)

fftsize = 2。^上限(log2(大小(l)));

% 2d fft

Y = fft2(X,fftsize(1),FFT size(2));

Y = FFT shift(Y);

%獲取頻率(周期/像素)

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);

%計算半徑

SF = sqrt(mfx。^ 2 + mfy。^ 2);

% SF-帶通和方向-非選擇濾波器

filt = SF >k0;

A_filtered =過濾器。* A;% SF篩選

l _ filtered = real(IFFT 2(IFFT shift(A _ filtered)));% IFFT

L _ filtered = L _ filtered(1: size(L,1),1:size(L,2));

%%%%%%%%%需要將(-1)x + y加到L_filtered

%顯示

圖(1);

clf復位;

色彩映射表灰色;

%繪圖圖像

支線劇情(2,2,1);

imagesc(L);

彩條;

軸正方形;

set(gca,' TickDir ',' out ');

標題(“原圖”);

xlabel(' x ');

y label(' y ');

imwrite(L,fullfile(FilePath,' original image.bmp '),' BMP ');

%繪圖振幅

A = ABS(A);

A = log 10(A);

%光譜振幅

支線劇情(2,2,2);

imagesc(fx,fy,A);

xy軸;

軸正方形;

set(gca,' TickDir ',' out ');

標題('振幅譜');

xlabel(' FX(cyc/pix)');

ylabel(' fy(cyc/pix)');

imwrite(A,fullfile(FilePath,' amplitude spectrum.bmp '),' BMP ');

SF域中的過濾器

支線劇情(2,2,3);

imagesc(fx,fy,filt);

xy軸;

軸正方形;

set(gca,' TickDir ',' out ');

標題(“SF域中的過濾器”);

xlabel(' FX(cyc/pix)');

ylabel(' fy(cyc/pix)');

imwrite(filt,fullfile(FilePath,' filter in SF.bmp '),' BMP ');

%已過濾圖像

支線劇情(2,2,4);

imagesc(L _ filtered);

彩條;

軸正方形;

set(gca,' TickDir ',' out ');

標題(“過濾圖像”);

xlabel(' x ');

y label(' y ');

imwrite(filtered,fullfile(FilePath,' filtered image.bmp '),' BMP ');

%%%%%%%%%%%%中值濾波%%%%%%%

[文件名,路徑名,篩選索引]= ui getfile;

filename = fullfile(路徑名,文件名);

[LNoise map] = imread(文件名,fmt);%讀取圖像

L = medfilt2(LNoise,[3 ^ 3]);%用3*3塊去除噪聲

圖;

im show(lno ise);

標題(“過濾前的圖像”);

我猜的

imshow(L)

標題(“過濾圖像”);

imwrite(FilePath,' filtered image.bmp ',bmp)

  • 上一篇:星形http代理源代碼
  • 下一篇:收獲日2上帝模式distinylua在哪拜托了各位 謝謝
  • copyright 2024編程學習大全網