-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add method to invert a ColorScheme (inverse of get) #11
Conversation
`invert` places a color within a colorscheme, by converting the color to a value representing its position on the colorscheme's axis. Put another way, it returns the value in the domain for which its colorscheme value most closely matches the provided color. Also adds `convertToScheme(cscheme, img)`, which uses `invert` to convert every pixel in img to its closest color from the provided colorscheme. Adds tests for both methods.
This is still a work in progress. I'm not exactly sure how the method should work, but this is a good start. It does what I think it should, although doesn't behave quite like I expected. See: I'd love to talk it through some with folks! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style is to use lowercase (“squishcase”, juliacase) rather than camelCase, so this should be convert_to_scheme or something better...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could move the export line from line 5 to line 116.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether an alternative to invert
would be getinverse
, because it doesn't invert some object, rather it 'gets' a value...
Oh sure, can do. Thanks. I didn't notice it way down there. Is there no convention on putting the |
Yeah I think that's better. I can't really think of anything better than that. Thanks! I'll make that change too. |
renamed methods; fixed broken convert_to_scheme definition; moved exports;
Okay I've changed it to
So anyway, maybe we just remove this function for now? |
Let’s merge this, make a release, and take it for a spin... If it proves problematic we can either document its problems or remove it; if it works we can improve the docs... it will all need extensive changes in a few months anyway! |
Fixes #10.
This PR is to add a method which is the inverse of
get(cscheme, x)
.For now, I've just copied over
invert
from NHDaly/ColorSchemesInvert.jl. For more details see NHDaly/ColorSchemesInvert.jl/.../README.ipynb.invert
places a color within a colorscheme, by converting the color toa value representing its position on the colorscheme's axis.
Put another way, it returns the value in the domain for which its
colorscheme value most closely matches the provided color.