com.brownsoft.codec
Class KLTDecoder

java.lang.Object
  extended bycom.brownsoft.codec.KLTDecoder
All Implemented Interfaces:
KLTConstants

public class KLTDecoder
extends java.lang.Object
implements KLTConstants

Title: Proyecto Codificacion de Imagenes y Video

Description:

Esta clase implementa un decodificador de imágenes a color y B/N aplicando la transformación de Karhunen-Loève

Copyright: Copyright (c) 2004

Company:

Version:
1.0
Author:
Gustavo Brown (alegus@adinet.com.uy)

Field Summary
protected  int BLOCK_SIZE
           
protected  int BLOCK_WIDTH
           
private  int coefficients
           
private  java.lang.String comment
           
private  int currentBand
           
private  java.io.DataInputStream dataStream
           
private  boolean embedKLTVectors
           
private  java.lang.String externalKLTBaseInputName
           
private  HuffmanMultiplexerBitInputStream externalKLTReader
           
private  HuffmanMultiplexerBitInputStream huffmanDecoder
           
private  java.awt.image.BufferedImage image
           
private  int imageHeight
           
private  double[][][] imageMatrix
           
private  byte imageType
           
private  int imageWidth
           
private  boolean ownerInputStream
           
private  int quality
           
private  boolean showBands
           
private  boolean useExternalKLTBase
           
private  boolean useQuantization
           
 
Fields inherited from interface com.brownsoft.codec.KLTConstants
AC_CHANNEL_BASE, AC_QUANTIZER, AC_QUANTIZER_CrCb, AC_QUANTIZER_FACTOR, AXIS_Cb, AXIS_Cr, AXIS_Y, BLUE, DC_CHANNEL, DC_QUANTIZER, EOB, FORMAT_STRING, FRACTION_MULTIPLIER, GRAY, GREEN, IMAGE_DEFAULT, IMAGE_GRAY, IMAGE_RGB, IMAGE_YCrCb, KLT_COEFF_MULTIPLIER, LOG_2, QUALITY_BEST, QUALITY_BETTER, QUALITY_GOOD, QUALITY_LOW, RED, subsampling_x, subsampling_y
 
Constructor Summary
KLTDecoder(java.io.InputStream inputStream)
          Construye una instance del decoder
KLTDecoder(java.lang.String filename)
          Construye una instance del decoder
 
Method Summary
 java.awt.Image decode()
          Decodifica la imagen
private  double decodeBlock(double[] vector, double lastDC)
          Decodifica un bloque de la imagen
private  void decodeImage()
          Decodifica la imagen
private  void decompressImage()
          Descomprime la imagen
private  double dequantizeAC(double value, int curCoef)
          Decuantifica un componente de alterna
private  double dequantizeDC(double value)
          Decuantifica el componente de continua
private  double[][][] expandSubSampling(double[][][] imageBand)
          Expande el subsampling de los canales Cr y Cb
private  java.lang.String getBandName()
          Obtiene el nombre asociado a un canal
 int getBlockSize()
          Obtiene el tamaño del bloque NxN return Tamaño del bloque NxN
private  int getBufferedImageType()
           
private  int getCantBlocks(int curBand)
          Retorna la cantidad de bloques (por banda) que tiene la imagen
 java.lang.String getComment()
          Obtiene el comentario asociado a la imagen
private  double getDoubleFromVLI(HuffmanMultiplexerBitInputStream huffmanDecoder, int cantBitsNeeded)
          Obtiene un double a partir de un VariableLengthInteger
private  double getDoubleFromVLI(int cantBitsNeeded)
          Obtiene un double a partir de un VariableLengthInteger
 java.awt.Point getImageSize()
          Obtiene el tamaño de la imagen
 int getImageType()
          Obtiene el tipo de imagen
 boolean getKLTVectorsEmbeded()
          Indica si los coeficientes de la base de la KLT estan embebidos en la imagen
 boolean getShowBands()
          Retorna si se mostraran las bandas al codificar la imagen
private  void openExternalKLTBase()
          Abre un archivo de base de la KLT (.kltc)
private  void readHeader()
          Lee el header
 void setBlockSize(int blockSize)
          Setea el tamaño(lado) de los bloques
 void setKLTBaseName(java.lang.String kltBaseName)
          Indica que utilice la base de la klt a partir del archivo pasado por argumento
private  void setQuality(int quality)
          Setea la calidad de la imagen
 void setShowBands(boolean showBands)
          Indica si se desea mostrar las bandas que se van codificando
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

protected int BLOCK_SIZE

BLOCK_WIDTH

protected int BLOCK_WIDTH

coefficients

private int coefficients

comment

private java.lang.String comment

currentBand

private int currentBand

dataStream

private java.io.DataInputStream dataStream

embedKLTVectors

private boolean embedKLTVectors

externalKLTBaseInputName

private java.lang.String externalKLTBaseInputName

externalKLTReader

private HuffmanMultiplexerBitInputStream externalKLTReader

huffmanDecoder

private HuffmanMultiplexerBitInputStream huffmanDecoder

image

private java.awt.image.BufferedImage image

imageHeight

private int imageHeight

imageMatrix

private double[][][] imageMatrix

imageType

private byte imageType

imageWidth

private int imageWidth

ownerInputStream

private boolean ownerInputStream

quality

private int quality

showBands

private boolean showBands

useExternalKLTBase

private boolean useExternalKLTBase

useQuantization

private boolean useQuantization
Constructor Detail

KLTDecoder

public KLTDecoder(java.io.InputStream inputStream)
           throws java.io.IOException
Construye una instance del decoder

Parameters:
inputStream - Stream de donde obtener la imagen

KLTDecoder

public KLTDecoder(java.lang.String filename)
           throws java.io.IOException
Construye una instance del decoder

Parameters:
filename - Nombre del archivo donde se encuentra la imagen
Method Detail

decode

public java.awt.Image decode()
                      throws KLTException
Decodifica la imagen

Returns:
Image con la imagen
Throws:
KLTException

decodeBlock

private double decodeBlock(double[] vector,
                           double lastDC)
                    throws java.io.IOException
Decodifica un bloque de la imagen

Parameters:
vector - Vector donde colocar los coeficientes del bloque
lastDC - el coeficiente de continua del bloque anterior
Returns:
double El coeficiente de continua actual
Throws:
java.io.IOException

decodeImage

private void decodeImage()
                  throws java.io.IOException,
                         KLTException
Decodifica la imagen

Throws:
java.io.IOException
KLTException

decompressImage

private void decompressImage()
                      throws java.io.IOException
Descomprime la imagen

Throws:
java.io.IOException

dequantizeAC

private double dequantizeAC(double value,
                            int curCoef)
Decuantifica un componente de alterna


dequantizeDC

private double dequantizeDC(double value)
Decuantifica el componente de continua


expandSubSampling

private double[][][] expandSubSampling(double[][][] imageBand)
Expande el subsampling de los canales Cr y Cb


getBandName

private java.lang.String getBandName()
Obtiene el nombre asociado a un canal

Returns:
Nombre asociado a un canal

getBlockSize

public int getBlockSize()
Obtiene el tamaño del bloque NxN return Tamaño del bloque NxN


getBufferedImageType

private int getBufferedImageType()

getCantBlocks

private int getCantBlocks(int curBand)
Retorna la cantidad de bloques (por banda) que tiene la imagen


getComment

public java.lang.String getComment()
Obtiene el comentario asociado a la imagen

Returns:
Comentario asociado a la imagen

getDoubleFromVLI

private double getDoubleFromVLI(HuffmanMultiplexerBitInputStream huffmanDecoder,
                                int cantBitsNeeded)
                         throws java.io.IOException
Obtiene un double a partir de un VariableLengthInteger

Parameters:
huffmanDecoder - el HuffmanMultiplexerBitInputStream con el stream de entrada
cantBitsNeeded - cantidad de bits de este VLI
Throws:
java.io.IOException

getDoubleFromVLI

private double getDoubleFromVLI(int cantBitsNeeded)
                         throws java.io.IOException
Obtiene un double a partir de un VariableLengthInteger

Parameters:
cantBitsNeeded - cantidad de bits de este VLI
Throws:
java.io.IOException

getImageSize

public java.awt.Point getImageSize()
Obtiene el tamaño de la imagen

Returns:
tamaño de la imagen

getImageType

public int getImageType()
Obtiene el tipo de imagen

Returns:
tipo de imagen (IMAGE_GRAY, IMAGE_RGB, IMAGE_YCrCb)

getKLTVectorsEmbeded

public boolean getKLTVectorsEmbeded()
Indica si los coeficientes de la base de la KLT estan embebidos en la imagen


getShowBands

public boolean getShowBands()
Retorna si se mostraran las bandas al codificar la imagen


openExternalKLTBase

private void openExternalKLTBase()
                          throws java.io.IOException
Abre un archivo de base de la KLT (.kltc)

Throws:
java.io.IOException

readHeader

private void readHeader()
                 throws java.io.IOException,
                        KLTException
Lee el header

Throws:
java.io.IOException
KLTException

setBlockSize

public void setBlockSize(int blockSize)
                  throws KLTException
Setea el tamaño(lado) de los bloques

Throws:
KLTException

setKLTBaseName

public void setKLTBaseName(java.lang.String kltBaseName)
Indica que utilice la base de la klt a partir del archivo pasado por argumento


setQuality

private void setQuality(int quality)
Setea la calidad de la imagen


setShowBands

public void setShowBands(boolean showBands)
Indica si se desea mostrar las bandas que se van codificando