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:
- Create an array same size as index.
- For each element in index, assign the corresponding value from codebook.
Here is the dequantization step:
dequants = codebook(index + 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!