corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * CVS identifier:
3 *
4 * $Id: SubbandRectROIMask.java,v 1.3 2001/02/28 14:53:12 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 class describes the ROI mask for a single subband. Each object of the
55 /// class contains the mask for a particular subband and also has references to
56 /// the masks of the children subbands of the subband corresponding to this
57 /// mask. This class describes subband masks for images containing only
58 /// rectangular ROIS
59 ///
60 /// </summary>
61 public class SubbandRectROIMask:SubbandROIMask
62 {
63  
64 /// <summary>The upper left x coordinates of the applicable ROIs </summary>
65 public int[] ulxs;
66  
67 /// <summary>The upper left y coordinates of the applicable ROIs </summary>
68 public int[] ulys;
69  
70 /// <summary>The lower right x coordinates of the applicable ROIs </summary>
71 public int[] lrxs;
72  
73 /// <summary>The lower right y coordinates of the applicable ROIs </summary>
74 public int[] lrys;
75  
76 /// <summary> The constructor of the SubbandROIMask takes the dimensions of the
77 /// subband as parameters. A tree of masks is generated from the subband
78 /// sb. Each Subband contains the boundaries of each ROI.
79 ///
80 /// </summary>
81 /// <param name="sb">The subband corresponding to this Subband Mask
82 ///
83 /// </param>
84 /// <param name="ulxs">The upper left x coordinates of the ROIs
85 ///
86 /// </param>
87 /// <param name="ulys">The upper left y coordinates of the ROIs
88 ///
89 /// </param>
90 /// <param name="lrxs">The lower right x coordinates of the ROIs
91 ///
92 /// </param>
93 /// <param name="lrys">The lower right y coordinates of the ROIs
94 ///
95 /// </param>
96 /// <param name="lrys">The lower right y coordinates of the ROIs
97 ///
98 /// </param>
99 /// <param name="nr">Number of ROIs that affect this tile
100 ///
101 /// </param>
102 public SubbandRectROIMask(Subband sb, int[] ulxs, int[] ulys, int[] lrxs, int[] lrys, int nr):base(sb.ulx, sb.uly, sb.w, sb.h)
103 {
104 this.ulxs = ulxs;
105 this.ulys = ulys;
106 this.lrxs = lrxs;
107 this.lrys = lrys;
108 int r;
109  
110 if (sb.isNode)
111 {
112 isNode = true;
113 // determine odd/even - high/low filters
114 int horEvenLow = sb.ulcx % 2;
115 int verEvenLow = sb.ulcy % 2;
116  
117 // Get filter support lengths
118 WaveletFilter hFilter = sb.HorWFilter;
119 WaveletFilter vFilter = sb.VerWFilter;
120 int hlnSup = hFilter.SynLowNegSupport;
121 int hhnSup = hFilter.SynHighNegSupport;
122 int hlpSup = hFilter.SynLowPosSupport;
123 int hhpSup = hFilter.SynHighPosSupport;
124 int vlnSup = vFilter.SynLowNegSupport;
125 int vhnSup = vFilter.SynHighNegSupport;
126 int vlpSup = vFilter.SynLowPosSupport;
127 int vhpSup = vFilter.SynHighPosSupport;
128  
129 // Generate arrays for children
130 int x, y;
131 int[] lulxs = new int[nr];
132 int[] lulys = new int[nr];
133 int[] llrxs = new int[nr];
134 int[] llrys = new int[nr];
135 int[] hulxs = new int[nr];
136 int[] hulys = new int[nr];
137 int[] hlrxs = new int[nr];
138 int[] hlrys = new int[nr];
139 for (r = nr - 1; r >= 0; r--)
140 {
141 // For all ROI calculate ...
142 // Upper left x for all children
143 x = ulxs[r];
144 if (horEvenLow == 0)
145 {
146 lulxs[r] = (x + 1 - hlnSup) / 2;
147 hulxs[r] = (x - hhnSup) / 2;
148 }
149 else
150 {
151 lulxs[r] = (x - hlnSup) / 2;
152 hulxs[r] = (x + 1 - hhnSup) / 2;
153 }
154 // Upper left y for all children
155 y = ulys[r];
156 if (verEvenLow == 0)
157 {
158 lulys[r] = (y + 1 - vlnSup) / 2;
159 hulys[r] = (y - vhnSup) / 2;
160 }
161 else
162 {
163 lulys[r] = (y - vlnSup) / 2;
164 hulys[r] = (y + 1 - vhnSup) / 2;
165 }
166 // lower right x for all children
167 x = lrxs[r];
168 if (horEvenLow == 0)
169 {
170 llrxs[r] = (x + hlpSup) / 2;
171 hlrxs[r] = (x - 1 + hhpSup) / 2;
172 }
173 else
174 {
175 llrxs[r] = (x - 1 + hlpSup) / 2;
176 hlrxs[r] = (x + hhpSup) / 2;
177 }
178 // lower right y for all children
179 y = lrys[r];
180 if (verEvenLow == 0)
181 {
182 llrys[r] = (y + vlpSup) / 2;
183 hlrys[r] = (y - 1 + vhpSup) / 2;
184 }
185 else
186 {
187 llrys[r] = (y - 1 + vlpSup) / 2;
188 hlrys[r] = (y + vhpSup) / 2;
189 }
190 }
191 // Create children
192 hh = new SubbandRectROIMask(sb.HH, hulxs, hulys, hlrxs, hlrys, nr);
193 lh = new SubbandRectROIMask(sb.LH, lulxs, hulys, llrxs, hlrys, nr);
194 hl = new SubbandRectROIMask(sb.HL, hulxs, lulys, hlrxs, llrys, nr);
195 ll = new SubbandRectROIMask(sb.LL, lulxs, lulys, llrxs, llrys, nr);
196 }
197 }
198 }
199 }