How to calculate discrete wavelet transform on an image with levels 2,4 and 6 using dwt2 function in matlab
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ajay Ganti
el 24 de Feb. de 2018
Respondida: Diwakar Diwakar
el 22 de Mayo de 2023
I have an image lena.pgm. I want to compute the dwt on the image using dwt2 function in matlab and i want to display all the coefficients diagrams concatenated as shown in the figure (that is the image for 2 level decomposition)
. Like that i want to display for level 4 and level 6. I'm sending the code for 2 level decomposition. Please help me code:
clc;
clear all
myimage=imread('lena512gray.pgm');
image = myimage;
wavename = 'haar';
[cA,cH,cV,cD] = dwt2(im2double(image),wavename);
[cAA,cAH,cAV,cAD] = dwt2(cA,wavename); % Recompute Wavelet of Approximation Coefs.
Level2=[cAA,cAH; cAV,cAD]; %contacinat
imshow([Level2,cH; cV,cD],'Colormap',gray); %2 level
1 comentario
kollikonda Ashok kumar
el 9 de Mayo de 2023
How can we use DWT for decomposition for multiple images in dataset so that they can be used for further processing
Respuesta aceptada
Abhishek Ballaney
el 26 de Feb. de 2018
https://in.mathworks.com/help/wavelet/ref/dwt2.html
0 comentarios
Más respuestas (1)
Diwakar Diwakar
el 22 de Mayo de 2023
Here's the complete MATLAB code for calculating the discrete wavelet transform (DWT) on an image with levels 2, 4, and 6 using the dwt2 function:
% Load the image
image = imread('your_image.jpg'); % Replace 'your_image.jpg' with the actual image file path
% Calculate the DWT at level 2
[LL2, LH2, HL2, HH2] = dwt2(image, 'haar');
% Calculate the DWT at level 4
[LL1, LH1, HL1, HH1] = dwt2(LL2, 'haar');
% Calculate the DWT at level 6
[LL, LH, HL, HH] = dwt2(LL1, 'haar');
% Access the coefficients at each level for further processing or analysis
% Level 2 coefficients
LL2 % Approximation coefficients at level 2
LH2 % Horizontal detail coefficients at level 2
HL2 % Vertical detail coefficients at level 2
HH2 % Diagonal detail coefficients at level 2
% Level 4 coefficients
LL1 % Approximation coefficients at level 4
LH1 % Horizontal detail coefficients at level 4
HL1 % Vertical detail coefficients at level 4
HH1 % Diagonal detail coefficients at level 4
% Level 6 coefficients
LL % Approximation coefficients at level 6
LH % Horizontal detail coefficients at level 6
HL % Vertical detail coefficients at level 6
HH % Diagonal detail coefficients at level 6
Make sure to replace 'your_image.jpg' with the actual path to your image file. Also, remember to adjust the wavelet type if desired by replacing 'haar' with the desired wavelet family, such as 'dbN', 'symN', 'coifN', etc.
0 comentarios
Ver también
Categorías
Más información sobre Wavelet Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!