Sat Nov 24, 2018 12:08 pm
I've been using the existing Chromatic Aberration (CA) filter in G'MIC for quite some time to make the desired effects. But, one thing that I note that it based on shifting the channels (move transform), so I think it looks flat and a little bit unnatural, the center and corners of the image are all having the same amount of CA effects, much more like a stereoscopic image. Here's what the existing filter looks like:
Another method is based on scaling the channels (scale transform), where basically the center of the image stays sharp and getting more separated toward the corners/edges. I've been exploring few method to create this kind of CA effect, including with the Krita's separate image (Image > Separate Image...) option which separates the image into individual RGB channels, which works good as well. But I want to make it a little bit more automated.
In G'MIC, there's even an option to create your own filter through "Various > Custom Code". This one is pretty powerful, but as an artist I barely understand a thing! After hours of trying to figure out the technical references on G'MIC's website https://gmic.eu/reference.shtml I came out with this rough bit of code that I wrote myself:
Which then resulted like this:
The only thing I need to change is the amount value.
Overall, I am satisfied enough with the results, although the code may looks rough and a bit how you doin'. Even though it uses RGBA conversion, it may not work well with images with transparency. Details below.
Now into the code breakdown:
- Three names are declared for the custom variables I want to use. valg for green channel scale, valb for blue channel scale, and amount for basically the strength of the effect.
- Set the amount value, this line is where I can change the filter strength.
- valg and valb formulas are for adding the values to the main code. This in percentage, so basically the green channel will be enlarged by the amount of 100+amount% and the blue channel by 2 times the amount of green.
- After converting into rgba, the image is then split by channels, then green and blue channel is individually resized with the corresponding values above and then rejoined.
- The second split is just to crop the resized channels to the original size, which referred to the alpha channel. This is why it might not work well with image with transparency.
- Take note that entering 0 as the amount will break the filter, as maybe the autocrop decides to crop the whole image.
There you go, feel free to give a feedback as I completely new to this code. It could be polished further! I don't even know how to add this to the filter lists, all I can do is set it as a favorite filter, rename it, and call it a day.
Also feel free to use the custom code as well! I hope it helps!
-PidhyFox / Kampidh
edit: changed the expressions using correct mathematical parser