|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.brownsoft.codec.KLTEncoder
Title: Proyecto Codificacion de Imagenes y Video
Description:
Esta clase implementa un codificador de imágenes a color y B/N aplicando la transformación de Karhunen-LoèveCopyright: Copyright (c) 2004
Company:
Field Summary | |
protected int |
BLOCK_SIZE
|
protected int |
BLOCK_WIDTH
|
private int |
cantBands
|
private int |
coefficients
|
private java.lang.String |
comment
|
private int |
currentBand
|
private int |
currentBandLeastUsedCoeff
|
private java.io.DataOutputStream |
dataStream
|
static boolean |
DEBUG
|
private boolean |
embedKLTVectors
|
private java.lang.String |
externalKLTBaseInputName
|
private java.lang.String |
externalKLTBaseOutputName
|
private HuffmanMultiplexerBitInputStream |
externalKLTReader
|
private HuffmanMultiplexerBitStream |
externalKLTWriter
|
private HuffmanMultiplexerBitStream |
huffmanMultiplexer
|
private java.awt.Image |
image
|
private int |
imageHeight
|
private double[][][] |
imageMatrix
|
private double[][][] |
imageMatrixYCrCb
|
private byte |
imageType
|
private int[] |
imageVector
|
private int |
imageWidth
|
private byte |
outputImageType
|
private int |
quality
|
private boolean |
showBands
|
private boolean |
showProgress
|
private java.io.ByteArrayOutputStream |
stream
|
private boolean |
useExternalKLTBase
|
private boolean |
writeExternalKLTBase
|
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 | |
KLTEncoder(java.awt.Image image)
Crea una instancia de KLTEncoder |
Method Summary | |
private void |
compressImage()
Aplica la KLT a la imagen con el factor de calidad deseado y obtiene los coeficientes tanto de la base como de la propia transformación |
private double |
dequantizeAC(double value,
int curCoef)
Decuantifica un componente de alterna |
private double |
dequantizeDC(double value)
Decuantifica el componente de continua |
private byte[] |
encode()
Codifica la imagen y retorna un bytearray con el contenido |
private double |
encodeBlock(double[] vector,
double lastDC)
Codifica un bloque de la imagen |
byte[] |
encodeImage()
Codifica la imagen retornando un array de bytes |
void |
encodeImage(java.lang.String outputFileName)
Codifica la imagen y escribe el archivo de salida |
private java.lang.String |
getBandName(int band)
Obtiene el nombre asociado a un canal |
int |
getBlockSize()
Obtiene el tamaño(lado) de los bloques |
private int |
getCantBitsNeeded(double value)
Retorna la cantidad de bits que se necesita para expresar una magnitud |
java.lang.String |
getComment()
Obtiene el comentario de la imagen |
private double |
getDoubleFromVLI(HuffmanMultiplexerBitInputStream huffmanDecoder,
int cantBitsNeeded)
Obtiene un double a partir de un VariableLengthInteger |
boolean |
getEmbedKLTVectors()
Retorna si embeber los vectores de la base de la KLT |
private byte |
getFlags()
Obtiene las flags de la imagen |
protected double[][] |
getImageMatrix(int band)
Obtiene la matriz de un canal de la imagen |
java.lang.String |
getKLTBaseInputName()
Obtiene el nombre del archivo de donde obtener la base de la KLT o null si debe ser calculado |
java.lang.String |
getKLTBaseOutputName()
Obtiene el nombre del archivo donde almacenar la base de la KLT |
int |
getNumberOfCoefficients()
Retorna la cantidad de coeficientes de la base a utilizar |
byte |
getOutputImageType()
Indica el tipo de imagen de salida |
int |
getQuality()
Obtiene la calidad de compresion de la imagen |
boolean |
getShowBands()
Retorna si se mostraran las bandas al codificar la imagen |
boolean |
getShowProgress()
Indica si se va a mostrar progreso de la codificacion |
private int |
getVLI(int cantBitsNeeded,
double value)
Obtiene un VariableLengthInteger |
private boolean |
isZero(double value)
Retorna true si el valor pasado por argumento se considera nulo |
private void |
openExternalKLTBase()
Abre un archivo de base de la KLT (.kltc) |
private double |
quantizeAC(double value,
int curCoef)
Cuantifica un componente de alterna |
private double |
quantizeDC(double value)
Cuantifica el componente de continua |
void |
setBlockSize(int blockSize)
Setea el tamaño(lado) de los bloques |
void |
setComment(java.lang.String comment)
Setea el comentario de la imagen |
void |
setEmbedKLTVectors(boolean embedKLTVectors)
Indica si embeber los vectores de la base de la KLT |
private void |
setImageMatrix()
Setea la informacion sobre la imagen de entrada y su matriz asociada |
private void |
setImageMatrixYCrCb()
Calcula la matrix en el espacio YCrCb |
void |
setKLTBaseName(java.lang.String kltBaseName)
Indica que utilice la base de la klt a partir del archivo pasado por argumento |
void |
setKLTBaseOutputName(java.lang.String externalKLTBase)
Setea si se desea crear la base de la KLT en un archivo separado |
void |
setNumberOfCoefficients(int coefficients)
Setea la cantidad de coeficientes de la base a utilizar |
void |
setOutputImageType(byte outputImageType)
Setea el tipo de la imagen de salida |
void |
setQuality(int quality)
Setea la calidad de la compresión |
void |
setShowBands(boolean showBands)
Indica si se desea mostrar las bandas que se van codificando |
void |
setShowProgress(boolean showProgress)
Setea si se desea ir mostrando un progreso de la codificación |
private void |
writeHeader()
Escribe el header |
private void |
writeString(java.lang.String str)
Escribe un String en el stream |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int BLOCK_SIZE
protected int BLOCK_WIDTH
private int cantBands
private int coefficients
private java.lang.String comment
private int currentBand
private int currentBandLeastUsedCoeff
private java.io.DataOutputStream dataStream
public static final boolean DEBUG
private boolean embedKLTVectors
private java.lang.String externalKLTBaseInputName
private java.lang.String externalKLTBaseOutputName
private HuffmanMultiplexerBitInputStream externalKLTReader
private HuffmanMultiplexerBitStream externalKLTWriter
private HuffmanMultiplexerBitStream huffmanMultiplexer
private java.awt.Image image
private int imageHeight
private double[][][] imageMatrix
private double[][][] imageMatrixYCrCb
private byte imageType
private int[] imageVector
private int imageWidth
private byte outputImageType
private int quality
private boolean showBands
private boolean showProgress
private java.io.ByteArrayOutputStream stream
private boolean useExternalKLTBase
private boolean writeExternalKLTBase
Constructor Detail |
public KLTEncoder(java.awt.Image image)
image
- La imagen a codificarMethod Detail |
private void compressImage() throws java.io.IOException
java.io.IOException
private double dequantizeAC(double value, int curCoef)
private double dequantizeDC(double value)
private byte[] encode() throws java.io.IOException
java.io.IOException
private double encodeBlock(double[] vector, double lastDC)
vector
- Vector de coeficientes del bloquelastDC
- el coeficiente de continua del bloque anterior
public byte[] encodeImage() throws KLTException, java.io.IOException
KLTException
java.io.IOException
public void encodeImage(java.lang.String outputFileName) throws KLTException, java.io.IOException
KLTException
java.io.IOException
private java.lang.String getBandName(int band)
band
- Canal
public int getBlockSize()
private int getCantBitsNeeded(double value)
public java.lang.String getComment()
private double getDoubleFromVLI(HuffmanMultiplexerBitInputStream huffmanDecoder, int cantBitsNeeded) throws java.io.IOException
huffmanDecoder
- el HuffmanMultiplexerBitInputStream con el stream de entradacantBitsNeeded
- cantidad de bits de este VLI
java.io.IOException
public boolean getEmbedKLTVectors()
private byte getFlags()
protected double[][] getImageMatrix(int band)
band
- Canal a obtener
public java.lang.String getKLTBaseInputName()
public java.lang.String getKLTBaseOutputName()
setEmbedKLTVectors
public int getNumberOfCoefficients()
public byte getOutputImageType()
public int getQuality()
public boolean getShowBands()
public boolean getShowProgress()
private int getVLI(int cantBitsNeeded, double value)
private boolean isZero(double value)
private void openExternalKLTBase() throws java.io.IOException
java.io.IOException
private double quantizeAC(double value, int curCoef)
private double quantizeDC(double value)
public void setBlockSize(int blockSize) throws KLTException
KLTException
public void setComment(java.lang.String comment)
public void setEmbedKLTVectors(boolean embedKLTVectors)
private void setImageMatrix()
private void setImageMatrixYCrCb()
public void setKLTBaseName(java.lang.String kltBaseName)
public void setKLTBaseOutputName(java.lang.String externalKLTBase)
externalKLTBase
- Nombre del archivo donde almacenar la base de la KLTsetEmbedKLTVectors
public void setNumberOfCoefficients(int coefficients) throws KLTException
coefficients
- Cantidad de coeficientes a utilizar
KLTException
public void setOutputImageType(byte outputImageType) throws KLTException
outputImageType
- tipo de la imagen de salida (IMAGE_DEFAULT, IMAGE_GRAY, IMAGE_RGB o IMAGE_YCrCb)
KLTException
public void setQuality(int quality) throws KLTException
KLTException
public void setShowBands(boolean showBands)
public void setShowProgress(boolean showProgress)
showProgress
- boolean que indica si mostrar progresoprivate void writeHeader() throws java.io.IOException
java.io.IOException
private void writeString(java.lang.String str) throws java.io.IOException
java.io.IOException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |