I'm trying to compute arithmetic coding on an image to perform lossless compression, so I used the matlab function arithenco and arithdeco like this :
picname='lena_32X32.png';
I = imread(picname);
minI = min(min(min(I)));
maxI = max(max(max(I)));
mapI = minI:1:maxI;
p = zeros(size(mapI));
for i = 1:length(mapI)
l = find(I == mapI(i));
p(i) = length(l);
end
Icomp = arithenco(I(:),p);
Idecomp = arithdeco(Icomp,p,length(I));
Idecomprgb = reshape(Idecomp, size(I,1), size(I,2), size(I,3));
isequal(Idecomprgb, I)
Unfortunately, it seems I can't make that work since I'm having the same error no matter what I try :(
??? Error using ==> arithenco at 36
The symbol sequence parameter must be a vector of positive finite integers.
Error in ==> test_arith at 16
Icomp = arithenco(I(:),p);
Thank you in advance for any help!
"Kaoutar " <kaou...@gmail.com> wrote in message
news:ikdht5$i79$1...@fred.mathworks.com...
> Hello everyone!
>
> I'm trying to compute arithmetic coding on an image to perform lossless
> compression, so I used the matlab function arithenco and arithdeco like
> this :
>
> picname='lena_32X32.png';
> I = imread(picname);
> minI = min(min(min(I)));
> maxI = max(max(max(I)));
> mapI = minI:1:maxI;
> p = zeros(size(mapI));
> for i = 1:length(mapI)
> l = find(I == mapI(i));
> p(i) = length(l); end
> Icomp = arithenco(I(:),p);
> Idecomp = arithdeco(Icomp,p,length(I));
> Idecomprgb = reshape(Idecomp, size(I,1), size(I,2), size(I,3));
> isequal(Idecomprgb, I)
>
> Unfortunately, it seems I can't make that work since I'm having the same
> error no matter what I try :(
>
> ??? Error using ==> arithenco at 36
> The symbol sequence parameter must be a vector of positive finite
> integers.
According to the documentation for ARITHENCO, the sequence parameter is the
first one. In your call to ARITHENCO, that would be I(:).
So, check that all the elements of I are positive finite integers. My
suspicion is that you have one or more 0 values in I.
--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com