corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * CVS identifier:
3 *
4 * $Id: ROIMaskGenerator.java,v 1.2 2000/11/27 15:03:51 grosbois Exp $
5 *
6 * Class: ROIMaskGenerator
7 *
8 * Description: This class describes generators of ROI masks
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.image;
45 using CSJ2K.j2k.quantization;
46 using CSJ2K.j2k.wavelet;
47 using CSJ2K.j2k.wavelet.analysis;
48 using CSJ2K.j2k.codestream.writer;
49 using CSJ2K.j2k.util;
50 using CSJ2K.j2k.roi;
51 namespace CSJ2K.j2k.roi.encoder
52 {
53  
54 /// <summary> This class generates the ROI masks for the ROIScaler.It gives the scaler
55 /// the ROI mask for the current code-block.
56 ///
57 /// <P>The values are calculated from the scaling factors of the ROIs. The
58 /// values with which to scale are equal to u-umin where umin is the lowest
59 /// scaling factor within the block. The umin value is sent to the entropy
60 /// coder to be used for scaling the distortion values.
61 ///
62 /// </summary>
63 /// <seealso cref="RectROIMaskGenerator">
64 ///
65 /// </seealso>
66 /// <seealso cref="ArbROIMaskGenerator">
67 ///
68 /// </seealso>
69 public abstract class ROIMaskGenerator
70 {
71 /// <summary> This function returns the ROIs in the image
72 ///
73 /// </summary>
74 /// <returns> The ROIs in the image
75 /// </returns>
76 virtual public ROI[] ROIs
77 {
78 get
79 {
80 return roi_array;
81 }
82  
83 }
84  
85 /// <summary>Array containing the ROIs </summary>
86 protected internal ROI[] roi_array;
87  
88 /// <summary>Number of components </summary>
89 protected internal int nrc;
90  
91 /// <summary>Flag indicating whether a mask has been made for the current tile </summary>
92 protected internal bool[] tileMaskMade;
93  
94 /* Flag indicating whether there are any ROIs in this tile */
95 protected internal bool roiInTile;
96  
97 /// <summary> The constructor of the mask generator
98 ///
99 /// </summary>
100 /// <param name="rois">The ROIs in the image
101 ///
102 /// </param>
103 /// <param name="nrc">The number of components
104 /// </param>
105 public ROIMaskGenerator(ROI[] rois, int nrc)
106 {
107 this.roi_array = rois;
108 this.nrc = nrc;
109 tileMaskMade = new bool[nrc];
110 }
111  
112 /// <summary> This functions gets a DataBlk with the size of the current code-block
113 /// and fills it with the ROI mask. The lowest scaling value in the mask
114 /// for this code-block is returned by the function to be used for
115 /// modifying the rate distortion estimations.
116 ///
117 /// </summary>
118 /// <param name="db">The data block that is to be filled with the mask
119 ///
120 /// </param>
121 /// <param name="sb">The root of the current subband tree
122 ///
123 /// </param>
124 /// <param name="magbits">The number of magnitude bits in this code-block
125 ///
126 /// </param>
127 /// <param name="c">Component number
128 ///
129 /// </param>
130 /// <returns> Whether or not a mask was needed for this tile
131 /// </returns>
132 public abstract bool getROIMask(DataBlkInt db, Subband sb, int magbits, int c);
133  
134 /// <summary> This function generates the ROI mask for the entire tile. The mask is
135 /// generated for one component. This method is called once for each tile
136 /// and component.
137 ///
138 /// </summary>
139 /// <param name="sb">The root of the subband tree used in the decomposition
140 ///
141 /// </param>
142 /// <param name="magbits">The max number of magnitude bits in any code-block
143 ///
144 /// </param>
145 /// <param name="n">component number
146 /// </param>
147 public abstract void makeMask(Subband sb, int magbits, int n);
148  
149 /// <summary> This function is called every time the tile is changed to indicate
150 /// that there is need to make a new mask
151 /// </summary>
152 public virtual void tileChanged()
153 {
154 for (int i = 0; i < nrc; i++)
155 tileMaskMade[i] = false;
156 }
157 }
158 }