天天看點

基于稀疏限制的圖像去噪算法研究(Matlab代碼實作)

 💥💥💞💞歡迎來到本部落格❤️❤️💥💥

🏆部落客優勢:🌞🌞🌞部落格内容盡量做到思維缜密,邏輯清晰,為了友善讀者。

⛳️座右銘:行百裡者,半于九十。

目錄

​​💥1 概述​​

​​📚2 運作結果​​

​​🎉3 參考文獻​​

​​🌈4 Matlab代碼實作​​

💥1 概述

圖像資料在人們日常的溝通和交流中不可或缺,然而圖像在傳輸和接收等過程中,往往會因為硬體裝置等原因受到噪聲的幹擾,這會降低圖像的品質,并影響後續對圖像的處理與分析。是以,去除圖像噪聲至關重要。目前,如何在去除噪聲的同時保護圖像的紋理細節仍是亟待解決的問題。近年來,稀疏表示理論的興起使圖像去噪取得了較大的突破。

📚2 運作結果

基于稀疏限制的圖像去噪算法研究(Matlab代碼實作)

 部分代碼:

pathname        = uigetdir;

allfiles        = dir(fullfile(pathname,'*.jpg'));

xts=[];         % initialize testing inputs

for i=1:size(allfiles,1)    

x=imread([pathname '\\' allfiles(i).name]);

x=imresize(x,gamma);

x=rgb2gray(x);

x=double(x);

xts=[xts; x];% testing set building

end

%% Initialization of the Algorithm

NumberofHiddenNeurons=500;  % number of neurons

D_ratio=0.35;               % the ratio of noise in each chosen frame

DB=1;                       % the power of white gaussian noise in decibels 

ActivationFunction='sig';   % Activation function

frame=20;                   % size of each frame

%% Train and test

%%

%  During training, gaussian white noise and zeros will be added to 

%  randomly chosen frames .

%  The Autoencoder will be trained to avoide this type of data corruption.

[AE_net]=elm_AE(xtr,xts,NumberofHiddenNeurons,ActivationFunction,D_ratio,DB,frame)

%% Important Note: 

%%

%  After completing the training process,we will no longer in need  To use 

%  InputWeight for mapping the inputs to the hidden layer, and  instead of 

%  that we will use the Outputweights beta  for coding and decoding phases

%  and also we can't use the activation  functon because  beta  is coputed 

%  after the activation .

%  The same thing is applied on biases (please for more details check the 

%  function'ELM_AE' at the testing phase).

%% Illustration

subplot(121)

corrupted=AE_net.x(:,1:gamma(2)*2);

imshow(corrupted')

title('corrupted images ');

subplot(122)

regenerated=AE_net.Ytr_hat(:,1:gamma(2)*2);

imagesc(regenerated'), colormap('gray');

title('regenerated images');

%% scale training dataset

T=Tinputs';T = scaledata(T,0,1);% memorize originale copy of the input and use it as a target

P=Tinputs';

%% scale training dataset

TV.T=Tsinputs';TV.T = scaledata(TV.T,0,1);% memorize originale copy of the input and use it as a target

TV.P=Tsinputs';TV.P = scaledata(TV.P,0,1);% temporal input

TVT=TV.T;%save acopy as an output of the function

%% in the 1st and 2nd step we will corrupte the temporal input

PtNoise=zeros(size(P));

i=1;

while i < size(P,2)-frame

gen=randi([0,1],1,1);

PNoise=[];

%%% 1st step: generate set of indexes to set some input's values to zero later 

%%% (here we set them randomly and you can choose them by probability)%%%

[zeroind] = dividerand(size(P,1),1-D_ratio,0,D_ratio);% generate indexes

%%% 2nd step: add gaussian noise 

if gen==1

Noise=wgn(1,size(P,1),DB)';% generate white gaussian noise

else

Noise=zeros(1,size(P,1))'; 

end

for j=1:frame;%copy  noise

PNoise=[PNoise Noise];

end

if gen==1

for j=1:length(zeroind);% set to zero

    PNoise(zeroind(j),:)=0;

    P(zeroind(j),i:i+frame)=0;

end

end

PtNoise(:,i:i+frame-1)=PNoise;

i=i+frame;

end

🎉3 參考文獻

部分理論來源于網絡,如有侵權請聯系删除。

​​🌈​​4 Matlab代碼實作

繼續閱讀