The Haar Transform with example (order N=4) and its implementation in MATLAB IIBasis function matrix
Video lecture series on Digital Image Processing, Lecture: 61, The Haar Wavelet Transform with example (order N=4) and its implementation in MATLAB II Haar Basis function transformation matrix Scaling function, Wavelet function Link to download ppts/lecture notes: https://drive.google.com/drive/folders/1AtR1eq6ZvQf-5vjXEMUPXNj2S0d9rAMZ?usp=share_link #DIP #DIPwithMATLAB #DigitalImageProcessingUsingMATLAB #digitalimageprocessing #digitalimageprocessinglecturesin4K #StudywithDrDafda MATLAB code used in the video is given below: % MATLAB program for generating Haar Matrix for N = 4 close all; clear all; clc; % Input : % N : size of matrix to be generated, N must be some power of 2. prompt = "Enter the size of Haar transformation matrix:"; N = input(prompt); % Hr : Haar matrix of size NxN if (N(less than)2 || (log2(N)-floor(log2(N)))~=0) error('The input argument should be of form 2^k'); end p=[0 0]; q=[0 1]; n=nextpow2(N); for i=1:n-1 p=[p i*ones(1,2^i)]; t=1:(2^i); q=[q t]; end Hr=zeros(N,N); Hr(1,:)=1; for i=2:N; P=p(1,i); Q=q(1,i); for j= (N*(Q-1)/(2^P)):(N*((Q-0.5)/(2^P))-1) Hr(i,j+1)=2^(P/2); end for j= (N*((Q-0.5)/(2^P))):(N*(Q/(2^P))-1) Hr(i,j+1)=-(2^(P/2)); end end disp('Haar matrix of size NxN is'); Hr=Hr*(1/sqrt(N)) % Plot of Haar Basis function Matrix M = N; K = 1; for i = 1 : M for j = 1 : N subplot (M,N,K); imshow(Hr(i,j)); K = K +1; end end %%%%%%%%%%%%%%%%%%%%%%% % MATLAB code for JPEG-2000 compression using Haar Transform close all; clear all; clc; rgb = imread('Peppers.png'); %rgb = imread('Maulik.png'); [LL,LH,HL,HH]= dwt2(rgb,'haar'); figure subplot(2,2,1);imshow(LL/255);title('LL band of image'); subplot(2,2,2);imshow(LH);title('LH band of image'); subplot(2,2,3);imshow(HL);title('HL band of image'); subplot(2,2,4);imshow(HH);title('HH band of image'); imwrite(rgb,'E:\Output_MATLAB\peppers_2000.j2k','CompressionRatio',100); imwrite(rgb,'E:\Output_MATLAB\peppers_jpeg.jpg'); figure subplot(1,3,1) imshow(rgb) title('Original Image') subplot(1,3,2) imshow('E:\Output_MATLAB\peppers_jpeg.jpg') title('JPEG compressed') subplot(1,3,3) imshow('E:\Output_MATLAB\peppers_2000.j2k') title('JPEG 2000 compressed') %%%Inverse JPEG-2000 rgb_Xrec=idwt2(LL,LH,HL,HH,'haar'); figure(3); imshow(uint8(rgb_Xrec)); title('Recovered Image')
Download
0 formatsNo download links available.