Original Address:How to change the decomposition coefficients and reconstruct the image after wavelet packet decomposition.
Author:Yang Storm
At present, the introduction of the Image wavelet packet transformation matlab Programming of the book is not many, but there are several, but they are a lot of MATLAB in the relevant functions of the help to re-describe it. Because the MATLAB help only shows that the decomposition results in a tree data structure, extract view is OK, how to change the decomposition coefficient is not known.
We know that the general wavelet packet decomposition is to deal with the wavelet packet coefficients, will deal with the changed coefficient reconstruction, so as to obtain the final processing results, so, how to get the coefficients, and then write the changed coefficients into the structure of the tree is the key.
The following describes how the image wavelet packet decomposition after the change of decomposition coefficients and re-reconstruction:
P=imread (' mwf1.bmp '); % Open an image
P1=double (P); % transform the image matrix into a double-precision type
WP1=WPDEC2 (p1,2, ' db2 ', ' Shannon '); % decomposition of image wavelet packets by DB2 wavelet
Nd=leaves (WP1); % get Decomposition Tree wp1 all also knot points
Cpj=wpcoef (Wp1,nd (j)); % a wavelet packet decomposition coefficient matrix corresponding to the first ND (j) node is obtained, for example j=3;
cpjn=cpj.*2; % change decomposition coefficient matrix
Wp1=write (WP1, ' CFS ', ND (j), CPJN); % will be changed after the coefficient matrix Cpjn written to the original Decomposition Tree WP1 in the structure of the second ND (j) node.
P2=WPREC2 (WP1); The modified wavelet decomposition coefficients are reconstructed, and the image is processed.
Figure (1); % display image before and after processing, compare
Subplot (211); Imagesc (P); ColorMap (' Gray ');
Subplot (212); Imagesc (Uint8 (p2)); ColorMap (' Gray ');