Source Code Cross Referenced for Dequantizer.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jj2000 » j2k » quantization » dequantizer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » jj2000.j2k.quantization.dequantizer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: Dequantizer.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:18 $
005:         * $State: Exp $
006:         *
007:         * Class:                   Dequantizer
008:         *
009:         * Description:             The abstract class for all dequantizers.
010:         *
011:         *
012:         *
013:         * COPYRIGHT:
014:         *
015:         * This software module was originally developed by Raphaël Grosbois and
016:         * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
017:         * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
018:         * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
019:         * Centre France S.A) in the course of development of the JPEG2000
020:         * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
021:         * software module is an implementation of a part of the JPEG 2000
022:         * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
023:         * Systems AB and Canon Research Centre France S.A (collectively JJ2000
024:         * Partners) agree not to assert against ISO/IEC and users of the JPEG
025:         * 2000 Standard (Users) any of their rights under the copyright, not
026:         * including other intellectual property rights, for this software module
027:         * with respect to the usage by ISO/IEC and Users of this software module
028:         * or modifications thereof for use in hardware or software products
029:         * claiming conformance to the JPEG 2000 Standard. Those intending to use
030:         * this software module in hardware or software products are advised that
031:         * their use may infringe existing patents. The original developers of
032:         * this software module, JJ2000 Partners and ISO/IEC assume no liability
033:         * for use of this software module or modifications thereof. No license
034:         * or right to this software module is granted for non JPEG 2000 Standard
035:         * conforming products. JJ2000 Partners have full right to use this
036:         * software module for his/her own purpose, assign or donate this
037:         * software module to any third party and to inhibit third parties from
038:         * using this software module for non JPEG 2000 Standard conforming
039:         * products. This copyright notice must be included in all copies or
040:         * derivative works of this software module.
041:         *
042:         * Copyright (c) 1999/2000 JJ2000 Partners.
043:         */
044:        package jj2000.j2k.quantization.dequantizer;
045:
046:        import jj2000.j2k.image.invcomptransf.*;
047:        import jj2000.j2k.wavelet.synthesis.*;
048:        import jj2000.j2k.entropy.decoder.*;
049:        import jj2000.j2k.codestream.*;
050:        import jj2000.j2k.entropy.*;
051:        import jj2000.j2k.decoder.*;
052:        import jj2000.j2k.wavelet.*;
053:        import jj2000.j2k.image.*;
054:        import jj2000.j2k.io.*;
055:        import jj2000.j2k.*;
056:
057:        import java.io.*;
058:
059:        /**
060:         * This is the abstract class from which all dequantizers must inherit. This
061:         * class has the concept of a current tile and all operations are performed on
062:         * the current tile.
063:         *
064:         * <p>This class provides default implemenations for most of the methods
065:         * (wherever it makes sense), under the assumption that the image and
066:         * component dimensions, and the tiles, are not modifed by the dequantizer. If
067:         * that is not the case for a particular implementation then the methods
068:         * should be overriden.</p>
069:         *
070:         * <p>Sign magnitude representation is used (instead of two's complement) for
071:         * the input data. The most significant bit is used for the sign (0 if
072:         * positive, 1 if negative). Then the magnitude of the quantized coefficient
073:         * is stored in the next most significat bits. The most significant magnitude
074:         * bit corresponds to the most significant bit-plane and so on.</p>
075:         *
076:         * <p>The output data is either in floating-point, or in fixed-point two's
077:         * complement. In case of floating-point data the the value returned by
078:         * getFixedPoint() must be 0. If the case of fixed-point data the number of
079:         * fractional bits must be defined at the constructor of the implementing
080:         * class and all operations must be performed accordingly. Each component may
081:         * have a different number of fractional bits.</p>
082:         * */
083:        public abstract class Dequantizer extends MultiResImgDataAdapter
084:                implements  CBlkWTDataSrcDec {
085:
086:            /** The prefix for dequantizer options: 'Q' */
087:            public final static char OPT_PREFIX = 'Q';
088:
089:            /** The list of parameters that is accepted by the bit stream
090:             * readers. They start with 'Q' */
091:            private static final String[][] pinfo = null;
092:
093:            /** The entropy decoder from where to get the quantized data (the
094:             * source). */
095:            protected CBlkQuantDataSrcDec src;
096:
097:            /** The "range bits" for each transformed component */
098:            protected int rb[] = null;
099:
100:            /** The "range bits" for each un-transformed component */
101:            protected int utrb[] = null;
102:
103:            /** The inverse component transformation specifications */
104:            private CompTransfSpec cts;
105:
106:            /** Reference to the wavelet filter specifications */
107:            private SynWTFilterSpec wfs;
108:
109:            /**
110:             * Initializes the source of compressed data.
111:             *
112:             * @param src From where to obtain the quantized data.
113:             *
114:             * @param rb The number of "range bits" for each component (must be the
115:             * "range bits" of the un-transformed components. For a definition of
116:             * "range bits" see the getNomRangeBits() method.
117:             *
118:             * @see #getNomRangeBits
119:             * */
120:            public Dequantizer(CBlkQuantDataSrcDec src, int utrb[],
121:                    DecoderSpecs decSpec) {
122:                super (src);
123:                if (utrb.length != src.getNumComps()) {
124:                    throw new IllegalArgumentException();
125:                }
126:                this .src = src;
127:                this .utrb = utrb;
128:                this .cts = decSpec.cts;
129:                this .wfs = decSpec.wfs;
130:            }
131:
132:            /**
133:             * Returns the number of bits, referred to as the "range bits",
134:             * corresponding to the nominal range of the data in the specified
135:             * component.
136:             *
137:             * <p>The returned value corresponds to the nominal dynamic range of the
138:             * reconstructed image data, not of the wavelet coefficients
139:             * themselves. This is because different subbands have different gains and
140:             * thus different nominal ranges. To have an idea of the nominal range in
141:             * each subband the subband analysis gain value from the subband tree
142:             * structure, returned by the getSynSubbandTree() method, can be used. See
143:             * the Subband class for more details.</p>
144:             *
145:             * <p>If this number is <i>b</b> then for unsigned data the nominal range
146:             * is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and
147:             * 2^(b-1)-1.</p>
148:             *
149:             * @param c The index of the component
150:             *
151:             * @return The number of bits corresponding to the nominal range of the
152:             * data.
153:             *
154:             * @see Subband
155:             * */
156:            public int getNomRangeBits(int c) {
157:                return rb[c];
158:            }
159:
160:            /**
161:             * Returns the subband tree, for the specified tile-component. This method
162:             * returns the root element of the subband tree structure, see Subband and
163:             * SubbandSyn. The tree comprises all the available resolution levels.
164:             *
165:             * <P>The number of magnitude bits ('magBits' member variable) for each
166:             * subband may have not been not initialized (it depends on the actual
167:             * dequantizer and its implementation). However, they are not necessary
168:             * for the subsequent steps in the decoder chain.
169:             *
170:             * @param t The index of the tile, from 0 to T-1.
171:             *
172:             * @param c The index of the component, from 0 to C-1.
173:             *
174:             * @return The root of the tree structure.
175:             * */
176:            public SubbandSyn getSynSubbandTree(int t, int c) {
177:                return src.getSynSubbandTree(t, c);
178:            }
179:
180:            /**
181:             * Returns the horizontal code-block partition origin. Allowable values
182:             * are 0 and 1, nothing else.
183:             * */
184:            public int getCbULX() {
185:                return src.getCbULX();
186:            }
187:
188:            /**
189:             * Returns the vertical code-block partition origin. Allowable values are
190:             * 0 and 1, nothing else.
191:             * */
192:            public int getCbULY() {
193:                return src.getCbULY();
194:            }
195:
196:            /**
197:             * Returns the parameters that are used in this class and
198:             * implementing classes. It returns a 2D String array. Each of the
199:             * 1D arrays is for a different option, and they have 3
200:             * elements. The first element is the option name, the second one
201:             * is the synopsis and the third one is a long description of what
202:             * the parameter is. The synopsis or description may be 'null', in
203:             * which case it is assumed that there is no synopsis or
204:             * description of the option, respectively. Null may be returned
205:             * if no options are supported.
206:             *
207:             * @return the options name, their synopsis and their explanation, 
208:             * or null if no options are supported.
209:             * */
210:            public static String[][] getParameterInfo() {
211:                return pinfo;
212:            }
213:
214:            /**
215:             * Changes the current tile, given the new indexes. An
216:             * IllegalArgumentException is thrown if the indexes do not
217:             * correspond to a valid tile.
218:             *
219:             * <P>This default implementation changes the tile in the source
220:             * and re-initializes properly component transformation variables..
221:             *
222:             * @param x The horizontal index of the tile.
223:             *
224:             * @param y The vertical index of the new tile.
225:             * */
226:            public void setTile(int x, int y) {
227:                src.setTile(x, y);
228:                tIdx = getTileIdx(); // index of the current tile
229:
230:                // initializations
231:                int cttype = 0;
232:                if (((Integer) cts.getTileDef(tIdx)).intValue() == InvCompTransf.NONE)
233:                    cttype = InvCompTransf.NONE;
234:                else {
235:                    int nc = src.getNumComps() > 3 ? 3 : src.getNumComps();
236:                    int rev = 0;
237:                    for (int c = 0; c < nc; c++)
238:                        rev += (wfs.isReversible(tIdx, c) ? 1 : 0);
239:                    if (rev == 3) {
240:                        // All WT are reversible
241:                        cttype = InvCompTransf.INV_RCT;
242:                    } else if (rev == 0) {
243:                        // All WT irreversible
244:                        cttype = InvCompTransf.INV_ICT;
245:                    } else {
246:                        // Error
247:                        throw new IllegalArgumentException(
248:                                "Wavelet transformation " + "and "
249:                                        + "component transformation"
250:                                        + " not coherent in tile" + tIdx);
251:                    }
252:                }
253:
254:                switch (cttype) {
255:                case InvCompTransf.NONE:
256:                    rb = utrb;
257:                    break;
258:                case InvCompTransf.INV_RCT:
259:                    rb = InvCompTransf.calcMixedBitDepths(utrb,
260:                            InvCompTransf.INV_RCT, null);
261:                    break;
262:                case InvCompTransf.INV_ICT:
263:                    rb = InvCompTransf.calcMixedBitDepths(utrb,
264:                            InvCompTransf.INV_ICT, null);
265:                    break;
266:                default:
267:                    throw new IllegalArgumentException("Non JPEG 2000 part I "
268:                            + "component" + " transformation for tile: " + tIdx);
269:                }
270:            }
271:
272:            /**
273:             * Advances to the next tile, in standard scan-line order (by rows then
274:             * columns). An NoNextElementException is thrown if the current tile is
275:             * the last one (i.e. there is no next tile).
276:             *
277:             * <P>This default implementation just advances to the next tile in the
278:             * source and re-initializes properly component transformation variables.
279:             * */
280:            public void nextTile() {
281:                src.nextTile();
282:                tIdx = getTileIdx(); // index of the current tile
283:
284:                // initializations
285:                int cttype = ((Integer) cts.getTileDef(tIdx)).intValue();
286:                switch (cttype) {
287:                case InvCompTransf.NONE:
288:                    rb = utrb;
289:                    break;
290:                case InvCompTransf.INV_RCT:
291:                    rb = InvCompTransf.calcMixedBitDepths(utrb,
292:                            InvCompTransf.INV_RCT, null);
293:                    break;
294:                case InvCompTransf.INV_ICT:
295:                    rb = InvCompTransf.calcMixedBitDepths(utrb,
296:                            InvCompTransf.INV_ICT, null);
297:                    break;
298:                default:
299:                    throw new IllegalArgumentException("Non JPEG 2000 part I "
300:                            + "component" + " transformation for tile: " + tIdx);
301:                }
302:            }
303:
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.