Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Arithmetic coding in Matlab

429 views
Skip to first unread message

Kaoutar

unread,
Feb 27, 2011, 8:00:21 AM2/27/11
to
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.

Error in ==> test_arith at 16
Icomp = arithenco(I(:),p);

Thank you in advance for any help!

Steven_Lord

unread,
Feb 27, 2011, 3:45:59 PM2/27/11
to

"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

0 new messages