Digital Signal Processing Reference
In-Depth Information
3 255
As an exercise, generate a random array and verify that the make_image program
always returns results between 0 and 255. Also, try it with oating-point values.
What if complex values were passed to this program? How could it be xed to
return real integers only?
10.3.1
2D DWT of a Grayscale Image
Now we have our program to show the eects of the 2D DWT on an image. First,
we will load the image and show it to the screen.
% load the image
x = imread(dog256x256.gif);
% show the original
figure(1);
imshow(x); title(original image);
Next, we will perform the 2D discrete wavelet transform on the image. Here we
use the Daubechies' db16 wavelet, though we could use any discrete wavelet that
we like.
[A, B, C, D] = dwt2(double(x), db16);
To make the dierent subimages viewable, we need to map their values to
grayscale pixel values. We use the make_image program from the previous section.
imA = make_image(A);
imB = make_image(B);
imC = make_image(C);
imD = make_image(D);
We need to know how large the subimages are. We can assume that they are the
same size, and create a large image matrix (superx) based on the size of subimage
imA. The zeros function simply returns a matrix lled with zeros, with the given
dimensions. In this case, the matrix values are all of type uint8.
[MAXA_row, MAXA_col] = size(imA);
% The dimensions should all be the same.
%[MAXB_row, MAXB_col] = size(imB);
%[MAXC_row, MAXC_col] = size(imC);
%[MAXD_row, MAXD_col] = size(imD);
superx = zeros(MAXA_row*2, MAXA_col*2, uint8);
Search WWH ::




Custom Search