Elevation Shading in Object Graphics [message #13351] |
Sun, 08 November 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Hi Folks,
Well, naturally, I hadn't posted my "Elevation Shading in
Object Graphics" example on my web page for more than 10
minutes when people more knowledgeable than I starting
pointing out the obvious faults.
In particular (and it is exceedingly odd that neither I
nor the folks who were helping me at RSI noticed this) it
is a LOT better to turn shading ON, although it is still
true that you want to have lights OFF.
I also discovered that it is better to add a color palette
to the surface (thanks to Struan) than to the window, which
I was doing previously. (Actually, it works the same, it
just seems more natural and elegant to add it to the
surface, where it really belongs.)
Anyway, I think I have it sorted out now and you can view
the article and code at these URLs:
http://www.dfanning.com/tips/elevation_object.html
http://www.dfanning.com/programs/object_shade_surf.pro
As always, a big thanks to the anonymous lurkers who
keep me on the straight and narrow. :-)
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Elevation Shading [message #42223 is a reply to message #13351] |
Fri, 14 January 2005 14:46  |
Jim Harwell
Messages: 5 Registered: January 2005
|
Junior Member |
|
|
Yes that's what I want - sorry I couldn't explain it so simply.
When I set MIN & MAX as you suggested in the second entry of this
thread, the output surface is black.
If I don't set them at all as in the code in the first entry of this
thread, the surface is displayed using the full color range rather than
just a portion of the colors.
|
|
|
Re: Elevation Shading [message #42224 is a reply to message #13351] |
Fri, 14 January 2005 14:39  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jim Harwell writes:
> The data range will lie somewhere between 0 & 255. I want each value to
> be represented by a different color/shade so that the user can make an
> approximation of the values of the peaks/troughs simply by looking at
> their color.
>
> Sorry, I am new to IDL so things are taking a long time - I keyed in
> the values of 55 and 155 as you suggested as a quick hack just to see
> if it was working - ultimately these Min & Max values will have to be
> extracted from the data each time a new set of data is processed.
> Thank you for your time and help.
Ah, then perhaps what you want is to set MIN=0 and MAX=255
so that your data colors are always scaled between these two endpoints.
That way, data that is actually scaled between 55 and 155 will
only use a portion of the colors in the color table. Is that
what you wanted?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Elevation Shading [message #42225 is a reply to message #13351] |
Fri, 14 January 2005 14:35  |
Jim Harwell
Messages: 5 Registered: January 2005
|
Junior Member |
|
|
A quick analogy.
Suppose we were working in grayscale and I was rendering a small
selection of a 2D grayscale image as a 3D surface. I would only want
the 3D surface to contain black troughs & white peaks if the image
selection contained black & white pixels. What I want is for the peak
to be of the same intensity as the brightest pixel in the image and the
trough the same intensity as the lowest.
|
|
|
Re: Elevation Shading [message #42226 is a reply to message #13351] |
Fri, 14 January 2005 14:26  |
Jim Harwell
Messages: 5 Registered: January 2005
|
Junior Member |
|
|
The data range will lie somewhere between 0 & 255. I want each value to
be represented by a different color/shade so that the user can make an
approximation of the values of the peaks/troughs simply by looking at
their color.
Sorry, I am new to IDL so things are taking a long time - I keyed in
the values of 55 and 155 as you suggested as a quick hack just to see
if it was working - ultimately these Min & Max values will have to be
extracted from the data each time a new set of data is processed.
Thank you for your time and help.
|
|
|
Re: Elevation Shading [message #42227 is a reply to message #13351] |
Fri, 14 January 2005 13:47  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jim Harwell writes:
> Thank you but now the surface is rendered as black no matter what
> values I set for MIN & MAX.
This might be a question of not really wanting what you
are asking for. :-)
The values 55 and 155 that we were talking about previously
are *data* values are they not? Your actual *data*
falls into this range. That's what occurs when you set
the MIN and MAX keywords as I suggested previously.
Any surface value LE to MIN is shown in the minimum
color, and any surface value GE to MAX is shown in
the MAX value, and the rest of the values are scaled
between MIN and MAX. If you thought these values
were color table values, then you might get a black
surface.
Now, I'm thinking that regardless of the data value, you
want to *display* the data with particular colors. How
we display the data, and how we scale the data can be two
completely different things.
In any case, I am now completely confused about what
you want to do. Can you elaborate a bit more on what
your data range actually is?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
Re: Elevation Shading [message #42239 is a reply to message #13351] |
Fri, 14 January 2005 08:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jim Harwell writes:
> I am using Dave Fanning's code to shade a 3D elevation.
>
> At present the elevations fade from:
> BLUE through GREEN through RED through YELLOW
>
> with the
> HIGHEST value represented as YELLOW, the
> LOWEST as BLUE and the
> MIDPOINT as RED.
>
> This always occurs regardless of the input values.
> i.e. if max & min are 255 and 0 respectively, they will be represented
> by yellow & blue respectively.
> likewise, if max & min are 155 and 55 respectively, they will be
> represented by yellow & blue respectively.
>
> What I want is that the output color correlates directly with the input
> value.
> i.e. if max & min are 255 and 0 respectively, they will be represented
> by yellow & blue respectively.
> but if max & min are 155 and 55 respectively, they will be represented
> by for instance red & green respectively.
>
> There must be some kind of scaling/normalization going on but I can't
> locate the code responsible - can anybody help me out/tell me where to
> correct it?
>
> This may be partly responsible:
> thisSurface = OBJ_NEW('IDLgrSurface', data, x, y, $
> Color=[255,255,255], _Extra=extra, Style=style, $
> Shading=shading, Hidden_Lines=hidden_lines)
> s = Size(data, /Dimensions)
> thisSurface->SetProperty, Vert_Colors=Reform(BytScl(data, /NAN),
> s[0]*s[1]), $
> Palette=thisPalette
Use the MAX and MIN values on the BYTSCL command to set the
scaling you desire:
theVertColors= BytScl(data, /NAN, MIN=55, MAX=155)
theVertColors= Reform(theVertColors, s[0]*s[1])
thisSurface -> SetProperty, Vert_Colors=theVertColors
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|