Fasten the huffman coding

조회 수: 1 (최근 30일)
Renjith V Ravi
Renjith V Ravi 2017년 3월 9일
Is there any possibility to fasten the below code
clear all
clc
%Read the input image
Ao=imread('Lena.bmp');
Ao = imresize(Ao,[256 256]);
in = imfinfo('Lena.bmp')
% figure,
subplot(221)
imshow(Ao);
title('input image')
A=double(Ao);
%
% A=[10 2 3 4;5 6 7 8];
% display(A);
e=A;
tic
%Perform prediction error
for i = 1:size(A,1)
for j = 2:size(A,2)
e(i,j)=e(i,j)-A(i,j-1);
end
end
display(e);
%Huffman coding
C=reshape(e,[],1);
[D1,x]=hist(C,min(min(e)):max(max(e)));
sym=x(D1>0);
prob=D1(D1>0)/numel(e);
[dict,avglen] = huffmandict(sym,prob);
comp = huffmanenco(C,dict);
CR = in.FileSize/length(comp)
CR1 = (in.Width*in.Height*in.BitDepth/8)/length(comp)
%Huffman Decoding
dsig = huffmandeco(comp,dict);
e=reshape(dsig,size(A,1),size(A,2));
d=e;
for i = 1:size(A,1)
for j = 2:size(A,2)
d(i,j)=d(i,j-1)+e(i,j);
end
end
toc
% display(d);
%Decompressed Image
% figure,
de = uint8(d);
subplot(222)
imshow(uint8(d));
title('decompressed image')
psnr = psnr(de,Ao)
ssim= ssim(de,Ao)

답변 (0개)

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by