apply 1-degree wavelet transform to your image. use the method described in the lecture for wavelet transform to create your own wavelet transform. write your program. in matlab

Here is a sample code for applying a 1-degree wavelet transform to an image in MATLAB:

main.m
% Load an image
img = imread('my_image.png');

% Define the wavelet filter
h = [1 1] / sqrt(2);

% Pad the image to be divisible by 2
M = size(img, 1);
N = size(img, 2);
while mod(M, 2) ~= 0
   img(end+1,:) = img(end,:);
   M = M+1;
end
while mod(N, 2) ~= 0
    img(:,end+1) = img(:,end);
    N = N+1;
end

% Perform the wavelet transform
C = conv2(h, h, img, 'valid');
img_low = C(1:2:end, 1:2:end);
img_high = C(1:2:end, 2:2:end);

% Display the original and transformed images
subplot(1,3,1); imshow(img); title('Original Image');
subplot(1,3,2); imshow(img_low, []); title('Low-Frequency Component');
subplot(1,3,3); imshow(img_high, []); title('High-Frequency Component');
678 chars
28 lines

Explanation:

  1. Load the image using imread function.
  2. Define the wavelet filter h in this case, the Haar wavelet.
  3. Pad the image to be divisible by 2, which is necessary for the transform to work.
  4. Perform the wavelet transform by convolving the filter h with the image (conv2(h, h, img, 'valid')). Then, extract the low-frequency and high-frequency components of the transformed image by selecting alternate rows and columns of the convolution result (C(1:2:end,1:2:end) and C(1:2:end,2:2:end)).
  5. Display the original, low-frequency and high-frequency images for visual comparison.

Note that this 1-degree wavelet transform is the Haar wavelet transform, which is just one of many wavelet transforms available.

gistlibby LogSnag