Using wavelets for image decomposition / reconstruction
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to use wavelets decompose/reconstruct on images. If i try to read the mandrill image using rgb2ind command, the decompose/reconstructed image does not match the original. However this works well with MAtlab defined load mandrill command. Why ?
% Option 1
load mandrill;
% Option 2
% rgb = imread('mand_image.jpg'); [X,map] = rgb2ind(rgb, (2^4)-1) ;
% Below program is an example program from Matlab help for dwt2 command
% When this command is used, a image is decomposed to half its size
% and using idwt2 and the decomposed arrays, the original image can be re-constructed
%
% Option 1 : Run the below program with
% load mandrill statement uncommented and statement rgb = ... commented
% Option 2 : Run the below program with
% statement rgb = ... uncommented and load mandrill statement commented and
% In Option 1 i am able to match the input and output images
% In Option 2 it is not happening. I am not able to figure out how
% to create [X,map] arrays using rgb2ind command
% Perform single-level decomposition of X using db1.
[cA1,cH1,cV1,cD1] = dwt2(X,'db1');
figure; imshow(X,map);title('Original Image');
figure; imshow(cA1,map);title('Decompose L1 Image');
sX = size(X);
%Convert back
A3 = idwt2(cA1,cH1,cV1,cD1,'db1');
figure; imshow(A3,map);title('Re-composed Image');
Respuestas (2)
Wayne King
el 29 de Ag. de 2011
Hi Srikanth
load mandrill;
gives you an array of class double. What is the class of X in the output of rbg2ind?
Did you use imwrite to create the .jpg file from the array X in the workspace? If so, show us the code.
Also, please use the {} Code features in Answers, so that people can read your code more easily.
Wayne
rudi setiawan
el 4 de Feb. de 2012
I think, you must change the value in rgb2ind(RGB, n), n = 256 or 128, it must suitable with your image size, if you want to show the decode image, you must convert first to uint8
[X, map] = rgb2ind(RGB, 256);
figure; imshow(X,map);title('Original Image');[cA1,cH1,cV1,cD1] = dwt2(X,'db1');
figure; imshow(cA1,map);title('Decompose L1 Image');
figure; imshow(X,map);title('Original Image');figure; imshow(uint8(cA1),map);title('Decompose L1 Image');
A3 = idwt2(cA1,cH1,cV1,cD1,'db1');
imshow(uint8(A3),map);title('Re-composed Image');
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!