Clear Filters
Clear Filters

dwt2 function for image compression

3 views (last 30 days)
Izabela Bigos
Izabela Bigos on 17 Dec 2022
Answered: Harsh Sanghai on 20 Dec 2022
Hello, I'm supposed to use the following code for a project to transform the image "WeeksHallSmall.jpg", but I am so confused as to what I am supposed to input for X. I don't know if I need both imread and load as well. I am confused on where I need to add additional inputs, rather than what the MATLAB documentation supplied.
imread("WeeksHallSmall.jpg");
load 'WeeksHallSmall.jpg'
imagesc(X)
colormap gray
[LoD,HiD] = wfilters('haar','d');
[cA,cH,cV,cD] = dwt2(X,LoD,HiD,'mode','symh');
subplot(2,2,1)
imagesc(cA)
colormap gray
title('Approximation')
subplot(2,2,2)
imagesc(cH)
colormap gray
title('Horizontal')
subplot(2,2,3)
imagesc(cV)
colormap gray
title('Vertical')
subplot(2,2,4)
imagesc(cD)
colormap gray
title('Diagonal')

Answers (1)

Harsh Sanghai
Harsh Sanghai on 20 Dec 2022
Hello Izabela,
For reading and displaying your own custom image "WeeksHallSmall.jpg" you can use the below code:
z = imread("WeeksHallSmall.jpg");
imagesc(z);
Note: imagesc(X) displays the data in array X as an image that uses the full range of colors in the colormap.
For understanding the "load" command use the below documentation as it is used to load ".mat" files:
For more information on dwt2 refer the documentation below:

Tags

Community Treasure Hunt

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

Start Hunting!