Need help in using **Haar** wavelet decomposition upto 3 low levels.

216 views
Skip to first unread message

Nasir Khan

unread,
Apr 8, 2022, 6:41:51 AM4/8/22
to PyWavelets
I want to decompose an image upto 3 low levels using haar wavelet DWT and want to extract features of Red, Green, Blue channels separately.

here is my code 
where  RGB_colored is the RGB image i gave it to. now i dont know if i did it right
"
coeffs = pywt.wavedec2(RGB_colored, wavelet='haar',level=3)
LL, [LH3,HL3,HH3],[LH2,HL2,HH2],[LH1,HL1,HH1] = coeffs
"

Now if it is right then can anyone help me extract features for those 3 channels separaty (Red,Green,Blue) ?

Arian J

unread,
Oct 20, 2022, 5:50:54 AM10/20/22
to PyWavelets
Can't you just take the three channels separately and just do the wavelet decomposition on those channels?

Op vrijdag 8 april 2022 om 12:41:51 UTC+2 schreef nk86...@gmail.com:

Manoj Pandey

unread,
Oct 20, 2022, 9:59:05 AM10/20/22
to pywav...@googlegroups.com
Hii

Yes you can seperate all the three chanel using RGB or YIQ Or YCbCr then perform 3 level DWT on any channel you want and them recombine chanels to get color image


Regards

Manoj Kumar Pandey
PhD scholar

--
You received this message because you are subscribed to the Google Groups "PyWavelets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pywavelets+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pywavelets/e6f0d5fa-8111-4d32-9a52-8a6862960c02n%40googlegroups.com.

José Dávila

unread,
Oct 20, 2022, 3:50:31 PM10/20/22
to pywav...@googlegroups.com
Hi thanks for your answer.

Deepu

unread,
May 22, 2023, 2:14:36 AM5/22/23
to PyWavelets
To extract features from the decomposed image coefficients for each channel (Red, Green, Blue) separately, you can apply various statistical or perceptual measures. Here's an example of extracting features for each channel:

```python
import pywt
import numpy as np

# Decompose the RGB image using DWT

coeffs = pywt.wavedec2(RGB_colored, wavelet='haar', level=3)
LL, (LH3, HL3, HH3), (LH2, HL2, HH2), (LH1, HL1, HH1) = coeffs

# Extract features for each channel separately
red_features = []
green_features = []
blue_features = []

# Feature extraction for the Red channel
red_features.append(np.mean(LL[:, :, 0]))  # Example: Mean of the LL subband
red_features.append(np.std(LL[:, :, 0]))   # Example: Standard deviation of the LL subband
# Add more features as desired

# Feature extraction for the Green channel
green_features.append(np.mean(LL[:, :, 1]))  # Example: Mean of the LL subband
green_features.append(np.std(LL[:, :, 1]))   # Example: Standard deviation of the LL subband
# Add more features as desired

# Feature extraction for the Blue channel
blue_features.append(np.mean(LL[:, :, 2]))  # Example: Mean of the LL subband
blue_features.append(np.std(LL[:, :, 2]))   # Example: Standard deviation of the LL subband
# Add more features as desired

# Print or use the extracted features
print("Red channel features:", red_features)
print("Green channel features:", green_features)
print("Blue channel features:", blue_features)
```

In this example, I've shown how to extract two features (mean and standard deviation) for each channel from the LL subband of the DWT decomposition. You can add more features or modify the features based on your requirements.

Feel free to customize the feature extraction process by considering other statistical measures (e.g., variance, skewness, kurtosis) or applying perceptual features (e.g., color histograms, texture descriptors) to capture relevant information from the decomposed coefficients.

Remember to adapt the feature extraction process according to the specific characteristics and goals of your application.

I hope this helps you extract features from the DWT decomposition of the RGB image. Let me know if you have further questions!
Reply all
Reply to author
Forward
0 new messages