Search code examples
imagematlabimage-processingwaveletwavelet-transform

How to re-construct an image with just the horizontal co-efficient of wavelet transform?


I am trying to reconstruct the input image with just the horizontal coefficients of the stationary wavelet transform.

[A,H,V,D ] = swt2(x,1,'sym4');

A = 0; V = 0; D = 0; %i am setting other co-efficents to zero since i am only intersted in the values of H %

Y = iswt2(A,H,V,D,'sym4') ; %this gives the following error below%

Error in iswt2/reconsLOC (line 153)
ca(sR,sC),ch(sR,sC,k),cv(sR,sC,k),cd(sR,sC,k), ...
Error in iswt2 (line 122) a = reconsLOC(a,h,v,d);

How can I resolve this?


Solution

  • You've omitted the top line of your error message, which gives a clue what the problem is:

    Index exceeds matrix dimensions.

    The problem is that you can't just set a matrix to a scalar 0, you have to set the entire matrix to zeroes, so that it still has the same size as H. This will work:

    A(:) = 0;  % Fills every element of A with zero
    V(:) = 0;
    D(:) = 0;
    Y = iswt2(A, H, V, D, 'sym4');