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