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.*; 053 054/** 055 * This class represents a subband in a tree structure that describes 056 * the subband decomposition for a wavelet transform, specifically for 057 * the syhthesis side. 058 * 059 * <P>The element can be either a node or a leaf of the tree. If it is 060 * a node then ther are 4 descendants (LL, HL, LH and HH). If it is a 061 * leaf there are no descendants. 062 * 063 * <P>The tree is bidirectional. Each element in the tree structure 064 * has a "parent", which is the subband from which the element was 065 * obtained by decomposition. The only exception is the root element 066 * which has no parent (i.e.it's null), for obvious reasons. 067 * */ 068public class SubbandSyn extends Subband { 069 070 /** 071 * The reference to the parent of this subband. It is null for the 072 * root element. It is null by default. */ 073 public SubbandSyn parent; 074 075 /** 076 * The reference to the LL subband resulting from the 077 * decomposition of this subband. It is null by default. */ 078 public SubbandSyn subb_LL; 079 080 /** 081 * The reference to the HL subband (horizontal high-pass) 082 * resulting from the decomposition of this subband. It is null by 083 * default. */ 084 public SubbandSyn subb_HL; 085 086 /** 087 * The reference to the LH subband (vertical high-pass) resulting 088 * from the decomposition of this subband. It is null by default. 089 * */ 090 public SubbandSyn subb_LH; 091 092 /** 093 * The reference to the HH subband resulting from the 094 * decomposition of this subband. It is null by default. 095 */ 096 public SubbandSyn subb_HH; 097 098 /** The horizontal analysis filter used to recompose this subband, 099 from its childs. This is applicable to "node" elements 100 only. The default value is null. */ 101 public SynWTFilter hFilter; 102 103 /** The vertical analysis filter used to decompose this subband, 104 from its childs. This is applicable to "node" elements 105 only. The default value is null. */ 106 public SynWTFilter vFilter; 107 108 /** The number of magnitude bits */ 109 public int magbits = 0; 110 111 /** 112 * Creates a SubbandSyn element with all the default values. The 113 * dimensions are (0,0) and the upper left corner is (0,0). 114 * 115 * 116 * */ 117 public SubbandSyn() { 118 } 119 120 /** 121 * Creates the top-level node and the entire subband tree, with 122 * the top-level dimensions, the number of decompositions, and the 123 * decomposition tree as specified. 124 * 125 * <P>This constructor just calls the same constructor of the 126 * super class. 127 * 128 * @param w The top-level width 129 * 130 * @param h The top-level height 131 * 132 * @param ulcx The horizontal coordinate of the upper-left corner with 133 * respect to the canvas origin, in the component grid. 134 * 135 * @param ulcy The vertical coordinate of the upper-left corner with 136 * respect to the canvas origin, in the component grid. 137 * 138 * @param lvls The number of levels (or LL decompositions) in the 139 * tree. 140 * 141 * @param hfilters The horizontal wavelet synthesis filters for each 142 * resolution level, starting at resolution level 0. 143 * 144 * @param vfilters The vertical wavelet synthesis filters for each 145 * resolution level, starting at resolution level 0. 146 * 147 * @see Subband#Subband(int,int,int,int,int, 148 * WaveletFilter[],WaveletFilter[]) 149 * 150 * 151 * */ 152 public SubbandSyn(int w, int h, int ulcx, int ulcy, int lvls, 153 WaveletFilter hfilters[], WaveletFilter vfilters[]) { 154 super(w,h,ulcx,ulcy,lvls,hfilters,vfilters); 155 } 156 157 /** 158 * Returns the parent of this subband. The parent of a subband is 159 * the subband from which this one was obtained by 160 * decomposition. The root element has no parent subband (null). 161 * 162 * @return The parent subband, or null for the root one. 163 * 164 * 165 * */ 166 public Subband getParent() { 167 return parent; 168 } 169 170 /** 171 * Returns the LL child subband of this subband. 172 * 173 * @return The LL child subband, or null if there are no childs. 174 * 175 * 176 * */ 177 public Subband getLL() { 178 return subb_LL; 179 } 180 181 /** 182 * Returns the HL (horizontal high-pass) child subband of this 183 * subband. 184 * 185 * @return The HL child subband, or null if there are no childs. 186 * 187 * 188 * */ 189 public Subband getHL() { 190 return subb_HL; 191 } 192 193 /** 194 * Returns the LH (vertical high-pass) child subband of this 195 * subband. 196 * 197 * @return The LH child subband, or null if there are no childs. 198 * 199 * 200 * */ 201 public Subband getLH() { 202 return subb_LH; 203 } 204 205 /** 206 * Returns the HH child subband of this subband. 207 * 208 * @return The HH child subband, or null if there are no childs. 209 * 210 * 211 * */ 212 public Subband getHH() { 213 return subb_HH; 214 } 215 216 /** 217 * Splits the current subband in its four subbands. It changes the 218 * status of this element (from a leaf to a node, and sets the 219 * filters), creates the childs and initializes them. An 220 * IllegalArgumentException is thrown if this subband is not a 221 * leaf. 222 * 223 * <P>It uses the initChilds() method to initialize the childs. 224 * 225 * @param hfilter The horizontal wavelet filter used to decompose 226 * this subband. It has to be a SynWTFilter object. 227 * 228 * @param vfilter The vertical wavelet filter used to decompose this 229 * subband. It has to be a SynWTFilter object. 230 * 231 * @return A reference to the LL leaf (subb_LL). 232 * 233 * @see Subband#initChilds 234 * 235 * 236 * */ 237 protected Subband split(WaveletFilter hfilter, WaveletFilter vfilter) { 238 // Test that this is a node 239 if (isNode) { 240 throw new IllegalArgumentException(); 241 } 242 243 // Modify this element into a node and set the filters 244 isNode = true; 245 this.hFilter = (SynWTFilter) hfilter; 246 this.vFilter = (SynWTFilter) vfilter; 247 248 // Create childs 249 subb_LL = new SubbandSyn(); 250 subb_LH = new SubbandSyn(); 251 subb_HL = new SubbandSyn(); 252 subb_HH = new SubbandSyn(); 253 254 // Assign parent 255 subb_LL.parent = this; 256 subb_HL.parent = this; 257 subb_LH.parent = this; 258 subb_HH.parent = this; 259 260 // Initialize childs 261 initChilds(); 262 263 // Return reference to LL subband 264 return subb_LL; 265 } 266 /** 267 * This function returns the horizontal wavelet filter relevant to this 268 * subband 269 * 270 * @return The horizontal wavelet filter 271 * 272 * 273 */ 274 public WaveletFilter getHorWFilter(){ 275 return hFilter; 276 } 277 278 /** 279 * This function returns the vertical wavelet filter relevant to this 280 * subband 281 * 282 * @return The vertical wavelet filter 283 * 284 * 285 */ 286 public WaveletFilter getVerWFilter(){ 287 return hFilter; 288 } 289 290}