coders
Class DifferenceExpansionEncoder

java.lang.Object
  extended by coders.Encoder
      extended by coders.DifferenceExpansionEncoder

public class DifferenceExpansionEncoder
extends Encoder

Author:
Jonathan L Dautrich Jr.

Field Summary
private  int currLayer
          Indicates current layer being embedded.
(package private)  int forcedThreshold
           
private  int lastCapacity
           
private  int lastCompLocMapSize
           
private  int lastCompSelVectorSize
           
private  int lastSelVectorSize
           
private  DifferenceExpansionOptions options
           
private  BitIterator payloadIterator
           
private  int[] thresholdSet
           
private  int totalCapacity
           
(package private)  int XP0
           
(package private)  int XP1
           
 
Fields inherited from class coders.Encoder
encoded, encodedBitmap, originalBitmap, payload, psnr, psnrComputed
 
Constructor Summary
DifferenceExpansionEncoder(Bitmap originalBitmap, BitSequence payload, DifferenceExpansionOptions options)
          Parameters should include pixel pair selection method, scanning order, map compression parameter, etc.
 
Method Summary
private  void buildMapAndLSBStream(java.util.ArrayList<DEPixelPair> pairs, BitSequence locationMap, BitSequence lsbSequence, int threshold)
          Builds the location map by setting the bit at index corresponding to a pair that has been selected for expansion.
private  void buildSelectionVector(java.util.ArrayList<DEPixelPair> pairs, BitSequence selectionVector, BitSequence locationMap, int threshold)
          Builds the selection vector from the specified pairs, locationMap, and threshold value.
private  void embed(java.util.ArrayList<DEPixelPair> pairs, BitIterator mapIterator, BitSequence sequence)
          Embeds the specified sequence in the specified pixel pairs, moving through the pairs using the iterator to determine the index of embedding and what type of embedding (expansion or simple embedding) to perform for each pair.
private  boolean embedBit(java.util.ArrayList<DEPixelPair> pairs, BitIterator mapIterator, BitIterator sequenceIterator)
          Attempts to embed the next bit in sequenceIterator into pairs.
private  void embedPayload(java.util.ArrayList<DEPixelPair> pairs, BitIterator mapIterator)
          Embeds as much of the payload as possible into the remaining pairs, while still fitting the end-of-map sequence in at the end.
 void encode()
          Encodes the current bitmap.
 void encodeLayer(BitSequence payload)
          Encodes the specified payload in a layer of the image.
 void forceThreshold(int threshold)
          Forces the threshold to the specified value, disregards payload content size.
 void forceThresholdSet(int[] thresholdSet)
           
 int getLastCapacity()
           
 int getLastCompLocMapSize()
           
 int getLastCompSelVectorSize()
           
 int getLastSelVectorSize()
           
private  java.util.ArrayList<DEPixelPair> getPairs()
          Returns a complete ordered list of pixel pairs in an order specified by the construction parameters, for the current layer.
 int getTotalCapacity()
          Returns the total capacity achieved during the last encoding.
 
Methods inherited from class coders.Encoder
computePSNR, getEncodedBitmap, getOriginalBitmap, getPayload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

private DifferenceExpansionOptions options

totalCapacity

private int totalCapacity

payloadIterator

private BitIterator payloadIterator

lastCompLocMapSize

private int lastCompLocMapSize

lastSelVectorSize

private int lastSelVectorSize

lastCompSelVectorSize

private int lastCompSelVectorSize

lastCapacity

private int lastCapacity

currLayer

private int currLayer
Indicates current layer being embedded.


XP0

int XP0

XP1

int XP1

forcedThreshold

int forcedThreshold

thresholdSet

private int[] thresholdSet
Constructor Detail

DifferenceExpansionEncoder

public DifferenceExpansionEncoder(Bitmap originalBitmap,
                                  BitSequence payload,
                                  DifferenceExpansionOptions options)
Parameters should include pixel pair selection method, scanning order, map compression parameter, etc. Perhaps info on header: multi-level expansion, thresholds, etc.

Method Detail

encode

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

Specified by:
encode in class Encoder

encodeLayer

public void encodeLayer(BitSequence payload)
Encodes the specified payload in a layer of the image. TODO: Need to re-think this.

Parameters:
payload -

getPairs

private java.util.ArrayList<DEPixelPair> getPairs()
Returns a complete ordered list of pixel pairs in an order specified by the construction parameters, for the current layer. If the pairing type is ADJACENT, just pair each pixel with its next neighbor in a top-down, left-to-right fashion. If there is an odd number of pixels, ignore the last one. If pairing type is RANDOM, pairs will be selected sequentially from a pseudo-random ordering of the pixels based on the specified random seed / key.


buildMapAndLSBStream

private void buildMapAndLSBStream(java.util.ArrayList<DEPixelPair> pairs,
                                  BitSequence locationMap,
                                  BitSequence lsbSequence,
                                  int threshold)
Builds the location map by setting the bit at index corresponding to a pair that has been selected for expansion. Simultaneously builds the sequence of original difference LSBs (C) that will be needed to restore the image.

Parameters:
pairs -
locationMap -
c -
threshold -

buildSelectionVector

private void buildSelectionVector(java.util.ArrayList<DEPixelPair> pairs,
                                  BitSequence selectionVector,
                                  BitSequence locationMap,
                                  int threshold)
Builds the selection vector from the specified pairs, locationMap, and threshold value. The selection vector is similar to the location map, but only contains information for those pairs for which it will be known for certain that the pair is either selected or not selected for expansion. This includes non-changeable pairs, as well as pairs that can be known to be embedded or not embedded based on the threshold value.

Parameters:
pairs -
selectionVector -
locationMap -
threshold -

embed

private void embed(java.util.ArrayList<DEPixelPair> pairs,
                   BitIterator mapIterator,
                   BitSequence sequence)
Embeds the specified sequence in the specified pixel pairs, moving through the pairs using the iterator to determine the index of embedding and what type of embedding (expansion or simple embedding) to perform for each pair. Non-changeable, and thus non-embeddable, pairs will be skipped. If the specified embedding sequence is null, random bits will be used to fill the remainder of the pairs.

Parameters:
pairs -
mapIterator -
sequence -

embedPayload

private void embedPayload(java.util.ArrayList<DEPixelPair> pairs,
                          BitIterator mapIterator)
Embeds as much of the payload as possible into the remaining pairs, while still fitting the end-of-map sequence in at the end.

Parameters:
pairs -
mapIterator -

embedBit

private boolean embedBit(java.util.ArrayList<DEPixelPair> pairs,
                         BitIterator mapIterator,
                         BitIterator sequenceIterator)
Attempts to embed the next bit in sequenceIterator into pairs.
If the next pair is not changeable, no embedding occurs, mapIterator is advanced, and we return false.
If the next pair is changeable, embedding occurs, mapIterator and sequenceIterator are advanced, and we return true.
Also return false if no more embeddable space exists.

Parameters:
pairs -
mapIterator -
sequenceIterator -
Returns:

forceThreshold

public void forceThreshold(int threshold)
Forces the threshold to the specified value, disregards payload content size. Used for data collection.

Parameters:
threshold -

getTotalCapacity

public int getTotalCapacity()
Returns the total capacity achieved during the last encoding.

Returns:

getLastCompLocMapSize

public int getLastCompLocMapSize()

getLastSelVectorSize

public int getLastSelVectorSize()

getLastCompSelVectorSize

public int getLastCompSelVectorSize()

getLastCapacity

public int getLastCapacity()

forceThresholdSet

public void forceThresholdSet(int[] thresholdSet)