coders
Class Encoder

java.lang.Object
  extended by coders.Encoder
Direct Known Subclasses:
DifferenceExpansionEncoder, ProgressiveDivisibilityEncoder

public abstract class Encoder
extends java.lang.Object

Author:
Jonathan L Dautrich Jr.

Field Summary
protected  boolean encoded
          Indicates whether the encode operation has been executed.
protected  Bitmap encodedBitmap
           
private  double mse
          Mean Squared Error.
protected  Bitmap originalBitmap
           
protected  BitSequence payload
           
protected  double psnr
           
protected  boolean psnrComputed
          Indicates whether the PSNR (peak signal-to-noise ratio) has been computed for this encoding.
 
Constructor Summary
Encoder(Bitmap originalBitmap, BitSequence payload)
          Initializes this encoder with the specified bitmap.
 
Method Summary
 double computePSNR()
          Computes and returns the PSNR (peak signal-to-noise ratio) for the current encoding.
protected abstract  void encode()
          Encodes the current bitmap.
 Bitmap getEncodedBitmap()
          Returns the encoded bitmap produced by this encoder, running the encode operation first if necessary.
 Bitmap getOriginalBitmap()
          Returns the original bitmap used as the basis for encoding.
 BitSequence getPayload()
          Retrieves the payload being encoded in the bitmap by this encoder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

originalBitmap

protected Bitmap originalBitmap

encodedBitmap

protected Bitmap encodedBitmap

payload

protected BitSequence payload

encoded

protected boolean encoded
Indicates whether the encode operation has been executed. If it has, the restored bitmap and the payload will be available for retrieval, and decode may not be executed again.


psnrComputed

protected boolean psnrComputed
Indicates whether the PSNR (peak signal-to-noise ratio) has been computed for this encoding. Encoding operation must occur before PSNR can be computed.


psnr

protected double psnr

mse

private double mse
Mean Squared Error. Used for computing PSNR.

Constructor Detail

Encoder

public Encoder(Bitmap originalBitmap,
               BitSequence payload)
Initializes this encoder with the specified bitmap. The originalBitmap should not be modified by the Encoder.

Parameters:
originalBitmap -
Method Detail

encode

protected abstract void encode()
Encodes the current bitmap. Should execute only if it has not already been called.


getOriginalBitmap

public Bitmap getOriginalBitmap()
Returns the original bitmap used as the basis for encoding.

Returns:

getEncodedBitmap

public Bitmap getEncodedBitmap()
Returns the encoded bitmap produced by this encoder, running the encode operation first if necessary.

Returns:

getPayload

public BitSequence getPayload()
Retrieves the payload being encoded in the bitmap by this encoder.

Returns:
the payload

computePSNR

public double computePSNR()
Computes and returns the PSNR (peak signal-to-noise ratio) for the current encoding. If the PSNR has already been computed, it will simply be returned. First invokes the encode operation if necessary. TODO: Currently only computes for the red (grayscale) pixel values.

Returns: