From: talal hammouri on 17 Feb 2010 04:15 hi all, i have used the following program that made image compression for color images and it works good but the problem of the color of the original and the compressed image output is not as the input image. can any body explain to me why and how can we made ro obtain the same color AS OF THE input image? what changes can be made to obtain the same color of the input image. THANX %Image compression for color images clear all; close all; clc; % Reading an image file [imagefile1 , pathname]= uigetfile('*.bmp;*.BMP;*.tif;*.TIF;*.jpg','Open An image'); if imagefile1 ~= 0 cd(pathname); I=imread(char(imagefile1)); end; X=I; % inputting the decomposition level and name of the wavelet n=input('Enter the decomposition level:'); wname = 'haar'; x = double(X); TotalColors = 255; map = gray(TotalColors); x = uint8(x); %Conversion of RGB to Grayscale x = double(X); xrgb = 0.2990*x(:,:,1) + 0.5870*x(:,:,2) + 0.1140*x(:,:,3); colors = 255; x = wcodemat(xrgb,colors); map = pink(colors); x = uint8(x); % A wavelet decomposition of the image [c,s] = wavedec2(x,n,wname); % wdcbm2 for selecting level dependent thresholds alpha = 1.5; m = 2.7*prod(s(1,:)); [thr,nkeep] = wdcbm2(c,s,alpha,m) % Compression [xd,cxd,sxd,perf0,perfl2] = wdencmp('lvd',c,s,wname,n,thr,'h'); disp('Compression Ratio'); disp(perf0); % Decompression R = waverec2(c,s,wname); rc = uint8(R); % Plot original and compressed images. subplot(221), image(x); colormap(map); title('Original image') subplot(222), image(xd); colormap(map); title('Compressed image') % Displaying the results xlab1 = ['2-norm rec.: ',num2str(perfl2)]; xlab2 = [' % -- zero cfs: ',num2str(perf0), ' %']; xlabel([xlab1 xlab2]); subplot(223), image(rc); colormap(map); title('Reconstructed image'); %Computing the image size disp('Original Image'); imwrite(x,'original.tif'); imfinfo('original.tif') disp('Compressed Image'); imwrite(xd,'compressed.tif'); imfinfo('compressed.tif') disp('Decompressed Image'); imwrite(rc,'decompressed.tif'); imfinfo('decompressed.tif')
|
Pages: 1 Prev: Please help with period Next: Link between AODV and CSMA/CA |