The Still Image compression For Effective Use Of Bandwidth
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
jyothsna chennareddy
el 13 de Abr. de 2011
Comentada: sailaja
el 6 de Feb. de 2014
Sir,
My project is "The Still Image compression For Effective Use Of Bandwidth". I have sucessfully compiled my code for gray scale images but while trying to compress color images getting an error that to while calculating mean square error(MSE) and peak signal to noise ratio (PSNR)indicating " ??? Error using ==> minus Number of array dimensions must match for binary array op. So, please kindly reply me soon what is the problem in the code and why it is possible to calculate MSE and PSNR only for gray scale images and not for color images.
MY code is
%%reading an image
input_image=imread('1.png');
input_image = imresize(input_image,[256 256]);
imshow(input_image);
handles.input_image=input_image;
[r c p]=size(input_image);
if p==3 %%%if p=3 then it is coler image
warndlg('convert color image into Gray image');
input_image=rgb2gray(input_image); %%%converting color image into gray image
end
input_image=imresize(input_image,[256 256]);
input_image=double(input_image);
[LL LH HL HH]= dwt2(input_image,'haar');
new_image=[...
LL LH
HL HH ...
];
figure, imshow(new_image,[]);
handles.new_image=new_image;
image_LL=handles.new_image;
[row1 col1] = size(image_LL);
Image_LL_resize = round(reshape(image_LL,[1 row1*col1]));
New_Image_LL_resize= round(Image_LL_resize/10);
%%%%%%%%% Huffman Encoding %%%%%%%%%%%
leng = length( New_Image_LL_resize);
maxr = max( New_Image_LL_resize);
minr = min( New_Image_LL_resize);
j = 1;
for i = minr:maxr
N = find(New_Image_LL_resize==i);
count = length(N);
probab(j) = count/leng;
j = j+1;
end
size_of_dict = length(probab);
[dictval avglen] = huffmandict([minr:maxr],[probab]);
y = huffmanenco( New_Image_LL_resize,dictval);
bitstream_image = y;
%%%%% finding length of bitstream %%%%%
bitstream = length(y);
disp('Length of Compressed Huffman Bitstream');
display(bitstream);
handles.dictval=dictval;
handles.y=y;
warndlg('Encoding Process Completed');
%%decoding
dictval=handles.dictval;
y=handles.y;
Dec_Out = huffmandeco(y,dictval);
len=length(Dec_Out);
row1=sqrt(len);
col1=row1;
New_Decim = reshape(Dec_Out,[row1 col1]);
New_Decim = New_Decim*10;
% figure(1),imshow(New_Decim,[]);
warndlg('Decoding Proces Completed');
handles.New_Decim = New_Decim;
%%Inverse DWT
Rec_image = handles.New_Decim;
%apply idwt
% img_idwt = idwt2(
[rows cols] = size(Rec_image);
for i = 1:rows/2
for j = 1:cols/2
CA(i,j) = Rec_image(i,j);
end
end
for i = rows/2+1:rows
for j = 1:cols/2
CH(i-rows/2,j) = Rec_image(i,j);
end
end
for i = 1:rows/2
for j = cols/2+1:cols
CV(i,j-cols/2) = Rec_image(i,j);
end
end
for i = rows/2+1:rows
for j = cols/2+1:cols
CD(i-rows/2,j-cols/2) = Rec_image(i,j);
end
end
% figure,imshow(CA,[]);
% figure,imshow(CH,[]);
% figure,imshow(CV,[]);
% figure,imshow(CD,[]);
output_image = idwt2(CA,CH,CV,CD,'haar');
%axes(handles.axes4);
figure, imshow(output_image,[]);
handles.output_image = output_image;
%%MSE
img1 = handles.input_image;
img2 = handles.output_image;
img2=imresize(img2,[256 256]);
[M N] = size(img1);
img2 = uint8(img2);
MSE = sum(sum((img1-img2).^2))/(M*N);
set(handles.edit1,'string',MSE);
handles.MSE = MSE;
%%PSNR
PSNR =abs(10*log10(255*255/MSE));
2 comentarios
Respuesta aceptada
Walter Roberson
el 13 de Abr. de 2011
To handle a color image, compress the R, G, and B planes separately.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Denoising and Compression 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!