Error in using waverec2
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Wayne King
2013-2-28
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 个评论
更多回答(2 个)
Wayne King
2013-2-28
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
2013-2-28
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!