1D DWT unwanted color shift.

1 次查看(过去 30 天)
harrynecek
harrynecek 2018-11-21
编辑: harrynecek 2018-11-21
Hello. I would like to ask you for a help. I'm writing a script for 1D dwt and idwt. Input data are spectral values on one pixel of a 3D image (300x300x224). My scripts are finally working but there is some unwanted shift in color. I can't figure out where it happens. I tried matlab's built-in functions and they work fine but I don't want to use them - I want to do the proces "manually".
In my opinion the convolution part is correct. The shifting is probably a result of a bad subtraction of the convolved signal (which is otherwise too long - I think (1,240)).
Please help me. I really don't know how to correct it.
Encoder script
INPUT=(1,224)
[LoD,HiD] = wfilters('db9','d');
L=length(input);
F=length(LoD);
x_l = conv(input,LoD); %Convolving
x_l = x_l(F:2:(F+L-2)); %Decimation and subtracting the wavelet length
x_h = conv(input,HiD); %Covolving
x_h = x_h(F:2:(F+L-2)); %Decimation and subtracting the wavelet length
% final output is [x_l x_h]
OUTPUT=2x(1,112)
Decoder script
INPUT=(1,224)
[LoR,HiR] = wfilters('db9','d');
L=length(input);
F=length(LoR);
mid_val=ceil((length(input))/2); %selecting middle value
x_l=input(1:mid_val); %dividing signal to LP and HP parts
x_h=input(mid_val+1:L);
x_l=upsample(x_l,2); %inserting 0 at even indexes
x_h=upsample(x_h,2);
x_l=conv(x_l,LoR);
x_h=conv(x_h,HiR);
x_l=x_l(F:F+L-1);
x_h=x_h(F:F+L-1);
% final output is [x_l + x_h]
OUTPUT=2x(1,112)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Multiresolution Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by