[Numpy-discussion] Speedup creation of a 3-color array from a 2-d color-index array a color lut
Fri Feb 27 14:44:57 CST 2009
On Fri, Feb 27, 2009 at 14:41, Delbert Franz <firstname.lastname@example.org> wrote:
>> Message: 2
>> Date: Thu, 26 Feb 2009 23:32:35 -0600
>> From: Robert Kern <email@example.com>
>> Subject: Re: [Numpy-discussion] Speedup creation of a 3-color array
>> from a 2-d color-index array a color lut
>> To: Discussion of Numerical Python <firstname.lastname@example.org>
>> Content-Type: text/plain; charset=UTF-8
>> On Thu, Feb 26, 2009 at 23:27, Delbert Franz <email@example.com> wrote:
>> > I have ?geotiff files of scanned paper maps that use an indexed color scheme
>> > with a 256-element
>> > color lookup table (color lut) and a 9252 by 7420 array ?of uint8 elements.
>> > The color is given by
>> > three values. ?I want to create an array with shape: (9252, 7420, 3) so that
>> > I can display the
>> > image without creating internal array working space in Matplotlib that
>> > exeeds 2^31 bytes.
>> > The following three approaches work in that the correct image is displayed,
>> > but all of them
>> > are waaaaay too slow:)
>> > ?Let
>> > ? doq have shape (9252, 7420) and have uint8 elements
>> > ? ctab have shape (256, 3) and have uint8 elements.
>> > ? doqq have shape (9252, 7420, 3) and have unit8 elements
>> doqq = ctab[doq]
> Thanks, Robert! It works just fine but it "blows my mind":) Never would of
> thought of trying that. I'll have to work hard at getting my "mind around" how
> Numpy "views the universe".
The full range of indexing is discussed here:
> I'm just starting to come to terms with what
> "object oriented" means in Python. In 46 years of developing software, one
> is always on a learning curve, sometimes relatively flat, but sometimes
> nearly vertical--this was a moment on the vertical:)
Good. That means you're learning quickly. :-)
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion