DSPRelated.com
Forums

Wavelet interpolation

Started by snehamoyc March 10, 2009
Hi,
I am working on image interpolation using wavelet transformation. I am doing one level wavelet transformation of my data and interpolating all 4 sub bands and inverse transformation to get interpolated image in spatial domain. I am trying with lena image but didn't get any satisfactory result. Here is my matlab code. Can anybody help me out what wrong I am doing with this program?

load lena;
X=lena;
X=imresize(X, [128,128]);
y1=X(1:2:end,1:2:end); %% This is the image to be interpolated

[W,S]=wavedec2(y1,1,'haar');

a=W(1:S(1,1)*S(1,2));
d1=W(S(1,1)*S(1,2+1:2*S(1,1)*S(1,2)));
d2=W(2*S(1,1)*S(1,2)+1:3*S(1,1)*S(1,2));
d3=W(3*S(1,1)*S(1,2)+1:end);

[Xi,Yi] = meshgrid(1:1:32);
[Xj,Yj] = meshgrid(0.5:0.5:32);
VI_Hd3 = interp2(Xi,Yi,d3,Xj,Yj,'linear');
VI_Hd1 = interp2(Xi,Yi,d1,Xj,Yj,'linear');
VI_Hd2 = interp2(Xi,Yi,d2,Xj,Yj,'linear');
VI_Ha1 = interp2(Xi,Yi,a,Xj,Yj,'linear');

y=[reshape(VI_Ha1, numel(VI_Ha1),1);reshape(VI_Hd1, numel(VI_Hd1),1);reshape(VI_Hd2, numel(VI_Hd2),1);reshape(VI_Hd3, numel(VI_Hd3),1)];
S1=2*S;
Xhat = waverec2(y, S1, 'haar');
imagesc(Xhat);
figure (2); hist(reshape(Xhat, numel(Xhat),1));

Waiting for help.

With regards,

Snehamoy
perhaps it would help if you explained what you meant by "not getting
satisfactory results".

my guess is you are trying to show perfect reconstruction. here's the
best way to start: pick a sequence x = [1 2 3 4 5 6 7 8 9], and see if
you can get perfect reconstruction. what you will notice is that there will
be a cyclic shift in the samples. once you correct that, you shouldn't
have any problems extending it to the 2-d separable filtering case that
you're trying to perform.

- chatonda

________________________________
From: snehamoyc
To: i...
Sent: Tuesday, March 10, 2009 5:19:28 PM
Subject: [imagedsp] Wavelet interpolation
Hi,
I am working on image interpolation using wavelet transformation. I am doing one level wavelet transformation of my data and interpolating all 4 sub bands and inverse transformation to get interpolated image in spatial domain. I am trying with lena image but didn't get any satisfactory result. Here is my matlab code. Can anybody help me out what wrong I am doing with this program?

load lena;
X=lena;
X=imresize(X, [128,128]);
y1=X(1:2:end, 1:2:end); %% This is the image to be interpolated

[W,S]=wavedec2( y1,1,'haar' );

a=W(1:S(1,1) *S(1,2));
d1=W(S(1,1)* S(1,2+1:2* S(1,1)*S( 1,2)));
d2=W(2*S(1,1) *S(1,2)+1: 3*S(1,1)* S(1,2));
d3=W(3*S(1,1) *S(1,2)+1: end);
[Xi,Yi] = meshgrid(1:1: 32);
[Xj,Yj] = meshgrid(0.5: 0.5:32);

VI_Hd3 = interp2(Xi,Yi, d3,Xj,Yj, 'linear') ;
VI_Hd1 = interp2(Xi,Yi, d1,Xj,Yj, 'linear') ;
VI_Hd2 = interp2(Xi,Yi, d2,Xj,Yj, 'linear') ;
VI_Ha1 = interp2(Xi,Yi, a,Xj,Yj,' linear');

y=[reshape(VI_ Ha1, numel(VI_Ha1) ,1);reshape( VI_Hd1, numel(VI_Hd1) ,1);reshape( VI_Hd2, numel(VI_Hd2) ,1);reshape( VI_Hd3, numel(VI_Hd3) ,1)];
S1=2*S;
Xhat = waverec2(y, S1, 'haar');
imagesc(Xhat) ;
figure (2); hist(reshape( Xhat, numel(Xhat), 1));

Waiting for help.

With regards,

Snehamoy