List Info

Thread: Perl code and median cut palettizing




Perl code and median cut palettizing
country flaguser name
United Kingdom
2007-03-02 04:22:20
First of all- note to self, should read the PNG website more
closely -
I've been struggling with coding issues for a month now and
until this
morning hadn't noticed the existance of this list!

Anyway, I am writing some perl to slim down PNGs (this all
started because
of some J2ME stuff).

You can see more at http://png.transpero.net
and
http://transpero.net/
blog/?p=58 may also be of interest. Code believed to
work can by found under Image-Pngslimmer at CPAN.

I started because although there were various bits of PNG
handling in some
of the perl graphics and images modules, there was nothing
stand-alone and
different modules seemed to perform in different ways (eg
GD::Graph seems
to output PNGs at default compression while PerlMagick is
much more
configurable).

Plus it was an intellectual challenge and I do this for
fun...

Anyway, now I've found the list I'll be asking lots of
questions but the
most immediate ones relate to median cut palettizing (which
I know is a
general mathematical problem rather than a specific PNG
one).

When trying to colour index (256 colour pallette) a PNG I am
consistently
having problems with creating 'boxes' in the colour space
which contain
only one point or are colour invariant on the longest axis -
is there an
algorithmic way of dealing with this or do people just use
heuristics?

Currently my code goes through the colour space repeatedly
cutting the
boxes up - ie going from 1 to 2 to 4 to 8 to 16 to ... 256
boxes, but it
seems that somewhere along the way I am always likely to end
up with a box
with just one point in the colourspace in it and that,
obviously, is not
susceptible to redivision.





------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
png-mng-implement mailing list
png-mng-implementlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/png-m
ng-implement

Re: Perl code and median cut palettizing
country flaguser name
United Kingdom
2007-03-02 05:57:12
On Fri, March 2, 2007 10:22 am, Adrian McMenamin wrote:
> Currently my code goes through the colour space
repeatedly cutting the
> boxes up - ie going from 1 to 2 to 4 to 8 to 16 to ...
256 boxes, but it
> seems that somewhere along the way I am always likely
to end up with a box
> with just one point in the colourspace in it and that,
obviously, is not
> susceptible to redivision.
>

I know it is bad form to reply to one's own messages, but I
have now
realised - after looking at a C++ implementation of the
algorithm - that
this is a pretty brain dead way of doing it, so I'll
rethink


------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
png-mng-implement mailing list
png-mng-implementlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/png-m
ng-implement

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )