<HTML>
<HEAD>
<TITLE>gems - Graphic Gems - Graphic Support Methods</TITLE>
<LINK REV="made" HREF="mailto:cristy@mystic.es.dupont.com">
</HEAD>

<body background="../../images/background.gif">

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#FUNCTION_DESCRIPTIONS">FUNCTION DESCRIPTIONS</A>
	<UL>

		<LI><A HREF="#BesselOrderOne">BesselOrderOne</A>
		<LI><A HREF="#Constrast">Constrast</A>
		<LI><A HREF="#GenerateNoise">GenerateNoise</A>
		<LI><A HREF="#HSLTransform">HSLTransform</A>
		<LI><A HREF="#Hull">Hull</A>
		<LI><A HREF="#InsidePrimitive">InsidePrimitive</A>
		<LI><A HREF="#InterpolateColor">InterpolateColor</A>
		<LI><A HREF="#Modulate">Modulate</A>
		<LI><A HREF="#TransformHSL">TransformHSL</A>
		<LI><A HREF="#Upsample">Upsample</A>
	</UL>

</UL>
<!-- INDEX END -->

<HR>
<P>
<H1><A NAME="NAME">NAME</A></H1>
<P>
gems - Graphic Gems - Graphic Support Methods

<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<P>
value=<STRONG>BesselOrderOne</STRONG>(x)

<P>
<STRONG>GenerateNoise</STRONG>(pixel,noise_type)

<P>
<STRONG>HSLTransform</STRONG>(hue,saturation,luminosity,red,green,blue)

<P>
<STRONG>Hull</STRONG>(x_offset,y_offset,polarity,columns,rows,f,g)

<P>
opacity=<STRONG>InsidePrimitive</STRONG>(primitive_info,annotate_info,target,image)

<P>
<STRONG>InterpolateColor</STRONG>(image,x_offset,y_offset)

<P>
<STRONG>TransformHSL</STRONG>(red,green,blue,hue,saturation,luminosity)

<P>
<STRONG>Upsample</STRONG>(width,height,scaled_width,pixels)

<P>
<HR>
<H1><A NAME="FUNCTION_DESCRIPTIONS">FUNCTION DESCRIPTIONS</A></H1>
<P>
<HR>
<H2><A NAME="BesselOrderOne">BesselOrderOne</A></H2>
<P>
Method BesselOrderOne computes the Bessel function of x of the first kind
of order 0:

<P>
<PRE>  Reduce x to |x| since j1(x)= -j1(-x), and for x in (0,8]
</PRE>
<P>
<PRE>     j1(x) = x*j1(x);
</PRE>
<P>
<PRE>  For x in (8,inf)
</PRE>
<P>
<PRE>     j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
</PRE>
<P>
<PRE>  where x1 = x-3*pi/4. Compute sin(x1) and cos(x1) as follow:
</PRE>
<P>
<PRE>     cos(x1) =  cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
</PRE>
<P>
<PRE>             =  1/sqrt(2) * (sin(x) - cos(x))
</PRE>
<P>
<PRE>     sin(x1) =  sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
</PRE>
<P>
<PRE>             = -1/sqrt(2) * (sin(x) + cos(x))
</PRE>
<P>
The format of the BesselOrderOne routine is:

<P>
<PRE>        value=BesselOrderOne(x)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG><A NAME="item_o">value:</A></STRONG><DD>
<P>
Method BesselOrderOne returns the Bessel function of x of the first kind of
orders 1.

<DT><STRONG>x:</STRONG><DD>
<P>
double value.

</DL></DL>
<P>
<HR>
<H2><A NAME="Constrast">Constrast</A></H2>
<P>
Method Contrast enhances the intensity differences between the lighter and
darker elements of the image.

<P>
The format of the Contrast routine is:

<P>
<PRE>    Contrast(sign,red,green,blue)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>sign:</STRONG><DD>
<P>
A positive value enhances the contrast otherwise it is reduced.

<DT><STRONG>red, green, blue:</STRONG><DD>
<P>
A pointer to a pixel component of type Quantum.

</DL></DL>
<P>
<HR>
<H2><A NAME="GenerateNoise">GenerateNoise</A></H2>
<P>
Method GenerateNoise adds noise to a pixel.

<P>
The format of the GenerateNoise routine is:

<P>
<PRE>        GenerateNoise(pixel,noise_type)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>pixel:</STRONG><DD>
<P>
A structure of type Quantum.

<DT><STRONG>noise_type:</STRONG><DD>
<P>
The type of noise: Gaussian, multiplicative Gaussian, impulse, laplacian,
or Poisson.

</DL></DL>
<P>
<HR>
<H2><A NAME="HSLTransform">HSLTransform</A></H2>
<P>
Method HSLTransform converts a (hue, saturation, luminosity) to a (red,
green, blue) triple.

<P>
The format of the HSLTransformImage routine is:

<P>
<PRE>        HSLTransform(hue,saturation,luminosity,red,green,blue)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>hue, saturation, luminosity:</STRONG><DD>
<P>
A double value representing a component of the HSL color space.

<DT><STRONG>red, green, blue:</STRONG><DD>
<P>
A pointer to a pixel component of type Quantum.

</DL></DL>
<P>
<HR>
<H2><A NAME="Hull">Hull</A></H2>
<P>
Method Hull implements the eight hull algorithm described in Applied
Optics, Vol. 24, No. 10, 15 May 1985, ``Geometric filter for Speckle
Reduction'', by Thomas R Crimmins. Each pixel in the image is replaced by
one of its eight of its surrounding pixels using a polarity and negative
hull function.

<P>
The format of the Hull routine is:

<P>
<PRE>        Hull(x_offset,y_offset,polarity,columns,rows,f,g)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>x_offset, y_offset:</STRONG><DD>
<P>
An integer value representing the offset of the current pixel within the
image.

<DT><STRONG>polarity:</STRONG><DD>
<P>
An integer value declaring the polarity (+,-).

<DT><STRONG>columns, rows:</STRONG><DD>
<P>
Specifies the number of rows and columns in the image.

<DT><STRONG>f, g:</STRONG><DD>
<P>
A pointer to an image pixel and one of it's neighbor.

</DL></DL>
<P>
<HR>
<H2><A NAME="InsidePrimitive">InsidePrimitive</A></H2>
<P>
Method InsidePrimitive returns the opacity of the pen at the (x,y) position
of the image. The opacity is Opaque if the (x,y) position is within the
primitive as defined in primitive_info. A value less than fully opaque and
greater than fully transparent is returned for a primitive edge pixel to
allow for anti-aliasing. Otherwise fully transparent is returned.

<P>
Rick Mabry provided the algorithms for anti-aliased primitives.

<P>
The format of the InsidePrimitive routine is:

<P>
<PRE>        opacity=InsidePrimitive(primitive_info,annotate_info,target,image)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>opacity:</STRONG><DD>
<P>
Method InsidePrimitive returns a pen opacity associated with the (x,y)
position of the image.

<DT><STRONG>primitive_info:</STRONG><DD>
<P>
Specifies a pointer to a PrimitiveInfo structure.

<DT><STRONG>annotate_info:</STRONG><DD>
<P>
Specifies a pointer to a AnnotateInfo structure.

<DT><STRONG>target:</STRONG><DD>
<P>
PointInfo representing the (x,y) location in the image.

<DT><STRONG>image:</STRONG><DD>
<P>
The address of a structure of type Image.

</DL></DL>
<P>
<HR>
<H2><A NAME="InterpolateColor">InterpolateColor</A></H2>
<P>
Method InterpolateColor applies bi-linear interpolation between a pixel and
it's neighbors.

<P>
The format of the InterpolateColor routine is:

<P>
<PRE>        InterpolateColor(image,x_offset,y_offset)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>image:</STRONG><DD>
<P>
The address of a structure of type Image.

<DT><STRONG>x_offset,y_offset:</STRONG><DD>
<P>
A double representing the current (x,y) position of the pixel.

</DL></DL>
<P>
<HR>
<H2><A NAME="Modulate">Modulate</A></H2>
<P>
Method Modulate modulates the hue, saturation, and brightness of an image.

<P>
The format of the ModulateImage routine is:

<P>
<PRE>    Modulate(percent_hue,percent_saturation,percent_brightness,red,green,
</PRE>
<P>
<PRE>      blue)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>percent_hue, percent_saturation, percent_brightness:</STRONG><DD>
<P>
A double value representing the percent change in a component of the HSL
color space.

<DT><STRONG>red, green, blue:</STRONG><DD>
<P>
A pointer to a pixel component of type Quantum.

</DL></DL>
<P>
<HR>
<H2><A NAME="TransformHSL">TransformHSL</A></H2>
<P>
Method TransformHSL converts a (red, green, blue) to a (hue, saturation,
luminosity) triple.

<P>
The format of the TransformHSL routine is:

<P>
<PRE>        TransformHSL(red,green,blue,hue,saturation,luminosity)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>red, green, blue:</STRONG><DD>
<P>
A Quantum value representing the red, green, and blue component of a
pixel..

<DT><STRONG>hue, saturation, luminosity:</STRONG><DD>
<P>
A pointer to a double value representing a component of the HSL color
space.

</DL></DL>
<P>
<HR>
<H2><A NAME="Upsample">Upsample</A></H2>
<P>
Method Upsample doubles the size of the image.

<P>
The format of the UpSample routine is:

<P>
<PRE>        Upsample(width,height,scaled_width,pixels)
</PRE>
<P>
A description of each parameter follows:

<DL><DL>
<DT><STRONG>width,height:</STRONG><DD>
<P>
Unsigned values representing the width and height of the image pixel array.

<DT><STRONG>scaled_width:</STRONG><DD>
<P>
Specifies the final width of the upsampled pixel array.

<DT><STRONG>pixels:</STRONG><DD>
<P>
An unsigned char containing the pixel data. On output the upsampled pixels
are returned here.

</DL></DL>
</BODY>

</HTML>
