geosolutions-it / jai-ext

Java Advanced Imaging Open Source Replacement Wannabe
Apache License 2.0
90 stars 38 forks source link

Doubts about bilinear interpolation in presence of ROI or nodata #203

Closed aaime closed 5 years ago

aaime commented 6 years ago

The current code seems to be basically an adaptation of the path with all pixels available, I think as coded is occasionally causing darker pixels to show up in the output on the borders of ROIs.

https://github.com/geosolutions-it/jai-ext/blob/14c227b2fcd1e841f10a6e74f8cfd667cb6fc944/jt-utilities/src/main/java/it/geosolutions/jaiext/interpolators/InterpolationBilinear.java#L930-L980

In particular, the code does two horizonal interpolations, and then performs a vertical one:

aaime commented 6 years ago

Actually, some of the logic I was describing is implemented, but only for the non integer case! (the integer case is the first one found in both the scale op and the stand alone bilinear interpolator!) This pull request, among other things, makes the logic consistent across the board: https://github.com/geosolutions-it/jai-ext/pull/205

aaime commented 6 years ago

Btw, as a visual aid, I believe the residual issues are the cause of the darker 1px shadows at the border of this picture (there is snow there, should be white):

image

aaime commented 6 years ago

A bit more information. I've saved the images from the rendered image browser and replicated the chain with all the same parameters in a stand alone test, and the shadows do not happen. I've also took the same image as above, but instead of picking it out of a single image mosaic, I published it as geotiff, and the issue also does not happen. So it seems it's something specific to the usage in the context of image mosaic, but mind, it's still happening at the level of "scale after read", here is a screenshot:

selezione_358

and the same reading from the RIB "save image" dumps and running a short chain out of java code, with all same parameters, same operations, same hints...

selezione_360

Checked, the ROI look exactly the same, the params appear to be the same, the images have same origin and size, and yet the interpolation at the borders of the ROI seems to work differently. Also checked they are getting in exactly the same code base, "caseB", the part not using ROI accessor.