Hello,
Thanks Simone for your answer. I unfortunately do not have enough time for
the moment to accept your proposition about the fixes to imageio-ext.
Discovering the GeoTools is a long job ! Sorry...
However, the problem do not seem to be due to the fileload operation from
JAI because the printed values of an arbitrary point just before the
GeoTools' resample operation are right. They are wrong just after it. That
is why I suspect a bug in GeoTools or in the JAI components it might use.
Have you got any idea ?
Thanks for your help.
Fred
2009/7/8 Simone Giannecchini <[email protected]>
> Ciao Fred,
> please, read below...
> -------------------------------------------------------
> Ing. Simone Giannecchini
> GeoSolutions S.A.S.
> Owner - Software Engineer
> Via Carignoni 51
> 55041 Camaiore (LU)
> Italy
>
> phone: +39 0584983027
> fax: +39 0584983027
> mob: +39 333 8128928
>
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://simboss.blogspot.com/
> http://www.linkedin.com/in/simonegiannecchini
>
> -------------------------------------------------------
>
>
>
> On Wed, Jul 8, 2009 at 7:26 PM, fred p<[email protected]> wrote:
> > Hello
> > I get an error when reprojecting an image : the values of the pixels in
> the
> > result image are one unit lesser than the corresponding pixels in the
> > original image.
> > Have I made a mistake somewhere in the provided code ? Is it a bug due to
> > GeoTools or to JAI or... ?
>
> I would not use the filestore/fileload operation from JAI, I would
> rather use the ImageRead/ImageWrite bridge between JAI and ImageIO.
> However, PNM support in imageio is buggy, data are not written out
> correctly. I did fixe some of the problems in the past but I am not
> sure the fixes were applied to the source code. I might commit those
> fixes to imageio-ext, but unless someone steps up with funding, that
> is unlikely to happen anytime soon.
> If you feel brave, I might pass them over to you.
>
> Simone.
> > Below is the code I have used, you will find the image file in
> attachment.
> > Thanks for your help.
> > Fred
> >
> >
> >
> >
> >
> >
> > import java.awt.Point;
> > import java.awt.geom.Point2D;
> > import java.awt.image.RenderedImage;
> > import java.awt.image.renderable.
> > ParameterBlock;
> >
> > import javax.media.jai.Interpolation;
> > import javax.media.jai.JAI;
> > import javax.media.jai.RenderedOp;
> >
> > import org.geotools.coverage.grid.GridCoverage2D;
> > import org.geotools.coverage.grid.GridCoverageFactory;
> > import org.geotools.coverage.processing.Operations;
> > import org.geotools.geometry.Envelope2D;
> > import org.geotools.referencing.CRS;
> > import org.opengis.geometry.Envelope;
> >
> >
> >
> > /**
> > * Reprojects a PGM file.
> > * The values of all the result file's pixels all are one unit lesser
> than
> > the original file's corresponding pixel.
> > *
> > * Usage : java ReprojectionProblem
> > */
> > public class ReprojectionProblem {
> > public static void main (String[] args) {
> >
> > try {
> >
> > // loading the input file
> > RenderedOp rop = JAI.create("fileload", "in.pgm");
> >
> > // getting a gridcoverage whithin the input file
> > GridCoverageFactory fac = new GridCoverageFactory();
> > GridCoverage2D gc = fac.create("NO
> > NAME",rop.getAsBufferedImage() , new
> > Envelope2D(CRS.decode("EPSG:4326"),-20,-20,40,40));
> >
> > // displaying the value at coordinates point (0,0) BEFORE
> > reprojection
> > int[] array = new int[1];
> > Point2D pt = new Point(0,0);
> > gc.evaluate(pt, array);
> > System.out.println("BEFORE: " + array[0]);
> >
> > // getting the target Envelope
> > Envelope env = new
> > Envelope2D(CRS.decode("EPSG:4326"),-40,-40,80,80);
> >
> > // reprojecting
> > GridCoverage2D gc2 =
> >
> (GridCoverage2D)Operations.DEFAULT.resample(gc,env,Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
> >
> > // displaying the value at coordinates point (0,0) AFTER
> > reprojection
> > array = new int[1];
> > pt = new Point(0,0);
> > gc2.evaluate(pt, array);
> > System.out.println("AFTER: " + array[0]);
> >
> > // getting the result image
> > RenderedImage res = gc2.getRenderedImage();
> >
> > // saving the result image
> > ParameterBlock pb = new ParameterBlock();
> > pb.addSource(res);
> > pb.add("out.pgm");
> > pb.add("pnm");
> > JAI.create("filestore", pb);
> >
> >
> > } catch (Exception e) {
> > e.printStackTrace();
> > }
> >
> >
> >
> >
> > }
> > }
> >
> ------------------------------------------------------------------------------
> > Enter the BlackBerry Developer Challenge
> > This is your chance to win up to $100,000 in prizes! For a limited time,
> > vendors submitting new applications to BlackBerry App World(TM) will have
> > the opportunity to enter the BlackBerry Developer Challenge. See full
> prize
> > details at: http://p.sf.net/sfu/Challenge
> > _______________________________________________
> > Geotools-gt2-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> >
> >
>
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users