Hi,

I do not know for sure what happens here but I do not believe that it is 
possible to get a perfect match with pixels with that code. Here is an excerpt.

Geometry fence = SelectionTools.getFenceGeometry(context);
Envelope envWanted = fence.getEnvelopeInternal();
BufferedImage partOfImageWanted = rLayer.getTileAsImage(envWanted);
Raster partOfRasterWanted = rLayer.getTileAsRaster(envWanted); //[sstein 2 Aug 
2010] need to add as we have now the image for display plus the data
if (partOfImageWanted==null){
context.getWorkbenchFrame().warnUser(I18N.get("org.openjump.core.ui.plugin.layer.pirolraster.ExtractSelectedPartOfImage.fence-in-wrong-region"));
return false;
}
boolean returnVal = this.putImageIntoMap(partOfImageWanted, partOfRasterWanted, 
envWanted, rLayer, context);
return returnVal;

And why not? Because our vector coordinates are doubles but raster images are 
tied to sort of binary world with raster size as a minimal step unit. If I can 
read the code, the writer believes that envWanted is same as the envelope of 
the returned pixels but it is impossible to crop an image to any imaginary 
envelope without doing resampling and I do not believe that getTileAsRaster is 
doing resampling. Envelope of the returned image can only be the same then the 
wanted envelope if coordinates in the envWanted match perfectly with the 
coordinates of pixel corners. In order to get a perfect match we should know 
the origin of the image and pixel size in X and Y directions. Based on those 
parameters it would be possible to count such an envWanted that matches 
perfectly with the pixels.
Another possibility would be to check the envelope of pixels which are really 
returned by the getTileAsRaster, make a new variable "envelopeThatWeGot" and 
use that one for georeferencing the clipped image.

I found some python code we have been using in a little bit similar task for 
extending bounding box to be full meters. It was enough for us because in that 
dataset the origins were always full meters and pixel size was either 0.5 or 
1.0 meters so we did not need to check those values from image info. The end 
result is "minmax_wider.

minmax = get_minmax(tm32_coords)
                           minmax_wider = [
                                                       
(int(math.floor(minmax[0][0])), int(math.floor(minmax[0][1]))),
                                                       (int(math.ceil 
(minmax[1][0])), int(math.ceil (minmax[1][1]))),
                           ]

                           log("Extents (min,max): " + str(minmax), outfilename)
                           log("Widened extents (min,max): " + 
str(minmax_wider), outfilename)

-Jukka Rahkonen-

Lähettäjä: Giuseppe Aruta [mailto:giuseppe_ar...@yahoo.it]
Lähetetty: 25. elokuuta 2013 13:35
Vastaanottaja: OpenJump develop and use
Aihe: Re: [JPP-Devel] Improvement to GeoTIFF reader

Hi all,
this is an observation on class:
org.openjump.core.ui.plugin.layer.pirolraster.ExtractSelectedPartOfImage
the extracted part of the image has a shift.
I calculate that the pixel are shifted of -1/5 for Y and around 1/20 for X.
I attached a picture on this mail (green points, anchor points of pixe of the 
original image. Red points anchor points of the extracted part of the image)
[Immagine in linea 1]
This doesn't happen with the same tool on Sextante Toolbox (Basic Toos for 
Raster - Crop GRID with polygon) - f coarse if OJ is using Oracle Java.
Sextante Raster tools simply don't work if OJ is using OpenJDK 
(java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGDecode) for the 
absence of TIF writer. Sextante for OJ probably requires a rework to use 
commons library instead of JAI (at least with Linux OpenJDK) at least to save 
results.
regards
Peppe




2013/8/25 Giuseppe Aruta 
<giuseppe_ar...@yahoo.it<mailto:giuseppe_ar...@yahoo.it>>
THis should be adopted also to OJ Sextante (Pirol) image reader
Peppe

2013/8/25 Rahkonen Jukka 
<jukka.rahko...@mmmtike.fi<mailto:jukka.rahko...@mmmtike.fi>>
Hi,

The Geotiff reader does now
- examine if tiff image contains geotiff tags
- if not, check if tfw file can be found
- if not, send an error and quit.

It would be often fine just to see the image, even if it is not georeferenced. 
How about to make OpenJUMP to use a default tfw file if image is not geotiff 
and tfw file is not found?

The default TFW could be for example

1
0
0
-1
0.5
-0.5

Image would be opened to have top left corner of the top left pixel at 
coordinates (0,0) and pixel size would be 1 by 1 units.

-Jukka Rahkonen-
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net<mailto:Jump-pilot-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


<<inline: image001.jpg>>

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to