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


java.lang.Object
   javax.media.jai.Warp
      javax.media.jai.WarpGrid

WarpGrid
final public class WarpGrid extends Warp (Code)
A regular grid-based description of an image warp.

The mapping from destination pixels to source positions is described by bilinear interpolation within a rectilinear grid of points with known mappings.

Given a destination pixel coordinate (x, y) that lies within a cell having corners at (x0, y0), (x1, y0), (x0, y1) and (x1, y1), with source coordinates defined at each respective corner equal to (sx0, sy0), (sx1, sy1), (sx2, sy2) and (sx3, sy3), the source position (sx, sy) that maps onto (x, y) is given by the formulas:

 xfrac = (x - x0)/(x1 - x0)
 yfrac = (y - y0)/(y1 - y0)
 s = sx0 + (sx1 - sx0)*xfrac
 t = sy0 + (sy1 - sy0)*xfrac
 u = sx2 + (sx3 - sx2)*xfrac
 v = sy2 + (sy3 - sy2)*xfrac
 sx = s + (u - s)*yfrac
 sy = t + (v - t)*yfrac
 

In other words, the source x and y values are interpolated horizontally along the top and bottom edges of the grid cell, and the results are interpolated vertically:

 (x0, y0) ->            (x1, y0) ->
 (sx0, sy0)             (sx1, sy1)
 +------------+---------+
 |            |\        |
 |            | (s, t)  |
 |            |         |
 |            |         |
 |            |         |
 |            |         |
 | (x, y) ->  |         |
 |  (sx, sy)--+         |
 |            |         |
 |            |         |
 |            | (u, v)  |
 |            |/        |
 +------------+---------+
 (x0, y1) ->          (x1, y1) ->
 (sx2, sy2)           (sx3, sy3)
 

Points outside the bounds of the cells defining the grid warp will be mapped to the source image using the identity transformation.

WarpGrid is marked final so that it may be more easily inlined.




Constructor Summary
public  WarpGrid(int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells, float[] warpPositions)
     Constructs a WarpGrid with a given grid-based transform mapping destination pixels into source space.
public  WarpGrid(Warp master, int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells)
     Constructs a WarpGrid object by sampling the displacements given by another Warp object of any kind.

The grid is defined by a set of equal-sized cells. The grid starts at (xStart, yStart).


Method Summary
public  intgetXNumCells()
     Returns the number of grid cell columns.
public  intgetXStart()
     Returns the minimum X coordinate of the grid.
public  intgetXStep()
     Returns the horizontal spacing between grid cells.
public  float[]getXWarpPos()
     Returns the horizontal warp positions at the grid points.
public  intgetYNumCells()
     Returns the number of grid cell rows.
public  intgetYStart()
     Returns the minimum Y coordinate of the grid.
public  intgetYStep()
     Returns the vertical spacing between grid cells.
public  float[]getYWarpPos()
     Returns the vertical warp positions at the grid points.
public  Point2DmapDestPoint(Point2D destPt)
     Computes the source point corresponding to the supplied point.

This method returns the value of pt in the following code snippet:

 float[] sxy = warpSparseRect((int)destPt.getX(), (int)destPt.getY(),
 2, 2, 1, 1, null);
 double wtRight  = destPt.getX() - (int)destPt.getX();
 double wtLeft   = 1.0 - wtRight;
 double wtBottom = destPt.getY() - (int)destPt.getY();
 double wtTop    = 1.0 - wtBottom;
 Point2D pt = (Point2D)destPt.clone();
 pt.setLocation((sxy[0]*wtLeft + sxy[2]*wtRight)*wtTop +
 (sxy[4]*wtLeft + sxy[6]*wtRight)*wtBottom,
 (sxy[1]*wtLeft + sxy[3]*wtRight)*wtTop +
 (sxy[5]*wtLeft + sxy[7]*wtRight)*wtBottom);
 


Parameters:
  destPt - the position in destination image coordinatesto map to source image coordinates.
public  float[]warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)
     Computes the source subpixel positions for a given rectangular destination region, subsampled with an integral period.

Points outside the bounds of the cells defining the grid warp will be mapped to the source image using the identity transformation.
Parameters:
  x - The minimum X coordinate of the destination region.
Parameters:
  y - The minimum Y coordinate of the destination region.
Parameters:
  width - The width of the destination region.
Parameters:
  height - The height of the destination region.
Parameters:
  periodX - The horizontal sampling period.
Parameters:
  periodY - The vertical sampling period.
Parameters:
  destRect - An int array containing at least2*((width+periodX-1)/periodX)*((height+periodY-1)/periodY)elements, or null.



Constructor Detail
WarpGrid
public WarpGrid(int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells, float[] warpPositions)(Code)
Constructs a WarpGrid with a given grid-based transform mapping destination pixels into source space. Note that this is a backward mapping as opposed to the forward mapping used in AffineOpImage.

The grid is defined by a set of equal-sized cells. The grid starts at (xStart, yStart). Each cell has width equal to xStep and height equal to yStep, and there are xNumCells cells horizontally and yNumCells cells vertically.

The local mapping within each cell is defined by the values in the table parameter. This parameter must contain 2*(xNumCells + 1)*(yNumCells + 1) values, which alternately contain the source X and Y coordinates to which each destination grid intersection point maps. The cells are enumerated in row-major order, that is, all the grid points along a row are enumerated first, then the grid points for the next row are enumerated, and so on.

As an example, suppose xNumCells is equal to 2 and yNumCells is equal 1. Then the order of the data in table would be:

 x00, y00, x10, y10, x20, y20, x01, y01, x11, y11, x21, y21
 
for a total of 2*(2 + 1)*(1 + 1) = 12 elements.
Parameters:
  xStart - the minimum X coordinate of the grid.
Parameters:
  xStep - the horizontal spacing between grid cells.
Parameters:
  xNumCells - the number of grid cell columns.
Parameters:
  yStart - the minimum Y coordinate of the grid.
Parameters:
  yStep - the vertical spacing between grid cells.
Parameters:
  yNumCells - the number of grid cell rows.
Parameters:
  warpPositions - a float array of length 2*(xNumCells + 1)*(yNumCells + 1) containing the warp positions at thegrid points, in row-major order.
throws:
  IllegalArgumentException - if the length of warpPositions is incorrect



WarpGrid
public WarpGrid(Warp master, int xStart, int xStep, int xNumCells, int yStart, int yStep, int yNumCells)(Code)
Constructs a WarpGrid object by sampling the displacements given by another Warp object of any kind.

The grid is defined by a set of equal-sized cells. The grid starts at (xStart, yStart). Each cell has width equal to xStep and height equal to yStep, and there are xNumCells cells horizontally and yNumCells cells vertically.
Parameters:
  master - the Warp object used to initialize the griddisplacements.
Parameters:
  xStart - the minimum X coordinate of the grid.
Parameters:
  xStep - the horizontal spacing between grid cells.
Parameters:
  xNumCells - the number of grid cell columns.
Parameters:
  yStart - the minimum Y coordinate of the grid.
Parameters:
  yStep - the vertical spacing between grid cells.
Parameters:
  yNumCells - the number of grid cell rows.





Method Detail
getXNumCells
public int getXNumCells()(Code)
Returns the number of grid cell columns.



getXStart
public int getXStart()(Code)
Returns the minimum X coordinate of the grid.



getXStep
public int getXStep()(Code)
Returns the horizontal spacing between grid cells.



getXWarpPos
public float[] getXWarpPos()(Code)
Returns the horizontal warp positions at the grid points.



getYNumCells
public int getYNumCells()(Code)
Returns the number of grid cell rows.



getYStart
public int getYStart()(Code)
Returns the minimum Y coordinate of the grid.



getYStep
public int getYStep()(Code)
Returns the vertical spacing between grid cells.



getYWarpPos
public float[] getYWarpPos()(Code)
Returns the vertical warp positions at the grid points.



mapDestPoint
public Point2D mapDestPoint(Point2D destPt)(Code)
Computes the source point corresponding to the supplied point.

This method returns the value of pt in the following code snippet:

 float[] sxy = warpSparseRect((int)destPt.getX(), (int)destPt.getY(),
 2, 2, 1, 1, null);
 double wtRight  = destPt.getX() - (int)destPt.getX();
 double wtLeft   = 1.0 - wtRight;
 double wtBottom = destPt.getY() - (int)destPt.getY();
 double wtTop    = 1.0 - wtBottom;
 Point2D pt = (Point2D)destPt.clone();
 pt.setLocation((sxy[0]*wtLeft + sxy[2]*wtRight)*wtTop +
 (sxy[4]*wtLeft + sxy[6]*wtRight)*wtBottom,
 (sxy[1]*wtLeft + sxy[3]*wtRight)*wtTop +
 (sxy[5]*wtLeft + sxy[7]*wtRight)*wtBottom);
 


Parameters:
  destPt - the position in destination image coordinatesto map to source image coordinates. a Point2D of the same class asdestPt.
throws:
  IllegalArgumentException - if destPt isnull.
since:
   JAI 1.1.2



warpSparseRect
public float[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)(Code)
Computes the source subpixel positions for a given rectangular destination region, subsampled with an integral period.

Points outside the bounds of the cells defining the grid warp will be mapped to the source image using the identity transformation.
Parameters:
  x - The minimum X coordinate of the destination region.
Parameters:
  y - The minimum Y coordinate of the destination region.
Parameters:
  width - The width of the destination region.
Parameters:
  height - The height of the destination region.
Parameters:
  periodX - The horizontal sampling period.
Parameters:
  periodY - The vertical sampling period.
Parameters:
  destRect - An int array containing at least2*((width+periodX-1)/periodX)*((height+periodY-1)/periodY)elements, or null. If null, anew array will be constructed. a reference to the destRect parameter if it isnon-null, or a new int array of length2*width*height otherwise.
throws:
  ArrayBoundsException - if destRect is too small




Methods inherited from javax.media.jai.Warp
public Point2D mapDestPoint(Point2D destPt)(Code)(Java Doc)
public Rectangle mapDestRect(Rectangle destRect)(Code)(Java Doc)
public Point2D mapSourcePoint(Point2D sourcePt)(Code)(Java Doc)
public Rectangle mapSourceRect(Rectangle sourceRect)(Code)(Java Doc)
public int[] warpPoint(int x, int y, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc)
public float[] warpPoint(int x, int y, float[] destRect)(Code)(Java Doc)
public int[] warpRect(int x, int y, int width, int height, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc)
public float[] warpRect(int x, int y, int width, int height, float[] destRect)(Code)(Java Doc)
public int[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, int subsampleBitsH, int subsampleBitsV, int[] destRect)(Code)(Java Doc)
abstract public float[] warpSparseRect(int x, int y, int width, int height, int periodX, int periodY, float[] destRect)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.