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


001:        /*
002:         * $RCSfile: MlibSobelOpImage.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:56:06 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.mlib;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.SampleModel;
017:        import java.awt.image.Raster;
018:        import java.awt.image.RenderedImage;
019:        import java.awt.image.WritableRaster;
020:        import java.awt.image.renderable.ParameterBlock;
021:        import java.awt.image.renderable.RenderedImageFactory;
022:        import javax.media.jai.AreaOpImage;
023:        import javax.media.jai.BorderExtender;
024:        import javax.media.jai.ImageLayout;
025:        import javax.media.jai.KernelJAI;
026:        import javax.media.jai.OpImage;
027:        import java.util.Map;
028:        import com.sun.medialib.mlib.*;
029:
030:        // import com.sun.media.jai.test.OpImageTester;
031:
032:        /**
033:         * An OpImage class to perform Sobel (Gradient) on a source image.
034:         *
035:         *
036:         *
037:         * @see KernelJAI
038:         */
039:        final class MlibSobelOpImage extends AreaOpImage {
040:
041:            /**
042:             * Creates a MlibSobelOpImage given the image source.
043:             * The image dimensions are derived from the source image.
044:             * The tile grid layout, SampleModel, and ColorModel may
045:             * optionally be specified by an ImageLayout object.
046:             *
047:             * @param source a RenderedImage.
048:             * @param extender a BorderExtender, or null.
049:
050:             * @param layout an ImageLayout optionally containing the tile grid layout,
051:             *        SampleModel, and ColorModel, or null.
052:             */
053:            public MlibSobelOpImage(RenderedImage source,
054:                    BorderExtender extender, Map config, ImageLayout layout,
055:                    KernelJAI kernel) {
056:                //
057:                // Both the orthogonal pair of kernels have the same width & height
058:                // Hence either of them can be used here
059:                //
060:                super (source, layout, config, true, extender, kernel
061:                        .getLeftPadding(), kernel.getRightPadding(), kernel
062:                        .getTopPadding(), kernel.getBottomPadding());
063:            }
064:
065:            /**
066:             * Performs Sobel on a specified rectangle. The sources are cobbled.
067:             *
068:             * @param sources an array of source Rasters, guaranteed to provide all
069:             *                necessary source data for computing the output.
070:             * @param dest a WritableRaster tile containing the area to be computed.
071:             * @param destRect the rectangle within dest to be processed.
072:             */
073:            protected void computeRect(Raster[] sources, WritableRaster dest,
074:                    Rectangle destRect) {
075:                Raster source = sources[0];
076:                Rectangle srcRect = mapDestRect(destRect, 0);
077:
078:                int formatTag = MediaLibAccessor.findCompatibleTag(sources,
079:                        dest);
080:
081:                MediaLibAccessor srcAccessor = new MediaLibAccessor(source,
082:                        srcRect, formatTag);
083:                MediaLibAccessor dstAccessor = new MediaLibAccessor(dest,
084:                        destRect, formatTag);
085:                int numBands = getSampleModel().getNumBands();
086:
087:                mediaLibImage[] srcML = srcAccessor.getMediaLibImages();
088:                mediaLibImage[] dstML = dstAccessor.getMediaLibImages();
089:                for (int i = 0; i < dstML.length; i++) {
090:                    switch (dstAccessor.getDataType()) {
091:                    case DataBuffer.TYPE_BYTE:
092:                    case DataBuffer.TYPE_USHORT:
093:                    case DataBuffer.TYPE_SHORT:
094:                    case DataBuffer.TYPE_INT:
095:                        Image.Sobel(dstML[i], srcML[i], ((1 << numBands) - 1),
096:                                Constants.MLIB_EDGE_DST_NO_WRITE);
097:                        break;
098:
099:                    case DataBuffer.TYPE_FLOAT:
100:                    case DataBuffer.TYPE_DOUBLE:
101:                        Image.Sobel_Fp(dstML[i], srcML[i],
102:                                ((1 << numBands) - 1),
103:                                Constants.MLIB_EDGE_DST_NO_WRITE);
104:                        break;
105:
106:                    default:
107:                        String className = this .getClass().getName();
108:                        throw new RuntimeException(JaiI18N
109:                                .getString("Generic2"));
110:                    }
111:                }
112:
113:                if (dstAccessor.isDataCopy()) {
114:                    dstAccessor.copyDataToRaster();
115:                }
116:            }
117:
118:            //     public static OpImage createTestImage(OpImageTester oit) {
119:            //         float data_h[] = {-1.0f, -2.0f, -1.0f,
120:            //                            0.0f,  0.0f,  0.0f,
121:            //                            1.0f,  2.0f,  1.0f};
122:            //         float data_v[] = {-1.0f, 0.0f, 1.0f,
123:            //                           -2.0f, 0.0f, 2.0f,
124:            //                           -1.0f, 0.0f, 1.0f};
125:
126:            //         KernelJAI kern_h = new KernelJAI(3,3,data_h);
127:            //         KernelJAI kern_v = new KernelJAI(3,3,data_v);
128:
129:            //         return new MlibSobelOpImage(oit.getSource(), null, null,
130:            //                                     new ImageLayout(oit.getSource()),
131:            //                                     kern_h);
132:            //     }
133:
134:            //     public static void main (String args[]) {
135:            //         String classname = "com.sun.media.jai.mlib.MlibSobelOpImage";
136:            //         OpImageTester.performDiagnostics(classname,args);
137:            //     }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.