[gdal-dev] Converting palette image to RBG
Frank Warmerdam
warmerdam at pobox.com
Fri Feb 15 17:21:28 EST 2008
Christopher Barker wrote:
> As I'm doing this on the fly, I'd like it to be fast -- the pct2rgb.py
> code uses numpy, but it looks like it's processing the image line by
> line, and also looping through the color table. I need to do more
> testing to see if this is really too slow, but it would be nice to have
> all that looping in C -- and I can't be the only one that would use such
> functionality.
Chris,
The Numeric.take() directive should be a fast way to do lookups, and
one whole scanline at a time is handled rather than looping over the
pixels. So I think that pct2rgb.py is pretty fast.
Of course, it is also easy to replicate the capability in C.
> Another thought -- my workflow may be a bad idea anyway -- should I
> convert to RBG first, and then re-scale it? You must not be able to
> interpolate smoothly with a palleted image..
If you want any resampling kernel other than nearest neighbour you
would need to convert to RGB before resampling.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the gdal-dev
mailing list