Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply discrete cmap when needed #325

Merged
merged 1 commit into from
Dec 22, 2020
Merged

apply discrete cmap when needed #325

merged 1 commit into from
Dec 22, 2020

Conversation

vincentsarago
Copy link
Member

closes #321

@vincentsarago vincentsarago merged commit 41c6729 into master Dec 22, 2020
@vincentsarago vincentsarago deleted the applyDiscreteCmap branch December 22, 2020 15:58
@@ -94,6 +94,9 @@ def apply_cmap(
if data.shape[0] > 1:
raise InvalidFormat("Source data must be 1 band")

if len(colormap) > 256 or max(colormap) > 256:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you only check for > 256 and not != 256?

Copy link
Member Author

@vincentsarago vincentsarago Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylebarron because make_lut should work for cmap that have less than 256 value or a max smaller than 256
https://github.com/cogeotiff/rio-tiler/pull/325/files#diff-1c0d3ee98487c3ad9e96a708cf2b17d8dba80980c2b0bd6faaca3688543bfd41R66-R68

just realizing that it should be max(colormap) >= 256 🤦

e.g

cmap = {1: [255,255,255,255], 255: [1,1,1, 255]}
make_lut(cmap)
array([[  0,   0,   0,   0],
       [255, 255, 255, 255],
       [  0,   0,   0,   0],
       ...,
       [  0,   0,   0,   0],
       [  0,   0,   0,   0],
       [  1,   1,   1, 255]], dtype=uint8)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

automatically apply discrete colormap when cmap doesn't have 256 values
3 participants