フィルターのクリア

How to calculate discrete wavelet transform on an image with levels 2,4 and 6 using dwt2 function in matlab

13 ビュー (過去 30 日間)
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 件のコメント
kollikonda Ashok kumar
kollikonda Ashok kumar 2023 年 5 月 9 日
How can we use DWT for decomposition for multiple images in dataset so that they can be used for further processing

サインインしてコメントする。

採用された回答

Abhishek Ballaney
Abhishek Ballaney 2018 年 2 月 26 日
https://in.mathworks.com/help/wavelet/ref/dwt2.html

その他の回答 (1 件)

Diwakar Diwakar
Diwakar Diwakar 2023 年 5 月 22 日
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.

カテゴリ

Help Center および File ExchangeDiscrete Multiresolution Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by