I came across this amazing response Applying MATLAB's idwt2
several times which I executed to understand it myself. However, I am unable to get how to use the same with work with an RGB image. So, I have 3 Questions.
How would the code be applied to an RGB image with only the transformed image displayed in the output that is along with the high and low frequency components along row and column,is it possible to view the fusion of all the components as a single image? I am aware that I have to put cat operator, but I cant understand how to go about it.
Secondly, I am also getting a mazed image! I am perplexed since I cannot seem to follow the reason. I have also attached the same code with the statement showing how this image has been generated.
3.What does the term
db1
in the function signature ofdwt
imply?
CODE:
load woman; % Load image data
%startImage=imread('pic_rgb.jpg'); % IF I WANT TO WORK WITH RGB IMAGE
nLevel = 3; % Number of decompositions
nColors = size(map,1); % Number of colors in colormap
cA = cell(1,nLevel); % Approximation coefficients
cH = cell(1,nLevel); % Horizontal detail coefficients
cV = cell(1,nLevel); % Vertical detail coefficients
cD = cell(1,nLevel); % Diagonal detail coefficients
startImage = X;
for iLevel = 1:nLevel,
[cA{iLevel},cH{iLevel},cV{iLevel},cD{iLevel}] = dwt2(startImage,'db1');
startImage = cA{iLevel};
end
figure;colormap(map);
imagesc(dwt2(startImage,'db1')); %THIS GIVES THE MAZED IMAGE INSTEAD OF THE TRANSFORMED IMAGE
figure;
tiledImage = wcodemat(cA{nLevel},nColors);
for iLevel = nLevel:-1:1,
tiledImage = [tiledImage wcodemat(cH{iLevel},nColors); ...
wcodemat(cV{iLevel},nColors) wcodemat(cD{iLevel},nColors)];
end
figure;
imshow(tiledImage,map);
%reconstruct
fullRecon = cA{nLevel};
for iLevel = nLevel:-1:1,
fullRecon = idwt2(fullRecon,cH{iLevel},cV{iLevel},cD{iLevel},'db1');
end
partialRecon = cA{nLevel};
for iLevel = nLevel:-1:1,
partialRecon = idwt2(partialRecon,[],[],[],'db1');
end
figure;
imshow([X fullRecon; partialRecon zeros(size(X))],map,...
'InitialMagnification',50);