I need help in image quantization & dequantization after dwt2 implementing

6 views (last 30 days)
hi friends...I have used a dwt2 on an grayscale image in 5 levels and its gave me large numbers up to 7000 as maximum,I need to use smaller numbers in my work (neer 256 or 512 as maximum) but I am also restricted to have large PSNR and little Compression ratio so I used quatization to less the values but I still have problems with the amount of my data so I used the follwoing code for quantization:
c1=c;
MAXc=max(c1);
MINc=min(c1);
MAXc=round(MAXc);
MINc=round(MINc);
v1=mod(MAXc,2);
v2=mod(MINc,2);
if v1==1
MAXc=MAXc+1;
end
if v2==1
MINc=MINc-1;
end
partition = [MINc:8:MAXc];
codebook = [(MINc/2)-4:4:(MAXc/2)];
[index,quants] = quantiz(c1,partition,codebook);
c=quants;
(where the c is the result of the 5 levels dwt2 on Lena image) I also need the dequantization step which I don't know how to write it...I hope that I explained my problem clearly I be very thankful to anybody can help me...

Answers (1)

Hari
Hari on 11 Jun 2025
Hi,
I understand that you are applying 5-level "dwt2" on a grayscale image and then using quantization to reduce the range of resulting wavelet coefficients for compression. However, you're concerned with high values (up to ~7000), and you're aiming to bring them down (closer to 256 or 512) while preserving high PSNR and minimizing compression loss. You’ve also written quantization code using "quantiz", and now you need a proper dequantization step.
I assume that your quantization is scalar and uniform (or near-uniform) based on the way partition and codebook are constructed, and you're using the same codebook for reconstruction.
In order to dequantize the previously quantized wavelet coefficients, you can follow the below steps:
Step 1: Use the same codebook for reconstruction
The quantiz function returns:
  • index: the quantization region index for each input
  • quants: the quantized values using the codebook
To reconstruct the original (approximate) values from index, you simply map back the index to the codebook values.Step 2: Perform dequantization using codebook
You can use the following approach:
  1. Create an array same size as index.
  2. For each element in index, assign the corresponding value from codebook.
Here is the dequantization step:
% Dequantization step
dequants = codebook(index + 1); % MATLAB indices start from 1
Explanation:
  • The +1 is used because MATLAB uses 1-based indexing, and index from quantiz starts at 0.
Step 3: Replace back into wavelet coefficient array
Now dequants contains the dequantized version of your original coefficient vector c1, and you can reshape or inverse transform it as needed.
Refer to the documentation of:
Hope this helps!

Products

Community Treasure Hunt

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

Start Hunting!