Repository navigation
Fix usage of IntCachedColorMap in Indexed PNG encoding - #2075
Conversation
|
@metasim This is the bug you ran into. |
|
Right, I recall this not being subject to the |
|
@echeipesh I believe so. Glad there was actually something behind it. |
| val r = createTile(arr) | ||
| val h = r.histogram | ||
| val colorMap = colorMap1.withNoDataColor(0).withBoundaryType(LessThanOrEqualTo).asInstanceOf[IntColorMap].cache(h) | ||
|
|
There was a problem hiding this comment.
Can we avoid somehow this runtime cast?
| h.foreachValue(z => ch.setItem(z, map(z))) | ||
| new IntCachedColorMap(colors, ch, options) | ||
| val cachedColors = h.values() | ||
| cfor(0)( _ < cachedColors.length, _ + 1) { i => |
There was a problem hiding this comment.
Is h.totalCount would be values count?
There was a problem hiding this comment.
h.totalCount would give me the total number of times any value was seen bytes histogram across all buckets. Not sure if thats useful here. What are you thinking?
There was a problem hiding this comment.
Eh, nothing smart, that's why i approved it. I tried to avoid somehow calculating length for the second time (as it's already known in fact) and trying to avoid distinct function usage. But no; it's fine as it is.
IntCachedColorMapimplementation was not covered by unit tests and turned out to be incorrect.This PR adds unit tests for its usage and changes the behavior to something that works.
It looks like this class fell through some cracks in the refactors. In reality it leans on implementation of
FastMapHistogramto convert pixels directly to colors, which uses a hash table lookup.In effect we get
eCcolor encoding instead ofLogwhich is provided byIntColorMap