Tamara
Tamara

Reputation: 2980

Discrete wavelet transformation of image using D4 wavelet

I'm trying to write forward wavelet transformation using D4 wavelet. Input data is color .bmp image with 24bit/pixel. Wavelet coefficients that I took:

h0 = 0.48296
h1 = 0.83652
h2 = 0.22414
h3 = -0.12941

g0 = -0.12941
g1 = -0.22414
g2 = 0.83652
g3 = -0.48296

The problem is, that during transformation I get values bigger than 255 or smaller than 0. What should I do in order to stay in [0,255] range?

Thanks.

Upvotes: 0

Views: 942

Answers (2)

alle_meije
alle_meije

Reputation: 2480

you can see from your filter coefficients that there will be negative values in your wavelet transform --in both the approximation and the detail coefficients.

there is one wavelet pair I can think of where the approximation coefficients will be nonnegative (if the input signal/image is): the haar wavelet, with

[h0 h1] = [1  1] / 2 

and

[g0 g1] = [1 -1] / 2

The detail coefficients will, in general, still be part negative, part positive (you may find monotonically decreasing signals/images where g is always nonnegative).

Upvotes: 0

jwdmsd
jwdmsd

Reputation: 2127

The output of wavelet transform always exceeds the input pixel range. Most Image processing libraries including Intel's IPP and CUVILib store the output in 32-bit floats. So you should too store the output in a bigger container. However in inverse wavelet transform you can always saturate the output to original image range which in your case is [0,255]

Upvotes: 1

Related Questions