Source Code Cross Referenced for QuantTypeSpec.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jj2000 » j2k » quantization » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: QuantTypeSpec.java,v $
003:         * $Revision: 1.1 $
004:         * $Date: 2005/02/11 05:02:18 $
005:         * $State: Exp $
006:         *
007:         * Class:                   QuantTypeSpec
008:         *
009:         * Description:             Quantization type specifications
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;
045:
046:        import jj2000.j2k.util.*;
047:        import jj2000.j2k.*;
048:
049:        import java.util.*;
050:
051:        import com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriteParamJava;
052:
053:        /**
054:         * This class extends ModuleSpec class in order to hold specifications about
055:         * the quantization type to use in each tile-component. Supported quantization
056:         * type are:<br>
057:         *
058:         * <ul>
059:         * <li> Reversible (no quantization)</li>
060:         * <li> Derived (the quantization step size is derived from the one of the
061:         * LL-subband)</li>
062:         * <li> Expounded (the quantization step size of each subband is signalled in
063:         * the codestream headers) </li>
064:         * </ul>
065:         *
066:         * @see ModuleSpec
067:         * */
068:        public class QuantTypeSpec extends ModuleSpec {
069:
070:            /**
071:             * Constructs an empty 'QuantTypeSpec' with specified number of tile and
072:             * components. This constructor is called by the decoder.
073:             *
074:             * @param nt Number of tiles
075:             *
076:             * @param nc Number of components
077:             *
078:             * @param type the type of the specification module i.e. tile specific,
079:             * component specific or both.
080:             * */
081:            public QuantTypeSpec(int nt, int nc, byte type) {
082:                super (nt, nc, type);
083:            }
084:
085:            /**
086:             * Constructs a new 'QuantTypeSpec' for the specified number of components
087:             * and tiles and the arguments of "-Qtype" option. This constructor is
088:             * called by the encoder.
089:             *
090:             * @param nt The number of tiles
091:             *
092:             * @param nc The number of components
093:             *
094:             * @param type the type of the specification module i.e. tile specific,
095:             * component specific or both.
096:             * */
097:            public QuantTypeSpec(int nt, int nc, byte type,
098:                    J2KImageWriteParamJava wp, String values) {
099:                super (nt, nc, type);
100:
101:                if (values == null) {
102:                    if (wp.getLossless())
103:                        setDefault("reversible");
104:                    else
105:                        setDefault("expounded");
106:                    return;
107:                }
108:
109:                // XXX: need to define it
110:                specified = values;
111:                String param = values;
112:                // Parse argument
113:                StringTokenizer stk = new StringTokenizer(param);
114:                String word; // current word
115:                byte curSpecValType = SPEC_DEF; // Specification type of the
116:                // current parameter
117:                boolean[] tileSpec = null; // Tiles concerned by the specification
118:                boolean[] compSpec = null; // Components concerned by the specification
119:
120:                while (stk.hasMoreTokens()) {
121:                    word = stk.nextToken().toLowerCase();
122:
123:                    switch (word.charAt(0)) {
124:                    case 't': // Tiles specification
125:                        tileSpec = parseIdx(word, nTiles);
126:                        if (curSpecValType == SPEC_COMP_DEF) {
127:                            curSpecValType = SPEC_TILE_COMP;
128:                        } else {
129:                            curSpecValType = SPEC_TILE_DEF;
130:                        }
131:                        break;
132:                    case 'c': // Components specification
133:                        compSpec = parseIdx(word, nComp);
134:                        if (curSpecValType == SPEC_TILE_DEF) {
135:                            curSpecValType = SPEC_TILE_COMP;
136:                        } else
137:                            curSpecValType = SPEC_COMP_DEF;
138:                        break;
139:                    case 'r': // reversible specification
140:                    case 'd': // derived quantization step size specification
141:                    case 'e': // expounded quantization step size specification
142:                        if (!word.equalsIgnoreCase("reversible")
143:                                && !word.equalsIgnoreCase("derived")
144:                                && !word.equalsIgnoreCase("expounded"))
145:                            throw new IllegalArgumentException(
146:                                    "Unknown parameter " + "for "
147:                                            + "'-Qtype' option: " + word);
148:
149:                        if (wp.getLossless()
150:                                && (word.equalsIgnoreCase("derived") || word
151:                                        .equalsIgnoreCase("expounded")))
152:                            throw new IllegalArgumentException(
153:                                    "Cannot use non " + "reversible "
154:                                            + "quantization with "
155:                                            + "'-lossless' option");
156:
157:                        if (curSpecValType == SPEC_DEF) {
158:                            setDefault(word);
159:                        } else if (curSpecValType == SPEC_TILE_DEF) {
160:                            for (int i = tileSpec.length - 1; i >= 0; i--)
161:                                if (tileSpec[i]) {
162:                                    setTileDef(i, word);
163:                                }
164:                        } else if (curSpecValType == SPEC_COMP_DEF) {
165:                            for (int i = compSpec.length - 1; i >= 0; i--)
166:                                if (compSpec[i]) {
167:                                    setCompDef(i, word);
168:                                }
169:                        } else {
170:                            for (int i = tileSpec.length - 1; i >= 0; i--) {
171:                                for (int j = compSpec.length - 1; j >= 0; j--) {
172:                                    if (tileSpec[i] && compSpec[j]) {
173:                                        setTileCompVal(i, j, word);
174:                                    }
175:                                }
176:                            }
177:                        }
178:
179:                        // Re-initialize
180:                        curSpecValType = SPEC_DEF;
181:                        tileSpec = null;
182:                        compSpec = null;
183:                        break;
184:
185:                    default:
186:                        throw new IllegalArgumentException(
187:                                "Unknown parameter for " + "'-Qtype' option: "
188:                                        + word);
189:                    }
190:                }
191:
192:                // Check that default value has been specified
193:                if (getDefault() == null) {
194:                    int ndefspec = 0;
195:                    for (int t = nt - 1; t >= 0; t--) {
196:                        for (int c = nc - 1; c >= 0; c--) {
197:                            if (specValType[t][c] == SPEC_DEF) {
198:                                ndefspec++;
199:                            }
200:                        }
201:                    }
202:
203:                    // If some tile-component have received no specification, it takes
204:                    // the default value
205:                    if (ndefspec != 0) {
206:                        if (wp.getLossless())
207:                            setDefault("reversible");
208:                        else
209:                            setDefault("expounded");
210:                    } else {
211:                        // All tile-component have been specified, takes the first
212:                        // tile-component value as default.
213:                        setDefault(getTileCompVal(0, 0));
214:                        switch (specValType[0][0]) {
215:                        case SPEC_TILE_DEF:
216:                            for (int c = nc - 1; c >= 0; c--) {
217:                                if (specValType[0][c] == SPEC_TILE_DEF)
218:                                    specValType[0][c] = SPEC_DEF;
219:                            }
220:                            tileDef[0] = null;
221:                            break;
222:                        case SPEC_COMP_DEF:
223:                            for (int t = nt - 1; t >= 0; t--) {
224:                                if (specValType[t][0] == SPEC_COMP_DEF)
225:                                    specValType[t][0] = SPEC_DEF;
226:                            }
227:                            compDef[0] = null;
228:                            break;
229:                        case SPEC_TILE_COMP:
230:                            specValType[0][0] = SPEC_DEF;
231:                            tileCompVal.put("t0c0", null);
232:                            break;
233:                        }
234:                    }
235:                }
236:            }
237:
238:            /**
239:             * Returns true if given tile-component uses derived quantization step
240:             * size.
241:             *
242:             * @param t Tile index
243:             *
244:             * @param c Component index
245:             *
246:             * @return True if derived quantization step size
247:             * */
248:            public boolean isDerived(int t, int c) {
249:                if (((String) getTileCompVal(t, c)).equals("derived"))
250:                    return true;
251:                else
252:                    return false;
253:            }
254:
255:            /**
256:             * Check the reversibility of the given tile-component.
257:             *
258:             * @param t The index of the tile
259:             *
260:             * @param c The index of the component
261:             *
262:             * @return Whether or not the tile-component is reversible
263:             * */
264:            public boolean isReversible(int t, int c) {
265:                if (((String) getTileCompVal(t, c)).equals("reversible"))
266:                    return true;
267:                else
268:                    return false;
269:            }
270:
271:            /**
272:             * Check the reversibility of the whole image.
273:             *
274:             * @return Whether or not the whole image is reversible
275:             * */
276:            public boolean isFullyReversible() {
277:                // The whole image is reversible if default specification is
278:                // rev and no tile default, component default and
279:                // tile-component value has been specificied
280:                if (((String) getDefault()).equals("reversible")) {
281:                    for (int t = nTiles - 1; t >= 0; t--)
282:                        for (int c = nComp - 1; c >= 0; c--)
283:                            if (specValType[t][c] != SPEC_DEF)
284:                                return false;
285:                    return true;
286:                }
287:
288:                return false;
289:            }
290:
291:            /**
292:             * Check the irreversibility of the whole image.
293:             *
294:             * @return Whether or not the whole image is reversible
295:             * */
296:            public boolean isFullyNonReversible() {
297:                // The whole image is irreversible no tile-component is reversible
298:                for (int t = nTiles - 1; t >= 0; t--)
299:                    for (int c = nComp - 1; c >= 0; c--)
300:                        if (((String) getSpec(t, c)).equals("reversible"))
301:                            return false;
302:                return true;
303:            }
304:
305:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.