core.image
Class AccumImage

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

public class AccumImage
extends ScalarImage

Stores a monochrome float image with alpha = < width, height, float-buffer, alpha-buffer, minalpha, coverage >. An AccumImage extends ScalarImage to include an alpha component for every scalar value. The alpha values are pre-multiplied into the scalar, so to obtain the scalar value at a pixel, the alpha must be divided out of it. This sort of image is useful for accumulation operations. Each AccumImage also automatically maintains information about the coverage of the image. Every time a pixel surpasses the "minalpha" requirement, "coverage" is incremented to indicated the total count of such pixels.

Version:
1.0
Author:
Andreas Sundquist

Field Summary
 float[] a
          a[] stores all the alpha values for the corresponding array f[]
 int coverage
          coverage indicates the number of pixels whose alpha exceeds "minalpha"
 double minalpha
          minalpha defines the minimum alpha required for a pixel to be "covered"
 
Fields inherited from class core.image.ScalarImage
f, height, offset, size, width
 
Constructor Summary
AccumImage(int width, int height)
          Constructs a new AccumImage = < width, height, zero-buffer, zero-buffer, 1.0, 0 >
 
Method Summary
 void Accumulate(int x, int y, double s)
          Adds "s" to the scalar value at (x, y) and increments the corresponding alpha value.
 void Accumulate(int x, int y, double s, double sa)
          Adds "s" and "sa" to the scalar and alpha values at (x, y) if it is in-bounds.
 void AccumulateBilinear(double x, double y, double s)
          Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate (x, y), weighting the alpha accumulation bilinearly as well.
 void AccumulateBilinear(Vec2 v, double s)
          Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate "v", weighting the alpha accumulation bilinearly as well.
 void Clear()
          Clears both the scalar and alpha components in "this"
 void Copy(AccumImage image)
          Copies the scalar and alpha values from the top-left corner of "image" to "this" Requires: "image" is at least as large as "this"
 void Copy(AccumImage image, int xorigin, int yorigin)
          Copies the scalar and alpha values from the sub-window of "image" starting at (xorigin, yorigin) to "this".
 double get(int x, int y)
          Returns: the value at (x, y) with the alpha divided out Requires: 0<=x
 double getAlpha(int x, int y)
          Returns: the alpha value at (x, y) Requires: 0<=x
 boolean hasSingularity()
          Returns: true if an scalar or alpha value in "this" is invalid
 void Normalize()
          Divides out the alpha component in "this", renormalizing it to 1.0
 void Normalize(int x, int y)
          Divides out the alpha component at coordinate (x, y) in "this", renormalizing it to 1.0 Requires: 0<=x
 void Set(int x, int y, double s, double sa)
          Sets the scalar and alpha value at (x, y) to (s, sa).
 void SetAlpha()
          Sets the scalar component of "this" to the alpha component
 void SetZero()
          Sets the samples in "this" to zero, with an alpha of 1.0
 
Methods inherited from class core.image.ScalarImage
Add, Clamp, Convolve3x3, Copy, Copy, getBilinear, getBilinear, inBounds, inBounds, inBounds, Modulate, Power, Rescale, Set, SetRandom, SetRandom, StretchBilinear, Vec2FieldMagnitude, Vec2FieldZero
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

public float[] a
a[] stores all the alpha values for the corresponding array f[]


minalpha

public double minalpha
minalpha defines the minimum alpha required for a pixel to be "covered"


coverage

public int coverage
coverage indicates the number of pixels whose alpha exceeds "minalpha"

Constructor Detail

AccumImage

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

Method Detail

SetZero

public void SetZero()
Sets the samples in "this" to zero, with an alpha of 1.0

Overrides:
SetZero in class ScalarImage

Clear

public void Clear()
Clears both the scalar and alpha components in "this"

Overrides:
Clear in class ScalarImage

SetAlpha

public void SetAlpha()
Sets the scalar component of "this" to the alpha component


Copy

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


Copy

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


Normalize

public void Normalize()
Divides out the alpha component in "this", renormalizing it to 1.0


Normalize

public void Normalize(int x,
                      int y)
Divides out the alpha component at coordinate (x, y) in "this", renormalizing it to 1.0 Requires: 0<=x

get

public double get(int x,
                  int y)
Returns: the value at (x, y) with the alpha divided out Requires: 0<=x
Overrides:
get in class ScalarImage

getAlpha

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

Set

public void Set(int x,
                int y,
                double s,
                double sa)
Sets the scalar and alpha value at (x, y) to (s, sa). If (x, y) is out-of-bounds, this has no effect.


Accumulate

public void Accumulate(int x,
                       int y,
                       double s)
Adds "s" to the scalar value at (x, y) and increments the corresponding alpha value. If (x, y) is out-of-bounds, it has no effect.

Overrides:
Accumulate in class ScalarImage

Accumulate

public void Accumulate(int x,
                       int y,
                       double s,
                       double sa)
Adds "s" and "sa" to the scalar and alpha values at (x, y) if it is in-bounds.


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), weighting the alpha accumulation bilinearly as well.

Overrides:
AccumulateBilinear in class ScalarImage

AccumulateBilinear

public void AccumulateBilinear(Vec2 v,
                               double s)
Bilinearly accumulates "s" to the four integer grid points surrounding the continuous coordinate "v", weighting the alpha accumulation bilinearly as well.

Overrides:
AccumulateBilinear in class ScalarImage

hasSingularity

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

Overrides:
hasSingularity in class ScalarImage