how to calculate entropy in matlab for lossless image compression ?

6 visualizzazioni (ultimi 30 giorni)
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 Commento
nur aqila
nur aqila il 21 Feb 2018
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)

Accedi per commentare.

Risposta accettata

Abhishek Ballaney
Abhishek Ballaney il 22 Feb 2018
https://in.mathworks.com/help/images/ref/entropy.html

Più risposte (0)

Categorie

Scopri di più su Discrete Multiresolution Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by