After playing with Cimg.h for some time, and now I have a slight deeper understanding of Cimg.h. I decided to announce a plan to fork G’MIC/Cimg. Now, the goal isn’t really to replace the main G’MIC at all, but rather to implement some of my ideas for the internals of G’MIC and to have a repository where they can be visited via separate branches. So, if one wants to merge a specific idea of mine, one can select a branch ‘feature_name’, merge it into local copy of Cimg/G’MIC, and then test it.
Here are some of the ideas I had:
- Next(), Previous() (Already discussed, and is done) - Basically they do find the previous/next representable value.
- Alpha-Aware Resize (Already discussed) - Optimized for resizing images with alpha, and preserves color. You can quickly see some optimization such as storing location of pixels with alpha, and then loop over that. And this is not dependent on alpha being 255 max.
# C = Color
# NC = New Color Value
# A = Alpha
# NA = New Alpha Value
# SA= Sum of Alpha
# WF = Weighing Factor
C = 85,255,55
A = 5,100,150
SA =255
WF = 1 / SA = 0.0038461538461538464
NA = 255 / 3 = 85
# To calculate NC, for each color, multiply the value of color by the corresponding alpha value. Multiply the resulting value by the weighing factor. Then, add them altogether
NC = sum(85*5*WF, 255*100*WF, 55*150*WF) =>134.01960784313727
So therefore, the new pixel value is [ 134.01960784313727 , 85 ] .
- Multiple-variable GCD support. - Instead of being limited to 2, one can find GCD of 3 or more variables at once.
- LCM - Find the least common multiple.
Binary Literal support - ‘0b1111’ will be treated as 15. This makes it a little bit more visually clear of what’s going on in case of using binary operators.Done by David.- ordered_set and unordered_set type - Scalar, and vector types are supported, but I have a idea to have support for these two types. Basically, there can never be a duplicate. I don’t plan to make it as flexible as Python set though I want that.
- Dictionary type - Another new type which allows one to dynamically adjust it, and find retrieved values via treating numbers as key. Would be useful for cases where one wants to emulate dictionary though you can do that in G’MIC outside of math evaluation easily.
That’s pretty much it. I think I can do all of that except the new types system which will take a while to figure out.
EDIT:
There’s few more I had in mind, but I don’t think I"ll do it.
Factors - Even though I had made this via G’MIC using prime factorization, I think it would be nice to have a native implementation of it instead.
And I’m not sure about these ones:
Numbers combinatorics library - All of this has been done via G’MIC within my gmic-community file. I have permutations, combinations, repeated combination, repeated permutation, and Cartesian Product. They’re more flexible than anything that’s out there because you can do it for all of the rank, or just one rank without having to calculate previous ranks.
String combinatorics library - This is one I’m actively looking at making via G’MIC. But, it’s a bit hard to resolve some issues for now and I’m not sure if doing this via C++ would make things easier.