Hi. I want to display second level dwt. If I display seperatly to frequency components, it works fine. But when I try to merge and display, It appears just black color. Here is my code
close all;
clear;
cd 'C:\Users\LENOVO\OneDrive\Masaüstü' %% Uploading picture to Matlab
X=imread('Coleen.jpg','jpg');%Reading picture by Matlab
[LoD,HiD] = wfilters('haar','d');
[cA,cH,cV,cD] = dwt2(X,LoD,HiD,'mode','symh');
[cA2,cH2,cV2,cD2]=dwt2(cA,LoD,HiD,'mode','symh');
subplot(2,2,1)
imagesc(cA)
colormap gray
title('Approximation')
subplot(2,2,2)
imagesc(cH)
colormap gray
title('Horizontal')
subplot(2,2,3)
imagesc(cV)
colormap gray
title('Vertical')
subplot(2,2,4)
imagesc(cD)
colormap gray
title('Diagonal')
figure
Level2=[cA2,cH2; cV2,cD2];
imagesc([Level2,cH; cV,cD]);
colormap gray
It appears like this. But I want to display it like below.
Please. Could you help me?

 채택된 답변

yanqi liu
yanqi liu 2021년 12월 24일
편집: yanqi liu 2021년 12월 24일

1 개 추천

yes,sir,may be use the dimension information,such as
close all;
clear all; clc;
%Reading picture by Matlab
X=imread('cameraman.tif');
[LoD,HiD] = wfilters('haar','d');
[cA,cH,cV,cD] = dwt2(X,LoD,HiD,'mode','symh');
[cA2,cH2,cV2,cD2]=dwt2(cA,LoD,HiD,'mode','symh');
figure
Level2=[mat2gray(cA2),mat2gray(cH2); mat2gray(cV2),mat2gray(cD2)];
d = [Level2,mat2gray(cH); mat2gray(cV),mat2gray(cD)];
% get dimension
rects1 = [1 1 size(cA2)
1 2 size(cA2)
2 1 size(cV2)
2 2 size(cD2)];
rects2 = [1 1 size(Level2)
1 2 size(cH)
2 1 size(cV)
2 2 size(cD)];
rects = {rects1, rects2};
imagesc(d);
colormap gray
axis equal
axis off
hold on;
rectangle('position', [1 1 size(d,2)-1 size(d,1)-1], 'EdgeColor', 'y', 'LineWidth', 2)
for k = 1 : length(rects)
rectsk = rects{k};
for i = 1 : size(rectsk, 1)
recti = [zeros(1, 2) rectsk(i,3:4)];
% get location
rowi = rectsk(i,1);
coli = rectsk(i,2);
for j = 1 : coli-1
recti(1) = recti(1) + rectsk(j, 4);
end
for j = 1 : rowi-1
recti(2) = recti(2) + rectsk(j, 3);
end
rectangle('position', recti, 'EdgeColor', 'y', 'LineWidth', 2)
end
end

댓글 수: 1

Imtiyaz Ahmad
Imtiyaz Ahmad 2023년 8월 7일
Hi,
I am facing an issue while using Daubechies wavelet , its says an error as ;Error using horzcat
Dimensions of arrays being concatenated are not consistent.... but its working fine while using haar wavelet, can you provide the solution for that also ..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2021년 12월 23일

댓글:

2023년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by