Restore skipping color correction for byte rasters
jisantuc opened this issue · comments
James Santucci commented
Problem description
Imagery already in the byte range doesn't need correction, and also, our histogram stretch seems to wash it out / introduce artifacts.
We used to do in ColorCorrect.scala
// if data is a byte raster (0, 255) don't do anything
// else if stats are available, clip assuming a normal distribution
// else use the histogram's min/max
if (imin >= 0 && imax <= 255) {
iMaxMin(index) = (0, 255)
} else {
(imin, imax, statsOption) match {
case (_, _, Some(stats)) =>
// assuming a normal distribution, clips 2nd and 98th percentiles of values
val newMin =
if (disableCorrection) imin
else stats.mean + (stats.stddev * -2.05)
val newMax =
if (disableCorrection) imax
else stats.mean + (stats.stddev * 2.05)
// assume non-negative values, otherwise visualization is weird
// I think this happens because the distribution is non-normal
iMaxMin(index) =
(if (newMin < 0) 0 else newMin.toInt, newMax.toInt)
case (min, max, _) => iMaxMin(index) = (min, max)
}
}
But when we simplified color correction, we lost the logic to skip correction for byte rasters.
Replication Steps
- upload a tif in the 0 - 255 range
- look at it
- look at it with
disableAutoCorrection=true
- feel sad
Expected Behavior or Output
all the imagery looks great all the time
James Santucci commented
Do azavea/raster-foundry-platform#1219 at the same time -- they're both normalization errors that will be easy to track down