We've been using the geotools' resample operation to generally resize
rasters and have run into an issue.  We have multiple bands with the double
data type and in the situation where the transform resolves to an identity
transform the resulting mosaic operation ends up masking some values.  The
Resampler2D code sets null for sourceROI and sourceThreshold for the
MosaicDescriptor parameters which results in the default sourceThreshold of
1.0 being used. The resulting MosaicOpImage then sets all values that are
less than 1.0 to the background value.

Here's where the resampler uses the default parameters:
https://github.com/geotools/geotools/blob/master/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/Resampler2D.java#L631

Here's then where jai uses the background values if the value doesn't
exceed sourceThreshold:
https://github.com/mauricio/jai-core/blob/master/src/share/classes/com/sun/media/jai/opimage/MosaicOpImage.java#L2059

In our case, we have valid values less than 1.0 and the background value is
NaN so we are effectively arbitrarily masking some of our values.  I get
how we could just determine if the resample operation is going to result in
a Mosaic operation and then make sure the parameters are set to something
valid. But this is just one case and its nice that the resample operation
is generalized for us so we don't have to determine the underlying
operation.

I'd think that the Resampler2D code could at least try to infer the
threshold as the minimum values from the GridSampleDimension[] of the
coverage.  Does that make sense?

I actually don't entirely get when this sourceThreshold is useful - as long
as the background and no data values for the source and destination are the
same it seems unnecessary. So perhaps in the spirit of eventually using
jai-ext this should be something that defaults as just not being used?

Please let me know what path I should try to go down.  Thanks,
Rich
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to