Effacer les filtres
Effacer les filtres

Huffman coding and decoding for image(JPEG, BMP)

24 vues (au cours des 30 derniers jours)
Manisha Mehra
Manisha Mehra le 28 Fév 2011
Commenté : Harshil Patel le 28 Avr 2020
I have to implement huffman encoding and decoding for a '.bmp' image without using the inbuilt matlab function like huffmandict, huffmanenco and huffmandeco.
Can anybody help me by sending me the source code?
Moreover, I have done the encoding part but I am not able to do the decoding. I have no idea as how to reconstruct the image through decoding.
  4 commentaires
Jasmina Vanasiwala
Jasmina Vanasiwala le 12 Déc 2016
I have to implement huffman encoding and decoding for a 'jpeg' image using C or C++. Please anyone help me by sending the source code?
Walter Roberson
Walter Roberson le 12 Déc 2016
  1. this is a resource for MATLAB questions not C or C++
  2. there are already a lot of public sources for that task including libjpeg
  3. if we send you source then you would not have implemented it. Would we get the academic credit or would you?

Connectez-vous pour commenter.

Réponse acceptée

Paulo Silva
Paulo Silva le 28 Fév 2011
  2 commentaires
Manisha Mehra
Manisha Mehra le 1 Mar 2011
Thanks..
It worked awesome.
fateh
fateh le 9 Nov 2014
how could i run this example

Connectez-vous pour commenter.

Plus de réponses (2)

Falak
Falak le 4 Mai 2012
Try this one... just change to your required image
%Author Name:Falak Shah
%Target: To huffman encode and decode user entered string
%--------------------------------------------------------------------------
string=input('enter the string in inverted commas'); %input string
symbol=[]; %initialise variables
count=[];
j=1;
%------------------------------------------loop to separate symbols and how many times they occur
for i=1:length(string)
flag=0;
flag=ismember(symbol,string(i)); %symbols
if sum(flag)==0
symbol(j) = string(i);
k=ismember(string,string(i));
c=sum(k); %no of times it occurs
count(j) = c;
j=j+1;
end
end
ent=0;
total=sum(count); %total no of symbols
prob=[];
%-----------------------------------------for loop to find probability and
%entropy
for i=1:1:size((count)');
prob(i)=count(i)/total;
ent=ent-prob(i)*log2(prob(i));
end
var=0;
%-----------------------------------------function to create dictionary
[dict avglen]=huffmandict(symbol,prob);
% print the dictionary.
temp = dict;
for i = 1:length(temp)
temp{i,2} = num2str(temp{i,2});
var=var+(length(dict{i,2})-avglen)^2; %variance calculation
end
temp
%-----------------------------------------encoder and decoder functions
sig_encoded=huffmanenco(string,dict)
deco=huffmandeco(sig_encoded,dict);
equal = isequal(string,deco)
%-----------------------------------------decoded string and output
%variables
str ='';
for i=1:length(deco)
str= strcat(str,deco(i));
end
str
ent
avglen
var
  8 commentaires
Walter Roberson
Walter Roberson le 23 Mar 2019
What leads you to say that it does not work?
Harshil Patel
Harshil Patel le 28 Avr 2020
I ran the code in matlab 2020a, and it generated some otput with some values for str, ent, avglen and var for an image input. So, how do I know if it's correct?

Connectez-vous pour commenter.


slama najla
slama najla le 19 Mai 2012
Hello please is that you can help me? is that you can send me your registration code files before you get the picture compressed as I encounter the same problem as let go of compressed image is a very superior picture framer and my original remark that the fault is in the recording files. thank you in advance
  9 commentaires
SS
SS le 27 Nov 2019
rng('default') % For reproducibility
X = rand(10,3);
In this code, what will be the value of X for my image..???

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by