Source Code Cross Referenced for BinarizeDescriptor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » operator » 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 » javax.media.jai.operator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: BinarizeDescriptor.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:30 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.operator;
013:
014:        import java.awt.RenderingHints;
015:        import java.awt.image.RenderedImage;
016:        import java.awt.image.renderable.ParameterBlock;
017:        import java.awt.image.renderable.RenderableImage;
018:        import javax.media.jai.JAI;
019:        import javax.media.jai.OperationDescriptorImpl;
020:        import javax.media.jai.ParameterBlockJAI;
021:        import javax.media.jai.RenderableOp;
022:        import javax.media.jai.RenderedOp;
023:        import javax.media.jai.registry.RenderableRegistryMode;
024:        import javax.media.jai.registry.RenderedRegistryMode;
025:
026:        /**
027:         * An <code>OperationDescriptor</code> describing the "Binarize" operation.
028:         *
029:         * <p> The "Binarize" operation takes one rendered or renderable single-banded
030:         * source image and a threshold value and applies a thresholding operation to
031:         * the produce a bilevel image.
032:         *
033:         * <p> By default the destination image bounds are equal to those of the
034:         * source image.  The <code>SampleModel</code> of the destination image is
035:         * an instance of <code>MultiPixelPackedSampleModel</code>.
036:         * 
037:         * <p> The pseudocode for "Binarize" is as follows:
038:         * <pre> 
039:         *      dst(x, y) = src(x, y) >= threshold ? 1 : 0;
040:         * </pre>
041:         *
042:         * <p><table border=1>
043:         * <caption>Resource List</caption>
044:         * <tr><th>Name</th>        <th>Value</th></tr>
045:         * <tr><td>GlobalName</td>  <td>Binarize</td></tr>
046:         * <tr><td>LocalName</td>   <td>Binarize</td></tr>
047:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
048:         * <tr><td>Description</td> <td>Thresholds an image into a bilevel image.<td></tr>
049:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BinarizeDescriptor.html</td></tr>
050:         * <tr><td>Version</td>     <td>1.1</td></tr>
051:         * <tr><td>arg0Desc</td>    <td>The threshold value.</td></tr>
052:         * </table></p>
053:         *
054:         * <p><table border=1>
055:         * <caption>Parameter List</caption>
056:         * <tr><th>Name</th>      <th>Class Type</th>
057:         *                        <th>Default Value</th></tr>
058:         * <tr><td>threshold</td> <td>java.lang.Double</td>
059:         *                        <td>NO_PARAMETER_DEFAULT</td>
060:         * </table></p>
061:         *
062:         * @see javax.media.jai.OperationDescriptor
063:         *
064:         * @since JAI 1.1
065:         */
066:        public class BinarizeDescriptor extends OperationDescriptorImpl {
067:
068:            /**
069:             * The resource strings that provide the general documentation
070:             * and specify the parameter list for this operation.
071:             */
072:            private static final String[][] resources = {
073:                    { "GlobalName", "Binarize" },
074:                    { "LocalName", "Binarize" },
075:                    { "Vendor", "com.sun.media.jai" },
076:                    { "Description", JaiI18N.getString("BinarizeDescriptor0") },
077:                    {
078:                            "DocURL",
079:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/BinarizeDescriptor.html" },
080:                    { "Version", JaiI18N.getString("DescriptorVersion") },
081:                    { "arg0Desc", JaiI18N.getString("BinarizeDescriptor1") } };
082:
083:            /** The parameter name list for this operation. */
084:            private static final String[] paramNames = { "threshold" };
085:
086:            /**
087:             * The parameter class list for this operation.
088:             * The number of threshold value provided should be 1.
089:             */
090:            private static final Class[] paramClasses = { java.lang.Double.class };
091:
092:            /** The parameter default value list for this operation. */
093:            private static final Object[] paramDefaults = { NO_PARAMETER_DEFAULT };
094:
095:            private static final String[] supportedModes = { "rendered",
096:                    "renderable" };
097:
098:            /** Constructor. */
099:            public BinarizeDescriptor() {
100:                super (resources, supportedModes, 1, paramNames, paramClasses,
101:                        paramDefaults, null);
102:            }
103:
104:            /**
105:             * Validates the input source.
106:             *
107:             * <p> In addition to the standard checks performed by the
108:             * superclass method, this method checks that the source image
109:             * is single-banded.
110:             */
111:            protected boolean validateSources(String modeName,
112:                    ParameterBlock args, StringBuffer msg) {
113:                if (!super .validateSources(modeName, args, msg)) {
114:                    return false;
115:                }
116:
117:                if (!modeName.equalsIgnoreCase("rendered"))
118:                    return true;
119:
120:                RenderedImage source = (RenderedImage) (args.getSource(0));
121:                int numBands = source.getSampleModel().getNumBands();
122:                if (numBands != 1) {
123:                    msg.append(getName() + " "
124:                            + JaiI18N.getString("BinarizeDescriptor2"));
125:                    return false;
126:                }
127:
128:                return true;
129:            }
130:
131:            /**
132:             * Binarize an image from a threshold value.
133:             *
134:             * <p>Creates a <code>ParameterBlockJAI</code> from all
135:             * supplied arguments except <code>hints</code> and invokes
136:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
137:             *
138:             * @see JAI
139:             * @see ParameterBlockJAI
140:             * @see RenderedOp
141:             *
142:             * @param source0 <code>RenderedImage</code> source 0.
143:             * @param threshold Argment must be of type java.lang.Double.
144:             * @param hints The <code>RenderingHints</code> to use.
145:             * May be <code>null</code>.
146:             * @return The <code>RenderedOp</code> destination.
147:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
148:             * @throws IllegalArgumentException if <code>threshold</code> is <code>null</code>.
149:             */
150:            public static RenderedOp create(RenderedImage source0,
151:                    Double threshold, RenderingHints hints) {
152:                ParameterBlockJAI pb = new ParameterBlockJAI("Binarize",
153:                        RenderedRegistryMode.MODE_NAME);
154:
155:                pb.setSource("source0", source0);
156:
157:                pb.setParameter("threshold", threshold);
158:
159:                return JAI.create("Binarize", pb, hints);
160:            }
161:
162:            /**
163:             * Binarize an image from a threshold value.
164:             *
165:             * <p>Creates a <code>ParameterBlockJAI</code> from all
166:             * supplied arguments except <code>hints</code> and invokes
167:             * {@link JAI#createRenderable(String,ParameterBlock,RenderingHints)}.
168:             *
169:             * @see JAI
170:             * @see ParameterBlockJAI
171:             * @see RenderableOp
172:             *
173:             * @param source0 <code>RenderableImage</code> source 0.
174:             * @param threshold Argment must be of type java.lang.Double.
175:             * @param hints The <code>RenderingHints</code> to use.
176:             * May be <code>null</code>.
177:             * @return The <code>RenderableOp</code> destination.
178:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
179:             * @throws IllegalArgumentException if <code>threshold</code> is <code>null</code>.
180:             */
181:            public static RenderableOp createRenderable(
182:                    RenderableImage source0, Double threshold,
183:                    RenderingHints hints) {
184:                ParameterBlockJAI pb = new ParameterBlockJAI("Binarize",
185:                        RenderableRegistryMode.MODE_NAME);
186:
187:                pb.setSource("source0", source0);
188:
189:                pb.setParameter("threshold", threshold);
190:
191:                return JAI.createRenderable("Binarize", pb, hints);
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.