Hi,
Given a set of ground control points (GCPs) and a non-referenced TIFF
image, I am trying to create a GeoTiff that can be rendered by
GeoTools.
I'm giving a set of source points (image pixels) and destination points
(world coordinates) to the WarpTransform2D class, and using that to
create the WarpPolynomial object to perform the JAI operation, but the
Warp that is created contains a strange affine transform. Although it is
more than likely that I just don't quite understand what is going on.
The test I am running it against uses a 25x25 pixel image. The source
points and destination points are the same (so the warp shouldn't do
anything to the image - the affine should be identity?)
I perform a test transformation in the code, just using the
WarpTransform2D on the point (12, 12) which should return (12, 12) or
something very close, but it actually returns (0, 12).
The Warp's affine transform:
[[0.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
I would think that that would be the identity? The image returned by JAI
is the same shape, but it is blank.
When I change each '0' to '1' in the source and destination points, the
affine transform becomes:
[[529.9999921023847, 4.0E-15, -23.0], [2.9802258E-8, 1.0, 3.0E-15]]
In this case, the image is stretched very far to the right (several
thousand pixels, I believe). It retains the same height.
Obviously I am doing something wrong here. Does anyone have any ideas
that may help? Or any alternative suggestions to referencing a TIFF
using just ground control points?
Here is my test source code:
Point2D[] src = new Point2D[4];
Point2D[] dest = new Point2D[4];
src[0] = new Point(0,0);
dest[0] = new DirectPosition2D(0, 0);
src[1] = new Point(0, 24);
dest[1] = new DirectPosition2D(0, 24);
src[2] = new Point(24, 24);
dest[2] = new DirectPosition2D(24, 24);
src[3] = new Point(24, 0);
dest[3] = new DirectPosition2D(24, 0);
int deg = 1;
WarpTransform2D wt = new WarpTransform2D(src, dest, deg);
System.out.println("Test Transform: " + wt.transform(new
java.awt.Point(12, 12), null));
InputStream is = getClass().getResourceAsStream("img.png");
BufferedImage sourceImage = ImageIO.read(is);
Viewer.show(sourceImage);
Warp warp = WarpTransform2D.getWarp("", wt);
ParameterBlock paramBlk = new
ParameterBlock().addSource(sourceImage);
paramBlk = paramBlk.add(warp);
JAI processor = JAI.getDefaultInstance();
String operation = "Warp";
RenderingHints targetHints = new RenderingHints(null);
RenderedOp targetImage = processor.createNS(operation, paramBlk,
targetHints);
Viewer.show(targetImage);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users