001/* 002 * $RCSfile: SynWTFilterSpec.java,v $ 003 * $Revision: 1.1 $ 004 * $Date: 2005/02/11 05:02:34 $ 005 * $State: Exp $ 006 * 007 * Class: SynWTFilterSpec 008 * 009 * Description: Synthesis filters specification 010 * 011 * 012 * 013 * COPYRIGHT: 014 * 015 * This software module was originally developed by Raphaël Grosbois and 016 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel 017 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David 018 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research 019 * Centre France S.A) in the course of development of the JPEG2000 020 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This 021 * software module is an implementation of a part of the JPEG 2000 022 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio 023 * Systems AB and Canon Research Centre France S.A (collectively JJ2000 024 * Partners) agree not to assert against ISO/IEC and users of the JPEG 025 * 2000 Standard (Users) any of their rights under the copyright, not 026 * including other intellectual property rights, for this software module 027 * with respect to the usage by ISO/IEC and Users of this software module 028 * or modifications thereof for use in hardware or software products 029 * claiming conformance to the JPEG 2000 Standard. Those intending to use 030 * this software module in hardware or software products are advised that 031 * their use may infringe existing patents. The original developers of 032 * this software module, JJ2000 Partners and ISO/IEC assume no liability 033 * for use of this software module or modifications thereof. No license 034 * or right to this software module is granted for non JPEG 2000 Standard 035 * conforming products. JJ2000 Partners have full right to use this 036 * software module for his/her own purpose, assign or donate this 037 * software module to any third party and to inhibit third parties from 038 * using this software module for non JPEG 2000 Standard conforming 039 * products. This copyright notice must be included in all copies or 040 * derivative works of this software module. 041 * 042 * Copyright (c) 1999/2000 JJ2000 Partners. 043 * 044 * 045 * 046 */ 047package jj2000.j2k.wavelet.synthesis; 048 049import jj2000.j2k.ModuleSpec; 050 051/** 052 * This class extends ModuleSpec class for synthesis filters 053 * specification holding purpose. 054 * 055 * @see ModuleSpec 056 * 057 * */ 058public class SynWTFilterSpec extends ModuleSpec { 059 060 /** 061 * Constructs a new 'SynWTFilterSpec' for the specified number of 062 * components and tiles. 063 * 064 * @param nt The number of tiles 065 * 066 * @param nc The number of components 067 * 068 * @param type the type of the specification module i.e. tile specific, 069 * component specific or both. 070 * 071 * */ 072 public SynWTFilterSpec(int nt, int nc, byte type){ 073 super(nt, nc, type); 074 } 075 076 /** 077 * Returns the data type used by the filters in this object, as defined in 078 * the 'DataBlk' interface for specified tile-component. 079 * 080 * @param t Tile index 081 * 082 * @param c Component index 083 * 084 * @return The data type of the filters in this object 085 * 086 * @see jj2000.j2k.image.DataBlk 087 * 088 * */ 089 public int getWTDataType(int t,int c){ 090 SynWTFilter[][] an = (SynWTFilter[][])getSpec(t,c); 091 return an[0][0].getDataType(); 092 } 093 094 /** 095 * Returns the horizontal analysis filters to be used in component 'n' and 096 * tile 't'. 097 * 098 * <P>The horizontal analysis filters are returned in an array of 099 * SynWTFilter. Each element contains the horizontal filter for each 100 * resolution level starting with resolution level 1 (i.e. the analysis 101 * filter to go from resolution level 1 to resolution level 0). If there 102 * are less elements than the maximum resolution level, then the last 103 * element is assumed to be repeated. 104 * 105 * @param t The tile index, in raster scan order 106 * 107 * @param c The component index. 108 * 109 * @return The array of horizontal analysis filters for component 'n' and 110 * tile 't'. 111 * 112 * 113 * */ 114 public SynWTFilter[] getHFilters(int t, int c) { 115 SynWTFilter[][] an = (SynWTFilter[][])getSpec(t,c); 116 return an[0]; 117 } 118 119 /** 120 * Returns the vertical analysis filters to be used in component 'n' and 121 * tile 't'. 122 * 123 * <P>The vertical analysis filters are returned in an array of 124 * SynWTFilter. Each element contains the vertical filter for each 125 * resolution level starting with resolution level 1 (i.e. the analysis 126 * filter to go from resolution level 1 to resolution level 0). If there 127 * are less elements than the maximum resolution level, then the last 128 * element is assumed to be repeated. 129 * 130 * @param t The tile index, in raster scan order 131 * 132 * @param c The component index. 133 * 134 * @return The array of horizontal analysis filters for component 'n' and 135 * tile 't'. 136 * 137 * 138 * */ 139 public SynWTFilter[] getVFilters(int t,int c) { 140 SynWTFilter[][] an = (SynWTFilter[][])getSpec(t,c); 141 return an[1]; 142 } 143 144 /** Debugging method */ 145 public String toString(){ 146 String str = ""; 147 SynWTFilter[][] an; 148 149 str += "nTiles="+nTiles+"\nnComp="+nComp+"\n\n"; 150 151 for(int t=0; t<nTiles; t++){ 152 for(int c=0; c<nComp; c++){ 153 an = (SynWTFilter[][])getSpec(t,c); 154 155 str += "(t:"+t+",c:"+c+")\n"; 156 157 // Horizontal filters 158 str += "\tH:"; 159 for(int i=0; i<an[0].length; i++) 160 str += " "+an[0][i]; 161 // Horizontal filters 162 str += "\n\tV:"; 163 for(int i=0; i<an[1].length; i++) 164 str += " "+an[1][i]; 165 str += "\n"; 166 } 167 } 168 169 return str; 170 } 171 172 /** 173 * Check the reversibility of filters contained is the given 174 * tile-component. 175 * 176 * @param t The index of the tile 177 * 178 * @param c The index of the component 179 * 180 */ 181 public boolean isReversible(int t,int c){ 182 // Note: no need to buffer the result since this method is 183 // normally called once per tile-component. 184 SynWTFilter[] 185 hfilter = getHFilters(t,c), 186 vfilter = getVFilters(t,c); 187 188 // As soon as a filter is not reversible, false can be returned 189 for(int i=hfilter.length-1; i>=0; i--) 190 if(!hfilter[i].isReversible() || !vfilter[i].isReversible()) 191 return false; 192 return true; 193 } 194}