On Thu, Mar 27, 2008 at 3:57 PM, Martin Desruisseaux
<[EMAIL PROTECTED]> wrote:
> Simone Giannecchini a écrit :
> > 1> in order to downsample an image, i would take a look at the various
> > scale operations which are tailored for that scope.
>
> Well... OGC 01-004 defines only "Resample" while they are silent on "Scale" or
> "Crop" operation. It can probably be understood by the fact that "Resample" is
> the general case, and the implementation can optimizes to "Scale" or "Crop"
> internally based on argument analysis.
>

Besides the fact that the GridCoverage IS is de-facto deprecated, I am
not a fan of automagic code.
It seems quite natural to have a scale operation for scaling images, a
warp operation for warping images, and a crop operation for cropping
images.
Of course, we might tell people that in some cases resample can do
more than one operation in the same step hence they can have a
performance gain. Of course, this is my personal opinion.

> The main difference between using a "Scale" or a "Resample" operation is in 
> the
> kind of parameters given ("Resample" requires a GridGeometry, which is 
> probably
> not the most intuitive construct) and in the additional cost involved inside 
> the
> "Resample" operation for analysing the parameters and realizing that it can
> optimize to "Scale" - but the later cost is very likely to be imperceptible
> compared to the cost of performing the actual raster scale or resampling.
>

Well, that depends a lot. If you are simply going to scale up or down
a raster, besides the non trivial cost of putting together the
gridgeometry for the resample operation a warp affine is much slower
than a simple scale. That is why I started using scale in some cases.

>
>
> > There is only one caveaut: being based on JAI scale operations there
> > is no way to set the expected final width and heigh but this depends
> > slightly on the operation used. If you want to get some W and H
> > explicitly you need to use the resample operation which is backed by
> > the JAI Warp operation for subsampling.
>
> This is true for JAI's "Scale", "Translate", "Rotate" and "Affine" operations.
> However the JAI's "Warp" operation backed by a WarpAffine allow us to set the
> width and height (i.e. the GridGeometry) with same performance I think.

As I said, for simple downsampling or subsampling, with no layout
constraint, warp is not the way to go, this is my opinion but also
what people suggests on the JAI mailing list.
I have been using warp extensively in the past (warp grid, warp
perspective, warp affine) an it is usually quite slower than scale. Of
course things might have improved at the JAI level.

>Again "Resample" tries to make automatically the best choice based on
an analysis of
> provided arguments.

automagically :-)

>
>
>
> > 2>If you just want to reproject to another CRS you can avoid providing
> > the gridgeometry. Just providing the target CRS would suffice.
>
> Yes... But I don't suggest to apply a "Scale" operation followed by a 
> "Resample"
> operation. I suggest that you rely only on "Resample" with a GridGeometry
> taillored to your wish and let "Resample" performs the optimal choice. It 
> allow
> it to performing everything (scale, crop, reprojection) in a single JAI
> operation rather than a chain of many JAI operations.

This is controversial from my experience. In principle it might be
better to do everything in one step as the resample does. But in the
past I have experience scaling very large tiled raster data (up to 20
gb as single mosaic)  and it seemed that for certain scale factors
(very big ones) with certain schemes (bilinear) or higher it was
better to do multiple scales. As an instance, if you want to scale by
64 I found out that doing multiple scales by 4 was faster. In ths case
if you think of a complex reprojection (datum change) of a very large
raster which also involves a drastic downsampling, I would not be 100%
sure that doin this in one step using warp affine is the best way to
go. I would rather scale down first and then reproject since you are
going to apply the reprojection point by point in java  and if you
first downsample you would make things much faster (this is from
experience).

There are so many factors involved (cache usage, original and
destination target layout, scale factor, interpolation scheme) that
the time spent to automagically select the best operation can become
too large compared to real benefits. I would let the possibility to
optimize in the end of the users.
Anyway, I would not say that you are wrong, I would just say that I
would not be so firm.

> This approach (and other
> stuff) has helped us to get more performance and lower memory usage than
> geoserver for raster WMS.
>

I believe you! :-)


Simone.
> The inconvenient is that everything depends on "Resample", so we need to 
> invest
> more effort in it for making it bug free and intelligent enough for optimizing
> the common cases.
>
>        Regards,
>
>                Martin
>



-- 
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928


http://www.geo-solutions.it

-------------------------------------------------------

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to