how to calculate entropy in matlab for lossless image compression ?

2 ビュー (過去 30 日間)
nur aqila
nur aqila 2018 年 2 月 21 日
コメント済み: nur aqila 2018 年 2 月 22 日
hi, I already perform iwt coding for the lossless image compression with image size 512x512 but I don't know how to calculate the entropy in Matlab coding. can anybody help me? below is my iwt coding;
  1 件のコメント
nur aqila
nur aqila 2018 年 2 月 21 日
clc
clear
x1= imread('lena.bmp');
im=double(x1);
En1 = entropy(x1)
% Start from the Haar wavelet and get the
% corresponding lifting scheme.
lshaar = liftwave('haar');
% Add a primal ELS to the lifting scheme.
els = {'p',[-0.125 0.125],0};
lshaarInt = liftwave('haar','int2int');
lsnewInt = addlift(lshaarInt,els);
%%%%%%%%%%%%%%%%%%%%%%%%Perform LWT for 9 level%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[cAint,cHint,cVint,cDint] = lwt2(im,lsnewInt);
test=[cAint,cHint;cVint,cDint];
%%%%%%%%%%%%%%%%%%%%%%%%Perform invert LWT until 9 level%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xRecInt = ilwt2(cAint,cHint,cVint,cDint,lsnewInt);
errInt = max(max(abs(im-xRecInt)))
level1=[cAint,cHint;cVint,cDint];
cAintk=int8(cAint);
one=[cAintk,cHint;cVint,cDint]; %int8
test1=[cAintk,cHint;cVint,cDint];
figure(2);
imshow(one);
title('leve1 1 suband');
%calculate entropy
%convert to positive integer
for y=1:512;
for x=1:512;
if test1(x,y)==0;
PixPos(x,y)=1;
else if test1(x,y)>0;
PixPos(x,y)=(test1(x,y)*2)+1;
else
PixPos(x,y)=abs(test1(x,y))*2;
end
end
end
end
%calculate frequency occurence of symbols
FreqPixInt(1:512)=0;
for y=1:512 %all pixel values in rows
for x=1:512 %all pixel values in columns
FreqPixInt(PixPos(x,y)+1)=FreqPixInt(PixPos(x,y)+1)+1;
end
end
FreqPixInt;
%calculate entropy of symbols(positive integer)
En2=0;% initialize value entropy to 0
for i=1:512 % all pixels value in first rows
if FreqPixInt(i)==0
En2=En2; %dummy
else
En2=En2+(FreqPixInt(i)/262144)*log2(FreqPixInt(i)/262144); %512x512=262144 total pixels
end
end
En2=En2*(-1)

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

採用された回答

Abhishek Ballaney
Abhishek Ballaney 2018 年 2 月 22 日
https://in.mathworks.com/help/images/ref/entropy.html

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by