CADI.Client.ClientLogicalTarget.JPEG2000
Class JPEG2KLogicalTarget

java.lang.Object
  extended by CADI.Client.ClientLogicalTarget.ClientLogicalTarget
      extended by CADI.Client.ClientLogicalTarget.JPEG2000.JPEG2KLogicalTarget

public class JPEG2KLogicalTarget
extends ClientLogicalTarget

This class implements a JPEG2000 decoder.

NOTE: this class will be implemented as a thread.

Version:
1.2.2 2008/12/12
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  int[] blockHeights
          Definition in CODParameters.blockHeights
private  int[][] blocksPerPrecinctHeights
          Definition in GenerateImageStructure.blocksPerPrecinctHeights.
private  int[][] blocksPerPrecinctWidths
          Definition in GenerateImageStructure.blocksPerPrecinctWidths.
private  int[] blockWidths
          Definition in CODParameters.blockWidths
private  java.awt.image.BufferedImage bufferedImage
          Definition in ImageData.bufImage.
private  ClientCacheManagement clientCache
          Is a reference to the client cache object for the actual logical target.
private  float[] fImagePixels
           
private  float[][][] imageSamplesFloat
          Definition in ImageData.imageSamplesFloat.
private  BufferedDataInputStream in
          Temporal buffer.
private  long initStageTime
          Used for verbose information (time for stage).
private  long initTime
          Used for verbose information (total time).
private  boolean isMainHeaderDecoded
          Indicates if the main header has been decoded.
private  JPCParameters jpcParameters
          It is the JPEG2000 image parameters.
private  JPEG2KDecoder jpeg2kDecoder
          This object is used to decode a JPEG2000 codestream.
private  int maxLayer
          Is the highest quality layer
private  PacketHeadersDecoder packetHeadersDecoder
          Definition in PacketHeadersDecoder
private  int[][] precinctHeights
          Definition in CODParameters.precinctHeights
private  java.util.Hashtable<java.lang.Long,ByteStream[][][][]> precinctsByteStreams
          Is a table where byte arrays of coding passes will be record after being read from the cache to be passed to the decompression module
private  int[][] precinctWidths
          Definition in CODParameters.precinctWidths
private  int TileXSize
          Definition in SIZParameters.XTsize
private  int TileYSize
          Definition in SIZParameters.YTsize
private  ViewWindowField viewWindow
          Contains the last view window of the image decompressed.
private  int[] WTLevels
          Definition in CODParameters.WTLevels
private  int[] WTTypes
          Definition in CODParameters.WTTypes
private  int XOsize
          Definition in SIZParameters.XOsize
private  int YOsize
          Definition in SIZParameters.YOsize
private  java.util.Hashtable<java.lang.Long,int[][][]> zeroBitPlanes
          Is a table where will be record the number of zero bit planes por each block
 
Fields inherited from class CADI.Client.ClientLogicalTarget.ClientLogicalTarget
components, imageData, imageDataType, initialized, log, logicalTargetType, maxComponents, target, tid, xSize, ySize, zSize
 
Constructor Summary
JPEG2KLogicalTarget(ImageData imageData)
          Constructor.
 
Method Summary
private  ViewWindowField calculateWOIToDecode(ViewWindowField requestViewWindow, ViewWindowField responseViewWindow)
          This function calculates the view window which will be decoded taken into account the requested view window (provided by the user application) and the response view window (sent by the server).
 void decode(ViewWindowField requestViewWindow, ImageData dstImageData)
          This method must implement the decode engine of the logical target.
 void decode(ViewWindowField requestViewWindow, ViewWindowField responseViewWindow, ImageData dstImageData)
          This method must implement the decode engine of the logical target.
private  boolean decodeMainHeader()
          Decodes the image main header.
 int[] getFrameSize(int resolutionLevel)
          Returns the frame size of the resolution level specified.
 int[][] getFrameSizes()
          Returns all available frame sizes.
 JPCParameters getJPCParameters()
          Returns the JPC parameters.
 java.lang.String getLogicalTargetDescription()
          This method gets a description of the logical target.
 int getMaxLayers()
          Returns the maximum number of layers.
 int getMaxResolutionLevels()
          Returns the maximum number of resolution levels.
 int[][] getRelevantComponents(int[][] comps)
          Calculates which are the necessary components to invert a multiple component transformation.
private  java.awt.image.BufferedImage imageSamplesToBufferedImage(float[][][] imageSamplesFloat)
          NOTE: this is a temporary method to convert from a three dimensional array representation to a bufferered image representation.
 boolean isMultiComponentTransform()
          Check if the logical target has a multiple component transformation.
 void list(java.io.PrintStream out)
          Prints this JPEG2KLogicaltarget's fields to the specified output stream.
private static void printByteArray(BufferedDataInputStream in, long iniPos, long finalPos)
           
private static void printByteStream(ByteStream byteStream)
          Useful method for printing out a ByteStream.
private  void printPrecinctsByteStreams(java.util.Hashtable<java.lang.Long,ByteStream[][][][]> precinctsByteStreams)
           
private  void readRelevantPrecincts(java.util.ArrayList<java.lang.Long> relevantPrecincts)
          Reads the data from the relevant precincts.
 void setCache(ClientCacheManagement clientCache)
          Sets the client cache for this logical target.
private  void showTimeMemory(java.lang.String stage)
          Show some time and memory usage statisticals.
 java.lang.String toString()
           
 
Methods inherited from class CADI.Client.ClientLogicalTarget.ClientLogicalTarget
getHeight, getImageData, getLogicalTargetType, getMaxComponents, getTarget, getTID, getWidth, isInitialized, setLog, setLogicalTargetType, setTarget, setTID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

viewWindow

private ViewWindowField viewWindow
Contains the last view window of the image decompressed.


clientCache

private ClientCacheManagement clientCache
Is a reference to the client cache object for the actual logical target.


jpcParameters

private JPCParameters jpcParameters
It is the JPEG2000 image parameters.


YOsize

private int YOsize
Definition in SIZParameters.YOsize


XOsize

private int XOsize
Definition in SIZParameters.XOsize


TileYSize

private int TileYSize
Definition in SIZParameters.YTsize


TileXSize

private int TileXSize
Definition in SIZParameters.XTsize


WTTypes

private int[] WTTypes
Definition in CODParameters.WTTypes


WTLevels

private int[] WTLevels
Definition in CODParameters.WTLevels


blockHeights

private int[] blockHeights
Definition in CODParameters.blockHeights


blockWidths

private int[] blockWidths
Definition in CODParameters.blockWidths


precinctHeights

private int[][] precinctHeights
Definition in CODParameters.precinctHeights


precinctWidths

private int[][] precinctWidths
Definition in CODParameters.precinctWidths


precinctsByteStreams

private java.util.Hashtable<java.lang.Long,ByteStream[][][][]> precinctsByteStreams
Is a table where byte arrays of coding passes will be record after being read from the cache to be passed to the decompression module. - The key of the hash is the unique identifier for precincts defined in the ISO/IEC 15444-9 (see JPIPMessageHeader.inClassIdentifier). - The value for each hash-table entry is a multi-array of ByteStreams where indices mean:
  subband
  yBlock
  xBlock
  coding-pass


zeroBitPlanes

private java.util.Hashtable<java.lang.Long,int[][][]> zeroBitPlanes
Is a table where will be record the number of zero bit planes por each block. - The key of the hash is the unique identifier for precincts defined in the ISO/IEC 15444-9 (see JPIPMessageHeader.inClassIdentifier). - The value for each hash-table entry is a multi-dimensional array of integer values. Indexes mean:
  subband
  yBlock
  xBlock


blocksPerPrecinctWidths

private int[][] blocksPerPrecinctWidths
Definition in GenerateImageStructure.blocksPerPrecinctWidths.


blocksPerPrecinctHeights

private int[][] blocksPerPrecinctHeights
Definition in GenerateImageStructure.blocksPerPrecinctHeights.


packetHeadersDecoder

private PacketHeadersDecoder packetHeadersDecoder
Definition in PacketHeadersDecoder


isMainHeaderDecoded

private boolean isMainHeaderDecoded
Indicates if the main header has been decoded.


maxLayer

private int maxLayer
Is the highest quality layer


jpeg2kDecoder

private JPEG2KDecoder jpeg2kDecoder
This object is used to decode a JPEG2000 codestream.


imageSamplesFloat

private float[][][] imageSamplesFloat
Definition in ImageData.imageSamplesFloat.

Temporal structure.


in

private BufferedDataInputStream in
Temporal buffer.


bufferedImage

private java.awt.image.BufferedImage bufferedImage
Definition in ImageData.bufImage.

Temporal structure.


fImagePixels

private float[] fImagePixels

initStageTime

private long initStageTime
Used for verbose information (time for stage).

0 is initial time.


initTime

private long initTime
Used for verbose information (total time).

0 is initial time.

Constructor Detail

JPEG2KLogicalTarget

public JPEG2KLogicalTarget(ImageData imageData)
Constructor.

Parameters:
imageData -
Method Detail

setCache

public void setCache(ClientCacheManagement clientCache)
Description copied from class: ClientLogicalTarget
Sets the client cache for this logical target.

Specified by:
setCache in class ClientLogicalTarget
Parameters:
clientCache - the client cache.

decode

public void decode(ViewWindowField requestViewWindow,
                   ImageData dstImageData)
            throws ErrorException
Description copied from class: ClientLogicalTarget
This method must implement the decode engine of the logical target.

Specified by:
decode in class ClientLogicalTarget
Parameters:
requestViewWindow - the Window Of Interest to decode.
dstImageData - an object where the decode image must be saved.
Throws:
ErrorException - if the Window Of Interest cannot be decoded.

decode

public void decode(ViewWindowField requestViewWindow,
                   ViewWindowField responseViewWindow,
                   ImageData dstImageData)
            throws ErrorException
Description copied from class: ClientLogicalTarget
This method must implement the decode engine of the logical target. If the second argument (responseViewWindow) is null, this method is equal to the ClientLogicalTarget.decode(ViewWindowField, ImageData) method.

Specified by:
decode in class ClientLogicalTarget
Parameters:
requestViewWindow - the Window Of Interest which the user is requesting for.
responseViewWindow - the Window Of Interest which the server has sent.
dstImageData - an object where the decode image must be saved.
Throws:
ErrorException - if the Window Of Interest cannot be decoded.

getFrameSize

public int[] getFrameSize(int resolutionLevel)
Description copied from class: ClientLogicalTarget
Returns the frame size of the resolution level specified.

Specified by:
getFrameSize in class ClientLogicalTarget
Parameters:
resolutionLevel - the resolution level.
Returns:
the frame size for the resolution level-

getFrameSizes

public int[][] getFrameSizes()
Description copied from class: ClientLogicalTarget
Returns all available frame sizes. The frame sizes are ordered from the smallest to the biggest one.

Specified by:
getFrameSizes in class ClientLogicalTarget
Returns:
a multidimensional array with the available frame sizes. The first index is the frame size index, and the second one is, 0 for width and 1 for the height.

getMaxResolutionLevels

public int getMaxResolutionLevels()
Description copied from class: ClientLogicalTarget
Returns the maximum number of resolution levels.

Specified by:
getMaxResolutionLevels in class ClientLogicalTarget
Returns:
the maximum number of resolution levels.

getMaxLayers

public int getMaxLayers()
Description copied from class: ClientLogicalTarget
Returns the maximum number of layers.

Specified by:
getMaxLayers in class ClientLogicalTarget
Returns:
the maximum number of layers

getLogicalTargetDescription

public java.lang.String getLogicalTargetDescription()
Description copied from class: ClientLogicalTarget
This method gets a description of the logical target. It is recomended the description was done as HTML table (for instance, an HTML table with a description of th logical target parameters).

Specified by:
getLogicalTargetDescription in class ClientLogicalTarget
Returns:
a string with the logical target description.

getJPCParameters

public JPCParameters getJPCParameters()
Returns the JPC parameters.

Returns:
the JPC parameters.

isMultiComponentTransform

public boolean isMultiComponentTransform()
Check if the logical target has a multiple component transformation.

Returns:
true if the logical target is spectrally transformed. Otherwise, returns false.

getRelevantComponents

public int[][] getRelevantComponents(int[][] comps)
                              throws ErrorException
Calculates which are the necessary components to invert a multiple component transformation. compsRanges the range of components to be decompressed. The first index is an array index of the ranges. An the second index indicates: 0 is the first component of the range, and 1 is the last component of the range.

Returns:
a bi-dimensional array with then required range of components. Indexes mean the same as the compsRanges input parameter.
Throws:
ErrorException

toString

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

list

public void list(java.io.PrintStream out)
Prints this JPEG2KLogicaltarget's fields to the specified output stream. This method is useful for debugging.

Overrides:
list in class ClientLogicalTarget
Parameters:
out - an output stream.

decodeMainHeader

private boolean decodeMainHeader()
                          throws ErrorException
Decodes the image main header.

Throws:
WarningException
ErrorException

readRelevantPrecincts

private void readRelevantPrecincts(java.util.ArrayList<java.lang.Long> relevantPrecincts)
                            throws ErrorException
Reads the data from the relevant precincts.

Throws:
ErrorException

imageSamplesToBufferedImage

private java.awt.image.BufferedImage imageSamplesToBufferedImage(float[][][] imageSamplesFloat)
NOTE: this is a temporary method to convert from a three dimensional array representation to a bufferered image representation.

Parameters:
imageSamplesFloat - a three-dimensional array with the image samples
Returns:
a buffered image.

calculateWOIToDecode

private ViewWindowField calculateWOIToDecode(ViewWindowField requestViewWindow,
                                             ViewWindowField responseViewWindow)
This function calculates the view window which will be decoded taken into account the requested view window (provided by the user application) and the response view window (sent by the server).

Parameters:
requestViewWindow -
responseViewWindow -
Returns:
the WOI to be decoded.

showTimeMemory

private void showTimeMemory(java.lang.String stage)
Show some time and memory usage statisticals.

Parameters:
stage - string that will be displayed

printPrecinctsByteStreams

private void printPrecinctsByteStreams(java.util.Hashtable<java.lang.Long,ByteStream[][][][]> precinctsByteStreams)
Parameters:
precinctsByteStreams -

printByteStream

private static void printByteStream(ByteStream byteStream)
Useful method for printing out a ByteStream. Only for debugging purposes.

Parameters:
buffer - the byte array to be printed.

printByteArray

private static void printByteArray(BufferedDataInputStream in,
                                   long iniPos,
                                   long finalPos)
                            throws java.io.IOException
Throws:
java.io.IOException


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)