How to create huffman dictionary, encoding and decoding without using built-in functions?

2 views (last 30 days)
I have a digital communication project assigned, i need help with one of the stages. the first stage is i need to format and image and then source encoded and decoded using huffman. the problem is that i can't use the built in functions, and i am to build a tree then a dictionary then encode and decode the image. i first converted it into a gray scale pixel matrix thrn i calculated the probabiltiy. I need help with huffman source coding, i need to build a code but i don't know how.
img = imread('sample.jpg');
imgOriginal = rgb2gray(img);
[rows, cols] = size(imgOriginal);
Image = imgOriginal(:);
[N, M] = size(Image);
Count = zeros(256,1);
for i = 1:N
for j = 1:M
Count(Image(i,j)+1) = Count(Image(i,j)+1)+1;
end
end
p = Count/(M*N);

Answers (0)

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!