Conversation
|
I spent all weekend working on colormaps in a development branch of my spectrogram library. You may find this page interesting: https://github.com/swharden/Spectrogram/tree/1.2#colormaps Once I get that finalized, I'll loop back around to ScottPlot and work on this colormap module. I think some of the things I'm learning in Spectrogram's colormaps will translate well here. I thought I'd drop a couple notes for reference: class structureI like having a // a standard colormap
Colormap cmap1 = Colormap.Viridis;
// a custom colormap
IColormap customCmap = new CustomCmap(); // custom implementation
Colormap cmap2 = Colormap(customCmap);The biggest advantage here is intellisense gives you a list of colormaps as you start typing storing valuesStoring RGB as an matplotlib colormapsFor reference, mant of matplotlib's colormaps are here, including magma, inferno, plasma, viridis, cividis, twilight, and turbo Note that in-between colors can be calculated if desired |
|
I like your structure more, enums seem clunky for this one. As for storing them I don't have any preference between byte arrays or ints, bytes are more clear in source code, but System.Drawing uses ARGB ints, so you can save converting. If you want to have users make custom colourmaps then it may be more intuitive to use byte arrays, but it isn't difficult to convert between. |
|
Also, calculating in-between colours seems unnecessary, as colourmaps are defined for 256 steps, which means adding more between those steps will be rounded away (on an sRGB monitor) unless the colourmap has very uneven steps, in which case it will be indistinguishable to the human eye. |
Actually, storage implementation (storing byte arrays, integers, or a formula) is handled in the colormap class itself (e.g., Viridis.cs) so developers can choose any storage mechanism they like. The reasons I found
Good point! A corner case may be some TIFs store pixel intensity as 32-bit values or even floating-point numbers, but I'll ignore that and agree we can keep things simple by assuming we intend to produce 8-bit RGB images. |
Purpose:
@swharden's suggestions here: #420 (comment)
New functionality (code):
New functionality (image):
N/A