bitmaps
Class PDPixel

java.lang.Object
  extended by bitmaps.PDPixel

public class PDPixel
extends java.lang.Object

Provides a wrapper and functionality for pixels used in the Progressive Divisibility (Coltuc's) method. Functionality included checking for constraints against another pixel, embedding a value, extracting a correction value, etc.

We define the operations of transforming (consisting of transforming the pixel but NOT embedding a value), embedding (adding a value to a transformed pixel), and adjusting (determining, subtracting, and returning the appropriate (ci) value to make the pixel divisible). After transforming and embedding, a pixel is guaranteed to be NOT divisible.

TODO: Having separate xi() and yi() calls may be confusing.

Author:
Jonathan L Dautrich Jr.

Field Summary
private static boolean DEBUG
           
private  int n
           
private  boolean negativeValueCase
           
private  Pixel nextPixel
           
private  Pixel pixel
           
private  boolean transformed
          Transformed can be set during embedding when the pixel is actually transformed, or (perhaps) during decoding if a pixel is identified as having been transformed, though this may not be necessary.
 
Constructor Summary
PDPixel(Pixel pixel, Pixel nextPixel, int n)
           
 
Method Summary
 int adjust()
          Should only be called on a pixel that cannot be transformed.
 void embed(int toEmbed)
          Should only be done after a pixel has been transformed.
 int invert()
          Extracts the value embedded in the pixel and inverts the transform to restore the original pixel value.
 boolean isDivisible()
          Checks condition for divisibility by (n+1).
 boolean isNegativeValueCase()
          Indicates whether the negative value case has occurred during adjustment.
 boolean isTransformable()
          Checks constraints for transformability and embeddability.
 boolean isTransformed(boolean embedding)
          If the call is made during the encoding phase, indicates whether this pixel has already been transformed.
 boolean isUnderThreshold()
          Returns true if the current pixel is at/under the threshold for special handling due to the negative value case.
 void reduceValue()
          Reduces the pixel value by (n+1).
 void restore(int ci)
          Restores the pixel value by adding the appropriate (ci) value back in.
 java.lang.String toString()
           
 void transform()
          Transforms the pixel.
private  int xi()
          Returns the integer value of the current pixel intensity.
private  int xi1()
          Returns the integer value of the next pixel intensity.
private  int yi()
          Returns the integer value of the current pixel intensity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

pixel

private final Pixel pixel

nextPixel

private final Pixel nextPixel

n

private final int n

negativeValueCase

private boolean negativeValueCase

transformed

private boolean transformed
Transformed can be set during embedding when the pixel is actually transformed, or (perhaps) during decoding if a pixel is identified as having been transformed, though this may not be necessary.

It is probably only relevant during the embedding phase, and thus is given a default value of false.

If a pixel does not get transformed, it will be adjusted instead.

Constructor Detail

PDPixel

public PDPixel(Pixel pixel,
               Pixel nextPixel,
               int n)
Method Detail

isTransformable

public boolean isTransformable()
Checks constraints for transformability and embeddability. Must be able to embed anything from 1 (0?) through n. Note: This checks on whether the pixel is transformable AND embeddable.

Returns:

isDivisible

public boolean isDivisible()
Checks condition for divisibility by (n+1). (Checks for value + n*(nextValue+1) congruent to 0 (mod (n+1))) The pixel is divisible if and only if it has been adjusted (and thus NOT transformed).

Returns:

transform

public void transform()
Transforms the pixel.


embed

public void embed(int toEmbed)
Should only be done after a pixel has been transformed. Call isTransformed(true) to check.


invert

public int invert()
Extracts the value embedded in the pixel and inverts the transform to restore the original pixel value. Should be called on pixels that had previously been transformed. Call isTransformed(false) to check.

Returns:

adjust

public int adjust()
Should only be called on a pixel that cannot be transformed. Subtracts a number (ci) as appropriate to make xi + n*xi1 divisible by (n+1).

Returns:
The number (ci) that had to be subtracted from xi + n*xi1 to make it divisible by (n+1). Should be in [0, n].

restore

public void restore(int ci)
Restores the pixel value by adding the appropriate (ci) value back in. To be used to restore pixels that have been adjusted. To restore the original value of a pixel that has been transformed/embedded, use invert().

Parameters:
ci -

isTransformed

public boolean isTransformed(boolean embedding)
If the call is made during the encoding phase, indicates whether this pixel has already been transformed. If made during the decoding phase, indicates whether this pixel's divisibility indicates that it was transformed previously. That is, returns !isDivisible().

Parameters:
embedding - true if check is made during encoding phase, false if made during decoding phase
Returns:

isNegativeValueCase

public boolean isNegativeValueCase()
Indicates whether the negative value case has occurred during adjustment. See notes for the adjust() method.

Returns:

xi

private int xi()
Returns the integer value of the current pixel intensity. Used when current pixel holds an original value. Functionally equivalent to yi().

Returns:

yi

private int yi()
Returns the integer value of the current pixel intensity. Used when current pixel holds a modified/transformed value. Functionally equivalent to xi().

Returns:

xi1

private int xi1()
Returns the integer value of the next pixel intensity.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isUnderThreshold

public boolean isUnderThreshold()
Returns true if the current pixel is at/under the threshold for special handling due to the negative value case. See adjust().

Returns:

reduceValue

public void reduceValue()
Reduces the pixel value by (n+1). Used during decoding when the negative value case has been observed. See adjust().