📄 forwwtfull.java
字号:
/* * CVS identifier: * * $Id: ForwWTFull.java,v 1.25 2001/02/27 19:13:35 grosbois Exp $ * * Class: ForwWTFull * * Description: This class implements the full page * forward wavelet transform for both integer * and floating point implementations. * * * * COPYRIGHT: * * This software module was originally developed by Rapha雔 Grosbois and * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel * Askel鰂 (Ericsson Radio Systems AB); and Bertrand Berthelot, David * Bouchard, F閘ix Henry, Gerard Mozelle and Patrice Onno (Canon Research * Centre France S.A) in the course of development of the JPEG2000 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This * software module is an implementation of a part of the JPEG 2000 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio * Systems AB and Canon Research Centre France S.A (collectively JJ2000 * Partners) agree not to assert against ISO/IEC and users of the JPEG * 2000 Standard (Users) any of their rights under the copyright, not * including other intellectual property rights, for this software module * with respect to the usage by ISO/IEC and Users of this software module * or modifications thereof for use in hardware or software products * claiming conformance to the JPEG 2000 Standard. Those intending to use * this software module in hardware or software products are advised that * their use may infringe existing patents. The original developers of * this software module, JJ2000 Partners and ISO/IEC assume no liability * for use of this software module or modifications thereof. No license * or right to this software module is granted for non JPEG 2000 Standard * conforming products. JJ2000 Partners have full right to use this * software module for his/her own purpose, assign or donate this * software module to any third party and to inhibit third parties from * using this software module for non JPEG 2000 Standard conforming * products. This copyright notice must be included in all copies or * derivative works of this software module. * * Copyright (c) 1999/2000 JJ2000 Partners. * */package jj2000.j2k.wavelet.analysis;import jj2000.j2k.wavelet.*;import jj2000.j2k.encoder.*;import jj2000.j2k.image.*;import jj2000.j2k.*;/** * This class implements the ForwardWT with the full-page approach to be used * either with integer or floating-point filters * */public class ForwWTFull extends ForwardWT { /** Boolean to know if one are currently dealing with int or float data. */ private boolean intData; /** * The subband trees for each component, in each tile. The array is * allocated by the constructor of this class. This array is updated by * the getSubbandTree() method, an a as needed basis. The first index is * the tile index (in lexicographical order) and the second index is the * component index. * * <P>The subband tree for a component in the current tile is created on * the first call to getSubbandTree() for that component, in the current * tile. Before that the element in 'subbTrees' is null. * */ private SubbandAn subbTrees[][]; /** The source of image data */ private BlkImgDataSrc src; /** The horizontal coordinate of the cell and code-block partition origin, * with respect to the canvas origin, on the reference grid */ private int pox; /** The vertical coordinate of the cell and code-block partition origin, * with respect to the canvas origin, on the reference grid */ private int poy; /** The number of decomposition levels specification */ private IntegerSpec dls; /** Wavelet filters for all components and tiles */ private AnWTFilterSpec filters; /** Block storing the full band decomposition for each component. */ private DataBlk decomposedComps[]; /** * The horizontal index of the last code-block "sent" in the current * subband in each component. It should be -1 if none have been sent yet. * */ private int lastn[]; /** * The vertical index of the last code-block "sent" in the current subband * in each component. It should be 0 if none have been sent yet. * */ private int lastm[]; /** The subband being dealt with in each component */ SubbandAn currentSubband[]; /** Cache object to avoid excessive allocation/deallocation. This variable * makes the class inheritently thread unsafe. */ Coord ncblks; /** * Initializes this object with the given source of image data and with * all the decompositon parameters * * @param src From where the image data should be obtained. * * @param encSpec The encoder specifications * * @param pox The horizontal coordinate of the cell and code-block * partition origin with respect to the canvas origin, on the reference * grid. * * @param poy The vertical coordinate of the cell and code-block partition * origin with respect to the canvas origin, on the reference grid. * * @see ForwardWT * */ public ForwWTFull(BlkImgDataSrc src,EncoderSpecs encSpec,int pox,int poy) { super(src); this.src = src; this.pox = pox; this.poy = poy; this.dls = encSpec.dls; this.filters = encSpec.wfs; int ncomp = src.getNumComps(); int ntiles = src.getNumTiles(); currentSubband = new SubbandAn[ncomp]; decomposedComps = new DataBlk[ncomp]; subbTrees = new SubbandAn[ntiles][ncomp]; lastn = new int[ncomp]; lastm = new int[ncomp]; } /** * Returns the implementation type of this wavelet transform, WT_IMPL_FULL * (full-page based transform). All components return the same. * * @param c The index of the component. * * @return WT_IMPL_FULL * */ public int getImplementationType(int c) { return WaveletTransform.WT_IMPL_FULL; } /** * Returns the number of decomposition levels that are applied to the LL * band, in the specified tile-component. A value of 0 means that no * wavelet transform is applied. * * @param t The tile index * * @param c The index of the component. * * @return The number of decompositions applied to the LL band (0 for no * wavelet transform). * */ public int getDecompLevels(int t,int c) { return ((Integer)dls.getTileCompVal(t,c)).intValue(); } /** * Returns the wavelet tree decomposition. Actually JPEG 2000 part 1 only * supports WT_DECOMP_DYADIC decomposition. * * @param t The tile-index * * @param c The index of the component. * * @return The wavelet decomposition. * */ public int getDecomp(int t,int c) { return WT_DECOMP_DYADIC; } /** * Returns the horizontal analysis wavelet filters used in each level, for * the specified component and tile. The first element in the array is the * filter used to obtain the lowest resolution (resolution level 0) * subbands (i.e. lowest frequency LL subband), the second element is the * one used to generate the resolution level 1 subbands, and so on. If * there are less elements in the array than the number of resolution * levels, then the last one is assumed to repeat itself. * * <P>The returned filters are applicable only to the specified component * and in the current tile. * * <P>The resolution level of a subband is the resolution level to which a * subband contributes, which is different from its decomposition level. * * @param t The index of the tile for which to return the filters. * * @param c The index of the component for which to return the filters. * * @return The horizontal analysis wavelet filters used in each level. * */ public AnWTFilter[] getHorAnWaveletFilters(int t,int c) { return filters.getHFilters(t,c); } /** * Returns the vertical analysis wavelet filters used in each level, for * the specified component and tile. The first element in the array is the * filter used to obtain the lowest resolution (resolution level 0) * subbands (i.e. lowest frequency LL subband), the second element is the * one used to generate the resolution level 1 subbands, and so on. If * there are less elements in the array than the number of resolution * levels, then the last one is assumed to repeat itself. * * <P>The returned filters are applicable only to the specified component * and in the current tile. * * <P>The resolution level of a subband is the resolution level to which a * subband contributes, which is different from its decomposition level. * * @param t The index of the tile for which to return the filters. * * @param c The index of the component for which to return the filters. * * @return The vertical analysis wavelet filters used in each level. * */ public AnWTFilter[] getVertAnWaveletFilters(int t,int c) { return filters.getVFilters(t,c); } /** * Returns the reversibility of the wavelet transform for the specified * component and tile. A wavelet transform is reversible when it is * suitable for lossless and lossy-to-lossless compression. * * @param t The index of the tile. * * @param c The index of the component. * * @return true is the wavelet transform is reversible, false if not. * */ public boolean isReversible(int t,int c) { return filters.isReversible(t,c); } /** * Returns the horizontal coordinate of the origin of the cell and * code-block partition, with respect to the canvas origin, on the * reference grid. Allowable values are 0 and 1, nothing else. * * @return The horizontal coordinate of the origin of the cell and * code-block partitions, with respect to the canvas origin, on the * reference grid. * */ public int getPartitionULX() { return pox; } /** * Returns the vertical coordinate of the origin of the cell and * code-block partition, with respect to the canvas origin, on the * reference grid. Allowable values are 0 and 1, nothing else. * * @return The vertical coordinate of the origin of the cell and * code-block partitions, with respect to the canvas origin, on the * reference grid. * */ public int getPartitionULY() { return poy; } /** * Returns the position of the fixed point in the specified * component. This is the position of the least significant integral * (i.e. non-fractional) bit, which is equivalent to the number of * fractional bits. For instance, for fixed-point values with 2 fractional * bits, 2 is returned. For floating-point data this value does not apply * and 0 should be returned. Position 0 is the position of the least * significant bit in the data. * * @param c The index of the component. * * @return The position of the fixed-point, which is the same as the * number of fractional bits. For floating-point data 0 is returned. * */ public int getFixedPoint(int c) { return src.getFixedPoint(c); } /** * Returns the number of code-blocks in a subband, along the horizontal * and vertical dimensions. * * @param sb The subband for which to return the number of blocks. * * @param co If not null the values are returned in this object. If null a * new object is allocated and returned. * * @return The number of code-blocks along the horizontal dimension in * 'Coord.x' and the number of code-blocks along the vertical dimension in * 'Coord.y'. * */ public Coord getNumCodeBlocks(SubbandAn sb, Coord co) { if(co == null) { co = new Coord(); } if(sb.w != 0 && sb.h != 0) { int apox, apoy; // projected anchor point for the code-block // partition // Project code-block partition origin to subband. Since the // origin is always 0 or 1, it projects to the low-pass side // (throught the ceil operator) as itself (i.e. no change) and to // the high-pass side (through the floor operator) as 0, always. apox = pox; apoy = poy; Subband sb2; switch (sb.gOrient) { case Subband.WT_ORIENT_LL: // No need to project since all low-pass => nothing to do break; case Subband.WT_ORIENT_HL: // There is at least a high-pass step on the horizontal // decomposition => project to 0 apox = 0; // We need to find out if there has been a high-pass step on // the vertical decomposition sb2 = sb; do { if (sb2.orientation == Subband.WT_ORIENT_HH || sb2.orientation == Subband.WT_ORIENT_LH) { // Vertical high-pass step => project to 0 and done apoy = 0; break; } if (sb2.gOrient == Subband.WT_ORIENT_LL) { // Only low-pass steps left, no need to continue // checking break; } sb2 = sb2.getParent(); } while (sb2 != null); break; case Subband.WT_ORIENT_LH: // We need to find out if there has been a high-pass step on // the horizontal decomposition sb2 = sb; do { if (sb2.orientation == Subband.WT_ORIENT_HH || sb2.orientation == Subband.WT_ORIENT_HL) { // Horizontal high-pass step => project to 0 and done apox = 0; break; } if (sb2.gOrient == Subband.WT_ORIENT_LL) { // Only low-pass steps left, no need to continue
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -