corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * CVS identifier:
3 *
4 * $Id: SubbandROIMask.java,v 1.2 2001/02/28 15:12:44 grosbois Exp $
5 *
6 * Class: ROI
7 *
8 * Description: This class describes the ROI mask for a subband
9 *
10 *
11 *
12 * COPYRIGHT:
13 *
14 * This software module was originally developed by Raphaël Grosbois and
15 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
16 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
17 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
18 * Centre France S.A) in the course of development of the JPEG2000
19 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
20 * software module is an implementation of a part of the JPEG 2000
21 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
22 * Systems AB and Canon Research Centre France S.A (collectively JJ2000
23 * Partners) agree not to assert against ISO/IEC and users of the JPEG
24 * 2000 Standard (Users) any of their rights under the copyright, not
25 * including other intellectual property rights, for this software module
26 * with respect to the usage by ISO/IEC and Users of this software module
27 * or modifications thereof for use in hardware or software products
28 * claiming conformance to the JPEG 2000 Standard. Those intending to use
29 * this software module in hardware or software products are advised that
30 * their use may infringe existing patents. The original developers of
31 * this software module, JJ2000 Partners and ISO/IEC assume no liability
32 * for use of this software module or modifications thereof. No license
33 * or right to this software module is granted for non JPEG 2000 Standard
34 * conforming products. JJ2000 Partners have full right to use this
35 * software module for his/her own purpose, assign or donate this
36 * software module to any third party and to inhibit third parties from
37 * using this software module for non JPEG 2000 Standard conforming
38 * products. This copyright notice must be included in all copies or
39 * derivative works of this software module.
40 *
41 * Copyright (c) 1999/2000 JJ2000 Partners.
42 * */
43 using System;
44 using CSJ2K.j2k.codestream.writer;
45 using CSJ2K.j2k.wavelet.analysis;
46 using CSJ2K.j2k.quantization;
47 using CSJ2K.j2k.wavelet;
48 using CSJ2K.j2k.image;
49 using CSJ2K.j2k.util;
50 using CSJ2K.j2k.roi;
51 namespace CSJ2K.j2k.roi.encoder
52 {
53  
54 /// <summary> This abstract class describes the ROI mask for a single subband. Each
55 /// object of the class contains the mask for a particular subband and also has
56 /// references to the masks of the children subbands of the subband
57 /// corresponding to this mask.
58 /// </summary>
59 public abstract class SubbandROIMask
60 {
61  
62 /// <summary>The subband masks of the child LL </summary>
63 protected internal SubbandROIMask ll;
64  
65 /// <summary>The subband masks of the child LH </summary>
66 protected internal SubbandROIMask lh;
67  
68 /// <summary>The subband masks of the child HL </summary>
69 protected internal SubbandROIMask hl;
70  
71 /// <summary>The subband masks of the child HH </summary>
72 protected internal SubbandROIMask hh;
73  
74 /// <summary>Flag indicating whether this subband mask is a node or not </summary>
75 protected internal bool isNode;
76  
77 /// <summary>Horizontal uper-left coordinate of the subband mask </summary>
78 public int ulx;
79  
80 /// <summary>Vertical uper-left coordinate of the subband mask </summary>
81 public int uly;
82  
83 /// <summary>Width of the subband mask </summary>
84 public int w;
85  
86 /// <summary>Height of the subband mask </summary>
87 public int h;
88  
89 /// <summary> The constructor of the SubbandROIMask takes the dimensions of the
90 /// subband as parameters
91 ///
92 /// </summary>
93 /// <param name="ulx">The upper left x coordinate of corresponding subband
94 ///
95 /// </param>
96 /// <param name="uly">The upper left y coordinate of corresponding subband
97 ///
98 /// </param>
99 /// <param name="w">The width of corresponding subband
100 ///
101 /// </param>
102 /// <param name="h">The height of corresponding subband
103 ///
104 /// </param>
105 public SubbandROIMask(int ulx, int uly, int w, int h)
106 {
107 this.ulx = ulx;
108 this.uly = uly;
109 this.w = w;
110 this.h = h;
111 }
112  
113 /// <summary> Returns a reference to the Subband mask element to which the specified
114 /// point belongs. The specified point must be inside this (i.e. the one
115 /// defined by this object) subband mask. This method searches through the
116 /// tree.
117 ///
118 /// </summary>
119 /// <param name="x">horizontal coordinate of the specified point.
120 ///
121 /// </param>
122 /// <param name="y">horizontal coordinate of the specified point.
123 ///
124 /// </param>
125 public virtual SubbandROIMask getSubbandRectROIMask(int x, int y)
126 {
127 SubbandROIMask cur, hhs;
128  
129 // Check that we are inside this subband
130 if (x < ulx || y < uly || x >= ulx + w || y >= uly + h)
131 {
132 throw new System.ArgumentException();
133 }
134  
135 cur = this;
136 while (cur.isNode)
137 {
138 hhs = cur.hh;
139 // While we are still at a node -> continue
140 if (x < hhs.ulx)
141 {
142 // Is the result of horizontal low-pass
143 if (y < hhs.uly)
144 {
145 // Vertical low-pass
146 cur = cur.ll;
147 }
148 else
149 {
150 // Vertical high-pass
151 cur = cur.lh;
152 }
153 }
154 else
155 {
156 // Is the result of horizontal high-pass
157 if (y < hhs.uly)
158 {
159 // Vertical low-pass
160 cur = cur.hl;
161 }
162 else
163 {
164 // Vertical high-pass
165 cur = cur.hh;
166 }
167 }
168 }
169 return cur;
170 }
171 }
172 }