-
Notifications
You must be signed in to change notification settings - Fork 332
Add Color Quantization effect #1815
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
base: master
Are you sure you want to change the base?
Add Color Quantization effect #1815
Conversation
|
I'll try to review this soon - I'm still catching up on reviewing some PRs, sorry! |
|
Just some initial thoughts about how this should be integrated:
I would also normally suggest making an add-in for new effects :) , but I think this has a very good argument for being upstream due to its overlap with the Dithering effect. My initial thinking is that this could perhaps be merged with the Dithering effect, as a new option for automatically choosing a palette with N colors. Then, you'd also gain the ability to apply one of the error diffusion methods too (but if we like the look of not having any error diffusion, as in the current version of this Quantize effect, that's a trivially easy to option to add) I'd also be interested to hear @Lehonti 's thoughts on this, who implemented the dithering effect |
|
@Matthieu-LAURENT39, @cameronwhite I haven't been able to look in much detail, but I see that an optimized palette is generated based on the colors of the image (not all of them, just a sample, presumably for speed). To fit this into the dithering effect, I think we would need to add the following options:
Both of the algorithms would benefit from each other. The dithering effect would be able to use the optimized palette that is used here, and also, we would not only be able to quantize a color, but also to spread the resulting inaccuracies to neighboring pixels. Let me know what you guys think :) |
|
Merging the 2 does seem like a good idea, those 2 effects are likely to be used together and it would definitely allow for better-looking results. My only concerns are
Fully agreed, this seems like the best approach. |
|
@Matthieu-LAURENT39 I have nothing against changing the effect names as the implementations evolve (but we have to make sure to document it in the change log). I think my only concern would be if it broke the API somehow (which in this case it doesn't). But let's see what @cameronwhite thinks. As for the separators: to my knowledge, separators can indeed be added to Gtk combo boxes. But you should note that, for most effects, the configuration dialog and its child controls are being generated dynamically based on the properties of the [CategoryConfig("Dynamic", Order = 1)]
[CategoryConfig("Catalog", Order = 2)]
[CategoryConfig("Application", Order = 3)]
enum PaletteSource
{
[Category("Dynamic")]
MedianCut,
[Category("Catalog")]
PresetPalettes,
[Category("Application")]
CurrentPalette,
[Category("Application")]
RecentlyUsedColors,
}Note: a |
Good point for the EffectData, annotations look like an elegant solution. Another thing that is related is using dynamic palettes requires an extra config field (the number of colors for the palette), but that field should probably not be shown when using static palettes. |
|
@Matthieu-LAURENT39 currently, there is no support in And as for creating a custom config dialog, it's perfectly possible (whether that's advisable is a different matter, though). Look at |
|
@Lehonti a simple way to toggle an option's visibility based on other config would indeed be nice to have, although it should probably it's own PR, especially given it would affect other effects. I'll wait from feedback from @cameronwhite to see if it's better to go with a custom dialogue or with extra attributes. |
|
This adds an effect to quantize the colors in an image, which can be used as either a compression method or as a stylistic choice.
I also tried my best to make an icon for it.
This was originally going to be an addon, hence why i didn't make an issue first, but in the end i figured it's probably useful enough to warrant being upstream.
I will likely add more quantization methods in the future when i have more time, but i wanted to make this PR first to make sure the effect is fit for inclusion in Pinta.