Clear Filters
Clear Filters

hi,i have a problerm in DWT

2 views (last 30 days)
Hadeel
Hadeel on 27 Oct 2022
Commented: Walter Roberson on 28 Oct 2022
hi,i try to transform the image into DWT and taking LL subband for processing,but i have a problem that LL subband views as a white region only,how i can solve this please??
[LL1,LH1,HL1,HH1]=dwt2(A,'db1');
figure(1)
subplot(2,2,1),imshow(LL1),title('LL');
subplot(2,2,2),imshow(LH1),title('Lh');
subplot(2,2,3),imshow(HL1),title('HL');
subplot(2,2,4),imshow(HH1),title('HH');
[LL2,LH2,HL2,HH2]=dwt2(LL1,'db1');

Accepted Answer

Walter Roberson
Walter Roberson on 27 Oct 2022
Your A matrix is probably uint8. Your LL1 returned from dwt() is double.
When you use that dwt() on data, the approximate maximum of the returned LL1 is twice the maximum value of the input. So with your input begin up to uint8(255), the approximate upper bound of LL1 is 510.0 . Notice that LL1 is double precision, and does not contain only values suitable for being uint8 .
So, you are trying to imshow() a double() number with values up to a little over 500.
When you are dealing with double() images, MATLAB assumes that all of the information is in the range 0.0 to 1.0 and that anything below 0.0 should be treated as 0, and anything about 1.0 should be treated as 1.0. It happens that the minimum LL1 value returned is greater than 1.0 so the data is displayed as-if it were all 1.0 -- all white.
You can use imshow(LL1, []) or imagesc(LL1) to have the graphics rescale the image data. But if you do that naively you lose any ability to compare between different images, because you would have removed any absolute scaling. You might want to specify a display range such as imshow(LL1, [0 512])
  2 Comments
Hadeel
Hadeel on 28 Oct 2022
yes sir,the problem is solved by your answer,i converted A into double and the matters became ok.thanks alot sir..but please the dimintion of LL views 128*128 and the size of A is 256*256,how can do the dimention of LL is 256*256???
Walter Roberson
Walter Roberson on 28 Oct 2022
@Hadeel you would need to create a new kind of mathematical analysis of objects in order to get that. Wavelet analysis is defined to create half-sized matrices of approximation coefficients. Look at the algorithm section and notice the downsample by a factor of 2 built right into the algorithm.
If what you are trying to do is a wavelet approximation of an array, then you can dtw2() and then idtw2() . Or you can use wavedec2() and then waverec2()
See also https://www.mathworks.com/matlabcentral/answers/1810980-wcompress-for-1d-data#comment_2383455 in which I show how to use wavedec() and drop coefficients and then waverec() the reduced coefficients, thus producing an approximated matrix. In my tests, dropping one level of coefficients stil looked pretty good, dropping two levels of coefficients tended to look somewhat blocky, and dropping three levels of coefficients was typically unusable.

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!