please see this program and tell me??????????i didn get the denoised image??

clc;
clf;
clear all;
close all;
i=imread('onion.png');
ii=rgb2gray(i);
figure,imshow(ii);
iy=imnoise(ii,'gaussian',0.1);
figure
imshow(iy);
Fs = 1000;
t = 0:1/Fs:.3;
digit = ii(:);
nsamp = length(digit);
N = 1024;
overlap = N/2;
%Pause delay
w = 4;
noise = iy(:); % Noise
digit2 = digit + noise; % Noisy signal, added noise
figure
plot(digit2)
%Plays Noisy sample
%loops to go through range of different variables
for a = (1:2) %Used to change between magnitude and power spectrum
%Used to overestimate the noise
for q = (1:0.2:1.4)
% Used to set negative spectrum values to positive ones
for D = (0.06:0.02:0.12)
% For loop to go through all the frames of 128 samples
for k = 1:overlap:nsamp-N,
% e is a frame of size 128 samples from k to k+N-1
e = digit2(k:k+N-1);
e=double(e);
% multiply signal by hanning
% get the signal spectrum
X = fft(digit);
pxx1 = periodogram(X,hamming(length(X)));
figure
plot(10*log10(pxx1))
MagX = abs(pxx1).^a;
PhaseX = angle(pxx1);
% get the noise spectrum
NN = fft(noise);
pxx = periodogram(NN,hamming(length(NN)));
figure
plot(10*log10(pxx))
MagNN = q.*abs(pxx).^a;
Pxx=pxx+pxx1;
% do something to the magnitude
noisevec = noise(k:k+N-1)
noise=double(noise);
imgVar=var(noise);
mo=imgVar*(1024*1024);
MagY = MagX + MagNN;
Mag=digit-mo;
% function finds samples less than zero then set them to D
z = find (MagY < 0 );
MagY(z) = D;
% ifft (Inverse FT function) to get the time-domain signal again
MagY=sqrt(MagY);
Y = (MagY.^a).*exp(sqrt(-1).*PhaseX);
y = real(ifft(Y));
fi=reshape(y,198,135);
imshow(uint8(fi))
% overlap-add on output
u(k:k+N-1) = u(k:k+N-1) + y;
end;
end;
end;
end
figure
plot(y)
disp('Finished') % Simply displays finished when the code runs through

2 Commenti

What happens instead of the denoised image being displayed? Do you get an error message?
When you omit the ugly "clear all", you can use the debugger to check your code.

Accedi per commentare.

Risposte (0)

Categorie

Tag

Non è stata ancora inserito alcun tag.

Richiesto:

il 16 Ott 2013

Commentato:

Jan
il 16 Ott 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by