Error in using waverec2
조회 수: 2 (최근 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!