Using wavelets for image decomposition / reconstruction

6 ビュー (過去 30 日間)
Srikanth
Srikanth 2011 年 8 月 29 日
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');
  1 件のコメント
ajith
ajith 2012 年 9 月 14 日
what is 'db1'?

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

回答 (2 件)

Wayne King
Wayne King 2011 年 8 月 29 日
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
  1 件のコメント
Srikanth
Srikanth 2011 年 9 月 5 日
Dear Wayne
rgb2ind gives output of X as unit8.
I downloaded a mandrill image from internet. This image i read into Matlab using imread command.
Srikanth

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


rudi setiawan
rudi setiawan 2012 年 2 月 4 日
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');

カテゴリ

Help Center および File ExchangeWavelet Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by