|
From: Ethan M. <merritt@u.washington.edu> - 2007-02-02 21:46:32
|
On Friday 02 February 2007 12:38, Hans-Bernhard Br=F6ker wrote:
> Ethan Merritt wrote:
> > gdImageShadedTriangle(gdImagePtr image, gdPoint *vertex, int *color);
>=20
> > That is, a filled triangle with interpolation of three separate colors
> > specified for the three vertices.=20
>=20
> Interpolation is quite a tricky business in color space, because there's=
=20
> no clear-cut idea what the curve to draw between two given points in=20
> colour space should be. To properly specify an interpolation mechanism,=
=20
> one needs to specify at least the coordinate system in which the=20
> interpolated surface in color-space is supposed to be flat.
That is an interesting point.
I noted out in my feature request for libgd that it was unclear what
sort of interpolation could be done with an indexed colormap. The usual
shading interpolation routines assume either RGB or CMY colorspace.
But I think you've answered that question. The gnuplot PM3D grey
scale palette routines define a single scale within which interpolation
of the index value does make sense. The question then becomes, is
this linear ordering of index values maintained internally in libgd?
We define colors 1->N sequentially using=20
for(i=3D0;i<N;i++) png_smooth_color[i] =3D gdImageColorAllocate(...)
Does this yield N successive color indices in libgd? I don't know.
If so, interpolation using the color index stored for each
vertex should approximate the PM3D colors that would have been
assigned for each pixel.
Of course, for small changes across the face of the triangle
RGB interpolation is probably OK anyhow. The results will only be=20
dramatically incorrect if the vertex values are so different that
they bracket a quite different color range on the PM3D color axis.
That can certainly happen, but it would mean that the grid
sampling is so course that important feature are likely to be
missed no matter what coloring scheme we use.
This is a general problem with interpolation schemes.
If the values assigned to the vertices are roughly the same,=20
but the "true" value in the middle of the face is different,
you won't get there by interpolation.
We should have plenty of time for testing, discussion, and
feedback. Gnuplot is headed for an imminent 4.2 release;
libgd for an imminant 2.0.34 release. Any work on coordinating
treatment of gradient-fill can proceed at leisure with an eye
to much more distant major release targets (4.4/5.0 and 2.1).
=2D-=20
Ethan A Merritt Courier Deliveries: 1959 NE Pacific=09
Dept of Biochemistry M/S 357742
Health Sciences Building
University of Washington - Seattle
|