core.image
Class Accum2Image

java.lang.Object
  extended bycore.image.ScalarImage
      extended bycore.image.AccumImage
          extended bycore.image.Accum2Image

public class Accum2Image
extends AccumImage

Stores a float image with alpha^2 = < width, height, float-buffer, alpha-buffer, minalpha, coverage >. An Accum2Image extends AccumImage so that the samples contribute in a such a way that the output variance is normalized. The float channel stores the sample sum with the alpha premultiplied, and the alpha channel stores the sum of the squares of the alpha amounts. This way, computing the final sample value is simple: sample = Sum(s[i]*sa[i])/Sqrt(Sum(sa[i]^2)) = f/Sqrt(a) If the samples accumulated have a Gaussian distribution, the final sample will have the same distribution.

Version:
1.0
Author:
Andreas Sundquist

Field Summary
 
Fields inherited from class core.image.AccumImage
a, coverage, minalpha
 
Fields inherited from class core.image.ScalarImage
f, height, offset, size, width
 
Constructor Summary
Accum2Image(int width, int height)
          Constructs a new Accum2Image = < width, height, zero-buffer, zero-buffer, 1.0, 0 >
 
Method Summary
 void Accumulate(int x, int y, double s, double sa)
          Adds "s" and "sa"^2 to the scalar and alpha values at (x, y) if it is in-bounds.
 void Clear()
          Clears both the scalar and alpha components in "this"
 double get(int x, int y)
          Returns: the value at (x, y) with the alpha divided out.
 void Normalize()
          Divides out the alpha component in "this", renormalizing it to 1.0.
 void Normalize(int x, int y)
          Normalize the alpha value of a particular pixel, dividing out the square root of the alpha channel.
 void Set(int x, int y, double s, double sa)
          Sets the scalar and alpha value at (x, y) to (s, sa^2).
 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.AccumImage
Accumulate, AccumulateBilinear, AccumulateBilinear, Copy, Copy, getAlpha, hasSingularity
 
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
 

Constructor Detail

Accum2Image

public Accum2Image(int width,
                   int height)
Constructs a new Accum2Image = < 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 AccumImage

Clear

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

Overrides:
Clear in class AccumImage

SetAlpha

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

Overrides:
SetAlpha in class AccumImage

Normalize

public void Normalize()
Divides out the alpha component in "this", renormalizing it to 1.0. Since the alpha channel stores the sum of the squares of the alphas, we actually divide out the square root of the alpha value.

Overrides:
Normalize in class AccumImage

Normalize

public void Normalize(int x,
                      int y)
Normalize the alpha value of a particular pixel, dividing out the square root of the alpha channel.

Overrides:
Normalize in class AccumImage

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 AccumImage

Set

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

Overrides:
Set in class AccumImage

Accumulate

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

Overrides:
Accumulate in class AccumImage