i have written a code to get the probability of pixels value as '1' for implementing huffman compression

1 次查看(过去 30 天)
A = imread('lena1.jpg');
A = reshape(uint8(A), [1 512*512*3]);
s = size(A);
[rows columns numberOfColorBands] = size(A);
col1 = 1;
col2 = floor(columns/2);
col3 = col2 + 1;
row1 = 1;
row2 = floor(rows/2);
row3 = row2 + 1;
% Now crop
upperLeft = imcrop(A, [col1 row1 col2 row2]);
count = zeros(1,256);
for i =1:s(1)
for j =1:s(2)
count(uint8(A(i,j)+1)) = count(uint8(A(i,j)+1))+1;
end
end
count = double(count) /(512*512*3);
sumofprob=sum((count))
plot(count)
its working fine with the lena image ,,am getting the desired probability as 1
but if the change to any other image am not getting the probability as 'one'
i want to write a general code which works on all images
please help anyone to get the prob as '1'.

回答(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