core.image
Class ScalarImage

java.lang.Object
  extended bycore.image.ScalarImage
Direct Known Subclasses:
AccumImage

public class ScalarImage
extends java.lang.Object

Stores a monochrome image of floats = < width, height, float-buffer >. A ScalarImage stores a rectangular array of scalar values. The image"s width and height are specified upon construction, and a float-buffer is created of size width*height, storing the data in left-right, top-down scanline order. Though the scalar data is stored internally as floats to save space, they are accessed as doubles for compatibility. The ScalarImage can also be viewed as a continuous field over a rectangle, with the value at integer coordinates equal to the scalar values, and the values at fractional coordinates interpolated between them. Since the values are interpolated, the effective size of the field becomes (width-1) by (height-1).

Version:
1.0
Author:
Andreas Sundquist

Field Summary
 float[] f
          f[] stores all the scalar values in scanline order
 int height
          width, height store the dimensions of the image.
 int[] offset
          offset[] indexes the left-most pixel of each scanline in f[] The index of pixel (x,y) is therefore offset[y]+x
 int size
          width, height store the dimensions of the image.
 int width
          width, height store the dimensions of the image.
 
Constructor Summary
ScalarImage(int width, int height)
          Constructs a new ScalarImage = < width, height, zero-buffer >
 
Method Summary
 void Accumulate(int x, int y, double s)
          Adds "s" to the scalar value at (x, y).
 void AccumulateBilinear(double x, double y, double s)
          Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate (x, y).
 void AccumulateBilinear(Vec2 v, double s)
          Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate "v".
 void Add(ScalarImage image)
           
 void Clamp(double min, double max)
           
 void Clear()
          Clears all the scalar values to zero.
 void Convolve3x3(double[] kernel)
          Performs a convolution on "this" with a 3x3 kernel and scalar offset.
 void Copy(ScalarImage image)
          Copies the scalar values from the top-left corner of "image" to "this" Requires: "image" is at least as large as "this"
 void Copy(ScalarImage image, int xorigin, int yorigin)
          Copies the scalar values from the sub-window of "image" starting at (xorigin, yorigin) to "this".
 double get(int x, int y)
          Returns: the scalar value at (x, y) Requires: 0<=x
 double getBilinear(double x, double y)
          Returns: the bilinearly-interpolated value of the continuous field at (x, y).
 double getBilinear(Vec2 v)
          Returns: the bilinearly-interpolated value of the continuous field at "v".
 boolean hasSingularity()
          Returns: true if any scalar value in "this" is invalid
 boolean inBounds(double x, double y)
          Returns: true if 0.0<=x<=(width-1.0) and 0.0<=y<=(height-1.0), false otherwise, the domain check for when "this" is viewed as a continuous field.
 boolean inBounds(int x, int y)
          Returns: true if 0<=x
 boolean inBounds(Vec2 v)
          Returns: true if "v" is within the domain of "this" when viewed as a continuous field.
 void Modulate(ScalarImage image)
           
 void Power(double exp)
          Transforms all the scalar values in "this" by the rule: f" = f^exp
 void Rescale(double scale, double add)
          Rescales all the scalar values in "this" by the rule: f" = f*scale + add
 void Set(int x, int y, double s)
          Sets the scalar value at (x, y) to "s".
 void SetRandom()
          Sets all the scalars in "this" to random values uniformly distributed over (0.0, 1.0).
 void SetRandom(java.util.Random random)
          Sets all the scalars in "this" to random values uniformly distributed over (0.0, 1.0) using the pseudo-random generator "random".
 void SetZero()
          Sets all the scalar values to zero
 void StretchBilinear(ScalarImage image)
          Rescales the scalar data in "image" to "this" using bilinear interpolation.
 void Vec2FieldMagnitude(Vec2Field field, Vec2Transform ftoi)
           
 void Vec2FieldZero(Vec2Field field, Vec2Transform ftoi)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

public final int width
width, height store the dimensions of the image. size = width*height, the number of scalar values


height

public final int height
width, height store the dimensions of the image. size = width*height, the number of scalar values


size

public final int size
width, height store the dimensions of the image. size = width*height, the number of scalar values


f

public float[] f
f[] stores all the scalar values in scanline order


offset

public final int[] offset
offset[] indexes the left-most pixel of each scanline in f[] The index of pixel (x,y) is therefore offset[y]+x

Constructor Detail

ScalarImage

public ScalarImage(int width,
                   int height)
Constructs a new ScalarImage = < width, height, zero-buffer >

Method Detail

SetZero

public void SetZero()
Sets all the scalar values to zero


Clear

public void Clear()
Clears all the scalar values to zero. This is different from SetZero() in the derived classes AccumImage, etc


Copy

public void Copy(ScalarImage image,
                 int xorigin,
                 int yorigin)
Copies the scalar values from the sub-window of "image" starting at (xorigin, yorigin) to "this". Requires: the sub-window fits inside "image"


Copy

public void Copy(ScalarImage image)
Copies the scalar values from the top-left corner of "image" to "this" Requires: "image" is at least as large as "this"


StretchBilinear

public void StretchBilinear(ScalarImage image)
Rescales the scalar data in "image" to "this" using bilinear interpolation.


inBounds

public boolean inBounds(int x,
                        int y)
Returns: true if 0<=x

inBounds

public boolean inBounds(double x,
                        double y)
Returns: true if 0.0<=x<=(width-1.0) and 0.0<=y<=(height-1.0), false otherwise, the domain check for when "this" is viewed as a continuous field.


inBounds

public boolean inBounds(Vec2 v)
Returns: true if "v" is within the domain of "this" when viewed as a continuous field.


get

public double get(int x,
                  int y)
Returns: the scalar value at (x, y) Requires: 0<=x

Set

public void Set(int x,
                int y,
                double s)
Sets the scalar value at (x, y) to "s". If it is outside the domain of "this", it has no effect.


Accumulate

public void Accumulate(int x,
                       int y,
                       double s)
Adds "s" to the scalar value at (x, y). If it is outside the domain of "this", it has no effect.


getBilinear

public double getBilinear(double x,
                          double y)
Returns: the bilinearly-interpolated value of the continuous field at (x, y). Requires: (x, y) is inside the domain of the field


getBilinear

public double getBilinear(Vec2 v)
Returns: the bilinearly-interpolated value of the continuous field at "v". Requires: "v" is inside the domain of the field


AccumulateBilinear

public void AccumulateBilinear(double x,
                               double y,
                               double s)
Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate (x, y).


AccumulateBilinear

public void AccumulateBilinear(Vec2 v,
                               double s)
Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate "v".


Rescale

public void Rescale(double scale,
                    double add)
Rescales all the scalar values in "this" by the rule: f" = f*scale + add


Power

public void Power(double exp)
Transforms all the scalar values in "this" by the rule: f" = f^exp


Convolve3x3

public void Convolve3x3(double[] kernel)
Performs a convolution on "this" with a 3x3 kernel and scalar offset. kernel is of type double[10], and the convolution computed is of the form: out(i,j) = c0 + c1*out(i-1,j-1) + c2*out( i ,j-1) + c3*out(i+1,j-1) + c4*out(i-1, j ) + c5*out( i , j ) + c6*out(i+1, j ) + c7*out(i-1,j+1) + c8*out( i ,j+1) + c9*out(i+1,j+1), where ci = kernel[i]


hasSingularity

public boolean hasSingularity()
Returns: true if any scalar value in "this" is invalid


SetRandom

public void SetRandom(java.util.Random random)
Sets all the scalars in "this" to random values uniformly distributed over (0.0, 1.0) using the pseudo-random generator "random".


SetRandom

public void SetRandom()
Sets all the scalars in "this" to random values uniformly distributed over (0.0, 1.0).


Vec2FieldMagnitude

public void Vec2FieldMagnitude(Vec2Field field,
                               Vec2Transform ftoi)

Vec2FieldZero

public void Vec2FieldZero(Vec2Field field,
                          Vec2Transform ftoi)

Modulate

public void Modulate(ScalarImage image)

Add

public void Add(ScalarImage image)

Clamp

public void Clamp(double min,
                  double max)