Image type? dwt2 problem? I don't know! the size is incorrect!

4 visualizzazioni (ultimi 30 giorni)
I perform a dwt2 on bmp image with in 5 levels and with filter bior4.4 but always doesn't have the same image size? since the original image size 512*512 =262144 but I get more than this number for the image ...the image is greyscale (black& white) why this happening.... the steps:
X=imread('baboon.bmp'); [C,S] = wavedec2(X,5,'bior4.4'); len=length(C);
and thank you in advance...

Risposta accettata

Wayne King
Wayne King il 5 Ott 2011
Hi Nizar, You are likely using the default extension mode for the DWT. Use the periodization mode.
dwtmode('per');
[C,S] = wavedec2(X,5,'bior4.4');
len=length(C);
Hope that helps,
Wayne
  2 Commenti
Nizar Ahmad
Nizar Ahmad il 5 Ott 2011
thank you king you were very helpful to me... I will check it just now and inform you the result...
Nizar Ahmad
Nizar Ahmad il 5 Ott 2011
hi again Mr king...
I had made these steps :
%%%%% 2D discrete wavelet transform with bior4.4%%%%
clear all;
clc;
global X;
X=imread('baboon.bmp');
dwtmode('per');
[C1,S1] = wavedec2(X,5,'bior4.4');
[a1,b1]=size(C1);
X_image = waverec2(C1,S1,'rbio4.4');
X_image=uint8(X_image);
imshow(X_image);
dwtmode('zpd');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
they worked v.well for me ...I thanl you again and ask you if there is any problem with the previous steps 4 dwt2 for 2 dimensions??

Accedi per commentare.

Più risposte (2)

Wayne King
Wayne King il 5 Ott 2011
Hi, You want to use 'bior4.4' in the reconstruction. The Toolbox knows that the biorthogonal filter has two analysis filters and two synthesis filters. 'rbio4.4' are not the synthesis filters for 'bior4.4'.
X = randn(512,512);
[C,S] = wavedec2(X,2,'bior4.4');
X1 = waverec2(C,S,'bior4.4');
% prefect reconstruction
norm(X1-X,2)
If you try to substitute 'rbio4.4', you'll see that you do not get perfect reconstruction. That is a different biorthogonal quadruplet.
I not sure why you set the dwtmode() back to zero pad at the end.
If you are trying to set it back to the toolbox default, that is:
dwtmode('sym');
  1 Commento
Nizar Ahmad
Nizar Ahmad il 6 Ott 2011
hi ... thank you wayne king: I thought that its the default mode
I will check the errors and fix them according to your advice
my needed decomposition is based on 5 levels then can I use:
[C,S] = wavedec2(X,5,'bior4.4');
then my final edit looks like:
clear all;
clc;
global X;
X=imread('baboon.bmp');
dwtmode('per');
[C1,S1] = wavedec2(X,5,'bior4.4'); %%% forward dwt2 with 5 levels
[a1,b1]=size(C1); %%% here a1=1 and b1= 262144
X_image = waverec2(C1,S1,'bior4.4');
X_image=uint8(X_image);
imshow(X_image); %%% show the image
dwtmode('sym');
%%%%%%%%%%%%%%%%%%%%%%%%%
I hope that is the correct one .... thank you v.much I appreciate your help....
thank you..

Accedi per commentare.


Walter Roberson
Walter Roberson il 5 Ott 2011
Do you get exactly 3 times what you expect? If so then although your image might appear to be greyscale (single channel), it was stored with 3 equal R, G, and B channels.
You should check size(X) after you read.
You should also try
[X,map] = imread('baboon.bmp');
and check to see isempty(map) . If map is not empty then the image matrix is 2D but stored in pseudocolor.
  2 Commenti
Nizar Ahmad
Nizar Ahmad il 5 Ott 2011
what I should then to get the same size 262144=512*512?
if the image was colored and not(black and white).
I used :
>> [Y,map]=imread('baboon.bmp');
>> X2=reshape(X,1,(512*512));
>> size(X2)
ans =
1 262144
the size was correct here...
but what if I used an (black and white)image(bmp)...
I always get more than the size expectd...
thank you for your help and thank you for any additional advices ...
Nizar Ahmad
Nizar Ahmad il 5 Ott 2011
just for knowledge the (map) was noe empty,, it contained an flost point number...

Accedi per commentare.

Categorie

Scopri di più su Wavelet Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by