All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.jhlabs.image.ImageMath

java.lang.Object
   |
   +----com.jhlabs.image.ImageMath

public class ImageMath
extends java.lang.Object
A class containing static math methods useful for image processing.


Constructor Index

 o ImageMath()

Method Index

 o bias(double, double)
Apply a bias to a number in the unit interval, moving numbers towards 0 or 1 according to the bias parameter.
 o bilinearInterpolate(double, double, int[])
Bilinear interpolation of ARGB values.
 o brightnessNTSC(int)
Return the NTSC gray level of an RGB value.
 o circleDown(double)
A "circle down" function.
 o circleUp(double)
A "circle up" function.
 o clamp(double, double, double)
Clamp a value to an interval.
 o clamp(int, int, int)
Clamp a value to an interval.
 o colorSpline(double, int, int[])
Compute a Catmull-Rom spline for RGB values.
 o colorSpline(int, int, int[], int[])
Compute a Catmull-Rom spline for RGB values, but with variable knot spacing.
 o gain(double, double)
A variant of the gamma function.
 o lerp(double, double, double)
Linear interpolation.
 o lerp(double, int, int)
Linear interpolation.
 o mixColors(double, int, int)
Linear interpolation of ARGB values.
 o mod(double, double)
Return a mod b.
 o mod(int, int)
Return a mod b.
 o pulse(double, double, double)
The pulse function.
 o resample(int[], int[], int, int, int, float[])
An implementation of Fant's resampling algorithm.
 o smoothPulse(double, double, double, double, double)
A smoothed pulse function.
 o smoothStep(double, double, double)
A smoothed step function.
 o spline(double, int, double[])
Compute a Catmull-Rom spline.
 o spline(double, int, int[], int[])
Compute a Catmull-Rom spline, but with variable knot spacing.
 o step(double, double)
The step function.
 o triangle(double)
The triangle function.

Constructors

 o ImageMath
 public ImageMath()

Methods

 o bias
 public static double bias(double a,
                           double b)
Apply a bias to a number in the unit interval, moving numbers towards 0 or 1 according to the bias parameter.

Parameters:
a - the number to bias
b - the bias parameter. 0.5 means no change, smaller values bias towards 0, larger towards 1.
Returns:
the output value
 o gain
 public static double gain(double a,
                           double b)
A variant of the gamma function.

Parameters:
a - the number to apply gain to
b - the gain parameter. 0.5 means no change, smaller values reduce gain, larger values increase gain.
Returns:
the output value
 o step
 public static double step(double a,
                           double x)
The step function. Returns 0 below a threshold, 1 above.

Parameters:
a - the threshold position
x - the input parameter
Returns:
the output value - 0 or 1
 o pulse
 public static double pulse(double a,
                            double b,
                            double x)
The pulse function. Returns 1 between two thresholds, 0 outside.

Parameters:
a - the lower threshold position
b - the upper threshold position
x - the input parameter
Returns:
the output value - 0 or 1
 o smoothPulse
 public static double smoothPulse(double a1,
                                  double a2,
                                  double b1,
                                  double b2,
                                  double x)
A smoothed pulse function. A cubic function is used to smooth the step between two thresholds.

Parameters:
a1 - the lower threshold position for the start of the pulse
a2 - the upper threshold position for the start of the pulse
b1 - the lower threshold position for the end of the pulse
b2 - the upper threshold position for the end of the pulse
x - the input parameter
Returns:
the output value
 o smoothStep
 public static double smoothStep(double a,
                                 double b,
                                 double x)
A smoothed step function. A cubic function is used to smooth the step between two thresholds.

Parameters:
a - the lower threshold position
b - the upper threshold position
x - the input parameter
Returns:
the output value
 o circleUp
 public static double circleUp(double x)
A "circle up" function. Returns y on a unit circle given 1-x. Useful for forming bevels.

Parameters:
x - the input parameter in the range 0..1
Returns:
the output value
 o circleDown
 public static double circleDown(double x)
A "circle down" function. Returns 1-y on a unit circle given x. Useful for forming bevels.

Parameters:
x - the input parameter in the range 0..1
Returns:
the output value
 o clamp
 public static double clamp(double x,
                            double a,
                            double b)
Clamp a value to an interval.

Parameters:
a - the lower clamp threshold
b - the upper clamp threshold
x - the input parameter
Returns:
the clamped value
 o clamp
 public static int clamp(int x,
                         int a,
                         int b)
Clamp a value to an interval.

Parameters:
a - the lower clamp threshold
b - the upper clamp threshold
x - the input parameter
Returns:
the clamped value
 o mod
 public static double mod(double a,
                          double b)
Return a mod b. This differs from the % operator with respect to negative numbers.

Parameters:
a - the dividend
b - the divisor
Returns:
a mod b
 o mod
 public static int mod(int a,
                       int b)
Return a mod b. This differs from the % operator with respect to negative numbers.

Parameters:
a - the dividend
b - the divisor
Returns:
a mod b
 o triangle
 public static double triangle(double x)
The triangle function. Returns a repeating triangle shape in the range 0..1 with wavelength 1.0

Parameters:
x - the input parameter
Returns:
the output value
 o lerp
 public static double lerp(double t,
                           double a,
                           double b)
Linear interpolation.

Parameters:
t - the interpolation parameter
a - the lower interpolation range
b - the upper interpolation range
Returns:
the interpolated value
 o lerp
 public static int lerp(double t,
                        int a,
                        int b)
Linear interpolation.

Parameters:
t - the interpolation parameter
a - the lower interpolation range
b - the upper interpolation range
Returns:
the interpolated value
 o mixColors
 public static int mixColors(double t,
                             int rgb1,
                             int rgb2)
Linear interpolation of ARGB values.

Parameters:
t - the interpolation parameter
rgb1 - the lower interpolation range
rgb2 - the upper interpolation range
Returns:
the interpolated value
 o bilinearInterpolate
 public static int bilinearInterpolate(double x,
                                       double y,
                                       int p[])
Bilinear interpolation of ARGB values.

Parameters:
x - the X interpolation parameter 0..1
y - the y interpolation parameter 0..1
rgb - array of four ARGB values in the order NW, NE, SW, SE
Returns:
the interpolated value
 o brightnessNTSC
 public static int brightnessNTSC(int rgb)
Return the NTSC gray level of an RGB value.

Parameters:
rgb1 - the input pixel
Returns:
the gray level (0-255)
 o spline
 public static double spline(double x,
                             int numKnots,
                             double knots[])
Compute a Catmull-Rom spline.

Parameters:
x - the input parameter
numKnots - the number of knots in the spline
knots - the array of knots
Returns:
the spline value
 o spline
 public static double spline(double x,
                             int numKnots,
                             int xknots[],
                             int yknots[])
Compute a Catmull-Rom spline, but with variable knot spacing.

Parameters:
x - the input parameter
numKnots - the number of knots in the spline
xknots - the array of knot x values
yknots - the array of knot y values
Returns:
the spline value
 o colorSpline
 public static int colorSpline(double x,
                               int numKnots,
                               int knots[])
Compute a Catmull-Rom spline for RGB values.

Parameters:
x - the input parameter
numKnots - the number of knots in the spline
knots - the array of knots
Returns:
the spline value
 o colorSpline
 public static int colorSpline(int x,
                               int numKnots,
                               int xknots[],
                               int yknots[])
Compute a Catmull-Rom spline for RGB values, but with variable knot spacing.

Parameters:
x - the input parameter
numKnots - the number of knots in the spline
xknots - the array of knot x values
yknots - the array of knot y values
Returns:
the spline value
 o resample
 public static void resample(int source[],
                             int dest[],
                             int length,
                             int offset,
                             int stride,
                             float out[])
An implementation of Fant's resampling algorithm.

Parameters:
source - the source pixels
dest - the destination pixels
length - the length of the scanline to resample
offset - the start offset into the arrays
stride - the offset between pixels in consecutive rows
out - an array of output positions for each pixel

All Packages  Class Hierarchy  This Package  Previous  Next  Index