comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: ENVI does a dumb thing reading a TIFF file with a palette included
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: ENVI does a dumb thing reading a TIFF file with a palette included [message #53805] Thu, 03 May 2007 07:00
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ed Hyer writes:

> I hesitate to use the term "bug", but what
> ENVI is doing here is at best a poor choice. ENVI has its own
> (somewhat clunky) color table functionality, why can't it load the
> palette as a palette? Am I wrong to think this is how ENVI "should"
> treat TIFF files?

Oh, oh. This post touched a nerve. I've heard this morning
from someone who should know that the reason ENVI treats
TIFF images this way goes back to the origins of ENVI
in the good ol' 8-bit display days, when you had perhaps
200 colors available for EVERYTHING, including all the
colors ENVI needed for it's own use. A TIFF file with a
256 color palette would completely overwhelm the system,
so the decision was make to decompose the image to a 24-bit
image (in the manner I showed yesterday), then COLOR_QUAN
that into some acceptable number of colors. (And I learned
that COLOR_QUAN was written by David Stern for *exactly*
this purpose!)

Of course, this is not the way things are done now, and
the new ENVI Zoom Display, which is written in object graphics,
treats one band images with lookup tables as just exactly
that.

Here is a suggestion for how you can get what you want
now. Output your single band as a flat binary file and
make the associated ENVI header file (*.hdr) with a file
type "ENVI Classification". Give the number of "classes"
and the "lookup" values for the class colors, and bingo,
there you go. (You can even open the flat binary file
and use ENVI's Edit Header tool to enter the classes.)

Hope that helps. Rest assured your complaints have been
heard! :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: ENVI does a dumb thing reading a TIFF file with a palette included [message #53817 is a reply to message #53805] Wed, 02 May 2007 13:09 Go to previous message
Jeff N. is currently offline  Jeff N.
Messages: 120
Registered: April 2005
Senior Member
On May 2, 3:11 pm, Ed Hyer <ejh...@gmail.com> wrote:
> Hello IDL Wizards,
>
> I apologize for the offtopic post, but maybe someone here knows an
> ENVI trick I am missing. I have an XY array of data, category data
> with values from 0-16 + 254=NODATA. I have a color table ginned up
> specifically to display this data. I write a TIFF file, like so:
>
> tvlct,r,g,b,/get ; load palette values from color table
> write_tiff,filename,image,r=r,g=g,b=b
>
> This operation works perfectly in reverse-- in IDL.
>
> When I open the TIFF file in ENVI, it tells me I have three image
> planes: r,g,b. So an XY Location that should have a value of [2]
> instead has a value of [255,0,0] = color mapping for category '2'. All
> ENVI functions I tested (statistics, histograms, slices) seem to deal
> only with the RGB levels.
>
> Does anyone know how I can get at the actual data in the file
> [0-16+254] from inside ENVI? I prefer to include the palette in the
> TIFF because otherwise it's ugly, but right now it seems I can't have
> both in ENVI.
>
> Ideas welcome,
>
> --Edward H.

Wow! I had no idea that ENVI did this! I don't think it's a very good
way to do to handle tiff files either. I wonder though, if the reason
that ENVI does it this way has to do with how it isn't necessarily
easy (in my opinion) to load color tables in ENVI. Don't you actually
have to go to the preferences menu? And even then, you can only import
color tables from an ASCII file?

Jeff
Re: ENVI does a dumb thing reading a TIFF file with a palette included [message #53821 is a reply to message #53817] Wed, 02 May 2007 12:43 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ed Hyer writes:

> I hesitate to use the term "bug", but what
> ENVI is doing here is at best a poor choice. ENVI has its own
> (somewhat clunky) color table functionality, why can't it load the
> palette as a palette? Am I wrong to think this is how ENVI "should"
> treat TIFF files?

I don't know. I just know there are an awful lot of
people paying good money for graphics cards they don't
use. :-)

Cheers,

David

P.S. Let's just say that if you subscribe to my view
that ENVI is the only hope IDL programmers have of getting
usable functionality into IDL in the future, you would
be crazy to say a bad word about it. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: ENVI does a dumb thing reading a TIFF file with a palette included [message #53824 is a reply to message #53821] Wed, 02 May 2007 12:28 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
David,

Thanks for the quick reply. What ENVI wants is not what I want. I
don't use ENVI much at all, but I'm preparing this for some
colleagues, and they want to be able to manipulate and analyze the
actual data values in ENVI. I also want ENVI to know how to display
these values. The problem arises that if I include a display palette,
ENVI hides the raw numbers. I hesitate to use the term "bug", but what
ENVI is doing here is at best a poor choice. ENVI has its own
(somewhat clunky) color table functionality, why can't it load the
palette as a palette? Am I wrong to think this is how ENVI "should"
treat TIFF files?

--Edward H.
Re: ENVI does a dumb thing reading a TIFF file with a palette included [message #53826 is a reply to message #53824] Wed, 02 May 2007 12:21 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ed Hyer writes:

> I apologize for the offtopic post, but maybe someone here knows an
> ENVI trick I am missing. I have an XY array of data, category data
> with values from 0-16 + 254=NODATA. I have a color table ginned up
> specifically to display this data. I write a TIFF file, like so:
>
> tvlct,r,g,b,/get ; load palette values from color table
> write_tiff,filename,image,r=r,g=g,b=b

If that what ENVI wants, why not let it have it?

tvlct, r, g, b, /get
write_tiff, filename, [[[r[image]]], [[g[image]]], [[b[image]]]], 3

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: structures, arrays of pointers and assignment
Next Topic: 3D registration

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:27:39 PDT 2025

Total time taken to generate the page: 0.00739 seconds