Error in using waverec2
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a code below,where i used 2 level decomposition and added noise to image ,wen reconstructing i am not getting original image ,please assist
X = imread('cameraman.tif');
[C,S] = wavedec2(X,2,'haar');
A1 = appcoef2(C,S,'haar',1);
A2 = appcoef2(C,S,'haar',2);
[H1,V1,D1] = detcoef2('all',C,S,1);
[H2,V2,D2] = detcoef2('all',C,S,2);
lev=[A1,H1;V1,D1];
figure('name','One_level_Decomposition','numbertitle','off'), imshow(uint8(lev))
q=[A2,H2;V2,D2];
q1=[q,H1;V1,D1];
figure('name','Two_level_Decomposition','numbertitle','off'), imshow(uint8(q1)),title('Two_level_Decomposition')
J = imnoise(q1,'salt & pepper',0.02);
G=J(:)';
p=waverec2(G,S,'haar')
0 commentaires
Réponse acceptée
Wayne King
le 28 Fév 2013
You add noise to the image, then denoise in the wavelet domain, then reconstruct.
Like this:
load sinsin;
Y = X + 18*randn(size(X));
[thr,sorh,keepapp] = ddencmp('den','wv',Y);
xd = wdencmp('gbl',Y,'sym4',2,thr,sorh,keepapp);
subplot(221)
imagesc(X); title('Original Image');
subplot(222);
imagesc(Y); title('Noisy Image');
subplot(223)
imagesc(xd); title('Denoised Image');
0 commentaires
Plus de réponses (2)
Wayne King
le 28 Fév 2013
Why do you expect that after you have added noise to the coefficients and then inverted the wavelet transform that you would obtain the original image?
That will never happen. The wavelet transform (like the Fourier transform) is an invertible transform. If you modify the coefficients (in the wavelet domain or in the Fourier domain) and then invert the transform, you will end up with a different signal (image).
Wayne King
le 28 Fév 2013
Yes, but you don't need to use anything other than the C,S vectors
load woman;
[C,S] = wavedec2(X,2,'haar');
Xnew = waverec2(C,S,'haar');
max(max(abs(X-Xnew)))
You see perfect reconstruction
3 commentaires
Voir également
Catégories
En savoir plus sur Image Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!