001/* 002 * $RCSfile: SubbandSyn.java,v $ 003 * $Revision: 1.1 $ 004 * $Date: 2005/02/11 05:02:33 $ 005 * $State: Exp $ 006 * 007 * Class: SubbandSyn 008 * 009 * Description: Element for a tree structure for a description 010 * of subband for the synthesis side. 011 * 012 * 013 * 014 * COPYRIGHT: 015 * 016 * This software module was originally developed by Raphaël Grosbois and 017 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel 018 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David 019 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research 020 * Centre France S.A) in the course of development of the JPEG2000 021 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This 022 * software module is an implementation of a part of the JPEG 2000 023 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio 024 * Systems AB and Canon Research Centre France S.A (collectively JJ2000 025 * Partners) agree not to assert against ISO/IEC and users of the JPEG 026 * 2000 Standard (Users) any of their rights under the copyright, not 027 * including other intellectual property rights, for this software module 028 * with respect to the usage by ISO/IEC and Users of this software module 029 * or modifications thereof for use in hardware or software products 030 * claiming conformance to the JPEG 2000 Standard. Those intending to use 031 * this software module in hardware or software products are advised that 032 * their use may infringe existing patents. The original developers of 033 * this software module, JJ2000 Partners and ISO/IEC assume no liability 034 * for use of this software module or modifications thereof. No license 035 * or right to this software module is granted for non JPEG 2000 Standard 036 * conforming products. JJ2000 Partners have full right to use this 037 * software module for his/her own purpose, assign or donate this 038 * software module to any third party and to inhibit third parties from 039 * using this software module for non JPEG 2000 Standard conforming 040 * products. This copyright notice must be included in all copies or 041 * derivative works of this software module. 042 * 043 * Copyright (c) 1999/2000 JJ2000 Partners. 044 * 045 * 046 * 047 */ 048 049 050package jj2000.j2k.wavelet.synthesis; 051 052import jj2000.j2k.wavelet.Subband; 053import jj2000.j2k.wavelet.WaveletFilter; 054 055/** 056 * This class represents a subband in a tree structure that describes 057 * the subband decomposition for a wavelet transform, specifically for 058 * the syhthesis side. 059 * 060 * <P>The element can be either a node or a leaf of the tree. If it is 061 * a node then ther are 4 descendants (LL, HL, LH and HH). If it is a 062 * leaf there are no descendants. 063 * 064 * <P>The tree is bidirectional. Each element in the tree structure 065 * has a "parent", which is the subband from which the element was 066 * obtained by decomposition. The only exception is the root element 067 * which has no parent (i.e.it's null), for obvious reasons. 068 * */ 069public class SubbandSyn extends Subband { 070 071 /** 072 * The reference to the parent of this subband. It is null for the 073 * root element. It is null by default. */ 074 public SubbandSyn parent; 075 076 /** 077 * The reference to the LL subband resulting from the 078 * decomposition of this subband. It is null by default. */ 079 public SubbandSyn subb_LL; 080 081 /** 082 * The reference to the HL subband (horizontal high-pass) 083 * resulting from the decomposition of this subband. It is null by 084 * default. */ 085 public SubbandSyn subb_HL; 086 087 /** 088 * The reference to the LH subband (vertical high-pass) resulting 089 * from the decomposition of this subband. It is null by default. 090 * */ 091 public SubbandSyn subb_LH; 092 093 /** 094 * The reference to the HH subband resulting from the 095 * decomposition of this subband. It is null by default. 096 */ 097 public SubbandSyn subb_HH; 098 099 /** The horizontal analysis filter used to recompose this subband, 100 from its childs. This is applicable to "node" elements 101 only. The default value is null. */ 102 public SynWTFilter hFilter; 103 104 /** The vertical analysis filter used to decompose this subband, 105 from its childs. This is applicable to "node" elements 106 only. The default value is null. */ 107 public SynWTFilter vFilter; 108 109 /** The number of magnitude bits */ 110 public int magbits = 0; 111 112 /** 113 * Creates a SubbandSyn element with all the default values. The 114 * dimensions are (0,0) and the upper left corner is (0,0). 115 * 116 * 117 * */ 118 public SubbandSyn() { 119 } 120 121 /** 122 * Creates the top-level node and the entire subband tree, with 123 * the top-level dimensions, the number of decompositions, and the 124 * decomposition tree as specified. 125 * 126 * <P>This constructor just calls the same constructor of the 127 * super class. 128 * 129 * @param w The top-level width 130 * 131 * @param h The top-level height 132 * 133 * @param ulcx The horizontal coordinate of the upper-left corner with 134 * respect to the canvas origin, in the component grid. 135 * 136 * @param ulcy The vertical coordinate of the upper-left corner with 137 * respect to the canvas origin, in the component grid. 138 * 139 * @param lvls The number of levels (or LL decompositions) in the 140 * tree. 141 * 142 * @param hfilters The horizontal wavelet synthesis filters for each 143 * resolution level, starting at resolution level 0. 144 * 145 * @param vfilters The vertical wavelet synthesis filters for each 146 * resolution level, starting at resolution level 0. 147 * 148 * @see Subband#Subband(int,int,int,int,int, 149 * WaveletFilter[],WaveletFilter[]) 150 * 151 * 152 * */ 153 public SubbandSyn(int w, int h, int ulcx, int ulcy, int lvls, 154 WaveletFilter hfilters[], WaveletFilter vfilters[]) { 155 super(w,h,ulcx,ulcy,lvls,hfilters,vfilters); 156 } 157 158 /** 159 * Returns the parent of this subband. The parent of a subband is 160 * the subband from which this one was obtained by 161 * decomposition. The root element has no parent subband (null). 162 * 163 * @return The parent subband, or null for the root one. 164 * 165 * 166 * */ 167 public Subband getParent() { 168 return parent; 169 } 170 171 /** 172 * Returns the LL child subband of this subband. 173 * 174 * @return The LL child subband, or null if there are no childs. 175 * 176 * 177 * */ 178 public Subband getLL() { 179 return subb_LL; 180 } 181 182 /** 183 * Returns the HL (horizontal high-pass) child subband of this 184 * subband. 185 * 186 * @return The HL child subband, or null if there are no childs. 187 * 188 * 189 * */ 190 public Subband getHL() { 191 return subb_HL; 192 } 193 194 /** 195 * Returns the LH (vertical high-pass) child subband of this 196 * subband. 197 * 198 * @return The LH child subband, or null if there are no childs. 199 * 200 * 201 * */ 202 public Subband getLH() { 203 return subb_LH; 204 } 205 206 /** 207 * Returns the HH child subband of this subband. 208 * 209 * @return The HH child subband, or null if there are no childs. 210 * 211 * 212 * */ 213 public Subband getHH() { 214 return subb_HH; 215 } 216 217 /** 218 * Splits the current subband in its four subbands. It changes the 219 * status of this element (from a leaf to a node, and sets the 220 * filters), creates the childs and initializes them. An 221 * IllegalArgumentException is thrown if this subband is not a 222 * leaf. 223 * 224 * <P>It uses the initChilds() method to initialize the childs. 225 * 226 * @param hfilter The horizontal wavelet filter used to decompose 227 * this subband. It has to be a SynWTFilter object. 228 * 229 * @param vfilter The vertical wavelet filter used to decompose this 230 * subband. It has to be a SynWTFilter object. 231 * 232 * @return A reference to the LL leaf (subb_LL). 233 * 234 * @see Subband#initChilds 235 * 236 * 237 * */ 238 protected Subband split(WaveletFilter hfilter, WaveletFilter vfilter) { 239 // Test that this is a node 240 if (isNode) { 241 throw new IllegalArgumentException(); 242 } 243 244 // Modify this element into a node and set the filters 245 isNode = true; 246 this.hFilter = (SynWTFilter) hfilter; 247 this.vFilter = (SynWTFilter) vfilter; 248 249 // Create childs 250 subb_LL = new SubbandSyn(); 251 subb_LH = new SubbandSyn(); 252 subb_HL = new SubbandSyn(); 253 subb_HH = new SubbandSyn(); 254 255 // Assign parent 256 subb_LL.parent = this; 257 subb_HL.parent = this; 258 subb_LH.parent = this; 259 subb_HH.parent = this; 260 261 // Initialize childs 262 initChilds(); 263 264 // Return reference to LL subband 265 return subb_LL; 266 } 267 /** 268 * This function returns the horizontal wavelet filter relevant to this 269 * subband 270 * 271 * @return The horizontal wavelet filter 272 * 273 * 274 */ 275 public WaveletFilter getHorWFilter(){ 276 return hFilter; 277 } 278 279 /** 280 * This function returns the vertical wavelet filter relevant to this 281 * subband 282 * 283 * @return The vertical wavelet filter 284 * 285 * 286 */ 287 public WaveletFilter getVerWFilter(){ 288 return hFilter; 289 } 290 291}