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

Home » Public Forums » archive » Working with color, cursor, and png to extract information
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
Working with color, cursor, and png to extract information [message #58526] Mon, 04 February 2008 11:59 Go to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
OK,

So I am no exactly sure how to ask this question but here goes. As
such I am open for reinterpretation or another solution all
together...

What I want to do:
- Start with a png image from old research (like
http://www.dfanning.com/programs/docs/read_toms_aerosol.jpg)
- read in the png (yes I know the example is a jpg, but it should be
the same procedure)
- extract the "value" at each pixel in the image based on the colorbar

This seems like it should in principle do doable...

Here is what I tried for this attempt:
- read in the image
IDL> image=selectimage(palette=palette)
IDL> help, image, palette
IMAGE BYTE = Array[3, 672, 708]
PALETTE BYTE = Array[256, 3]
- display it
IDL> window, /free, xs=672, ys=708
IDL> tv, image, /true
- select out the part that is the data with cursor and save it
separately
IDL> cursor, x1, y1, /dev ; clicked lower left
IDL> cursor, x2, y2, /dev ; clicked upper right
IDL> image2=image[*,x1:x2, y1:y2]
IDL> window, /free, xs=x2-x1, ys=y2-y1
IDL> tv, image2, /true
- set the x-y vectors using cursor and inspection, and scale_vector
(easy)

now I am stuck, I thought I could set the colortable with
IDL> tvlct, palette
but this seems to still be gray scale (according to cindex)
then I thought I could just pull out the value at each pixel from the
color table then map that back to the values in the colorbar. But I
dont know how, anyone else done something like this?

Normally I extract line plots with g3data (http://www.frantz.fi/
software/g3data.php) but it only does lineplots and not color plots.

Ideas? Comments?

thanks much,

Brian








------------------------------------------------------------ -------------
Brian Larsen
Boston University
Center for Space Physics
Re: Working with color, cursor, and png to extract information [message #58619 is a reply to message #58526] Mon, 04 February 2008 14:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Brian Larsen writes:

> I am not sure I agree with you entirely on this, if it were as
> hopeless as you say then why do we make those plots, our eyes can
> obviously decode the "meaning" in the color. Since you have the
> colorbar, it seems that gives a one-to-one mapping of colors to data
> value. At the worst case maybe just at the points in the colorbar
> where you have the value.
>
> If I ask the question another way does it make more sense? How can
> one choose out of an image a particular color and then display that?
> For example in that aerosol image of yours say I wanted to know where
> the data was between 3 and 3.5 (red), I can presumably "select" red
> and then pull out the red pixels from the image? No? Is this as easy
> as the 3 elements in image[*,0, 0] and a where statement? I am not
> too clear on exactly how the colors are built.

Normally, the color encoding of the color bar is different
from the color encoding of a 24-bit image. The former typically
uses indexed color, the latter used decomposed color. They
*may* be related. For example, suppose we load a "yellow" color
in color index 10:

r = 255 & g = 255 & b = 0
TVLCT, r, g, b, 10

And we decide that all pixels in our data between 3 and 3.5
are going to be colored with yellow:

index = Where(data ge 3 and data le 3.5)

We color our 24 bit image with this color:

s = Size(data, /Dimensions)
image = BytArr(s[0], [s[1])
rimage = image [index] = r
gimage = image [index] = g
bimage = image [index] = b
image24 = [[[rimage]], [[gimage]], [[bimage]]]

Now, the question is, how can you go from the 24-bit image
back to the data value? We can click on the image. We learn that
the pixel we clicked on has a value (255, 255, 0). Can we
find such a color triple in the color table? Maybe, we have
to search for the proper value in each of the three color vectors
at the same time. We find that color located in bin 10 of the
color table vectors. What does that tell us about the data
values? Absolutely nothing. I could have chosen to represent
data between 2000 and 3000 with this color index.

To make sense of this, you will have to know what color index
10 represents in the color table. You may have this information
somewhere. But you *don't* have it in the image. You can't go
anywhere with an index value of 10 and recover useful information
from either your images or your data array.

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: Working with color, cursor, and png to extract information
Next Topic: WIDGET_BASE always on top

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

Current Time: Wed Oct 08 17:06:30 PDT 2025

Total time taken to generate the page: 0.00457 seconds