G'MIC exercises



Could you provide links and examples of what you mean?


Well, this is the only example of what I have at the moment. - https://pixls-discuss.s3.dualstack.us-east-1.amazonaws.com/optimized/3X/9/1/9135dc607e26697d8ecca3bc5efcda62ca94fdca_1_690x405.png

What smooth divisive modulo is?

A%B is equal to the remainder; Smooth Divisive Modulo(a,b) is equal to the remainder or invert of the remainder if floor (A/B)% 2 is equal to 0.

773 % 256 = 5 ; SMD(773,256) = 5

368 % 256 = 112 ; SMD(368/256) = 114

So, that is what I mean, and there doesn’t seem to be a easy way to do that sort of thing. I would like to implement smod, smodiv, smodmul, smodadd function to gmic.

smod = smodiv * (max_luminosity_value_with_mod/max_value)
smodiv = See example above

I think you get the idea.


Okay, haven’t learned cli yet.

I haven’t been having luck with running map command on Krita G’MIC. Either it says that dimensions don’t match, or values turn to 0,0. And I tried everything.

What I’m trying to do is to generate random swaps of channel values. Like 0 becomes in the 233 place. Basically trying to improve my glitch filter.


There is a tutorial here if it helps: https://gmic.eu/tutorial/_map.shtml.


Here’s what I’m getting now.

I copied and paste the palette from that tutorial. I either get 0 value or incompatible dimension. Resize would lead to 0. I change 1 and 0 in the map, and wouldn’t work.

I found psuedo_c command, I think I could use that instead since it’s easier for me to use pre-built command.

Tested it and it did seem to solve it.


Is your syntax correct? In the image, you have

map [0] [1] 0

Do you mean?

map[0] [1],0


Incompatible dimension occurred.


Is this a bug or just math? I applied this curve to i

x-axis should be [0,1]

and it turned tiger into

In fact, this happens to every image.


(G'MIC staff) #303

@afre which command did you use for that?


Here is my command, the part that is causing this problem. It happens when the parameter is between [-126,-120ish]. I realize that it likely has to do with {2^-126} being an extreme value of 1.1754943508222875e-038. A lower value yields an image of 0s.

gmic sp tiger,barbara hlg_afre -126 to_rgb a x
hlg_afre: skip ${1=0}
  n 0,1 * {2^$1}
  f "a=.17883277;b=.28466892;c=.55991073;
  n 0,1

(G'MIC staff) #305

Tested here on my Ubuntu Linux, and it works without any banding effect.


It is always Windows’ fault, isn’t it? :stuck_out_tongue: :blush:


I came across something interesting. I was having some G’MIC fun when I made a typo. y50_afre is supposed to take in one parameter (forgot to add a ,). I wonder what is going on and how I could arrive at “Typo” without incorrect syntax.

texture_afre: skip ${1=1},${2=10}
  repeat $! l[$>]
    n 0,255
        if $1 gradient_orientation 2 n 0,1 + y50_afre # ,
        else gradient_norm fi
        b 1,1,1
      *. {255*$2/iM} +
      n 0,255
    +l.. n 0,1 f gauss(i-.5) n 0,1 endl
    blend_fade[0,1] . k[0]
  endl done

No typo


G'MIC fun with afre

I like the second one better even though the first one is more like the original picture.

(G'MIC staff) #310

When the , is commented, then else is passed as first argument of command y50_afre, and the test if $1 does not hold (there is no file with filename else that exists).
After returning from command y50_afre , the next command to be executed is gradient_norm (as else was not considered to be a command, but an argument to a command).

So, to get the same behavior, you should probably write y50_afre 0 gradient norm instead of y50_afre.


Thanks, I suspected as much. When debugging the commands, I must have made a few additional typos that confused me. I will add this to my the fun with afre thread. :slight_smile:


:thinking: When I paste a GUI filter into user.gmic, it loads properly in the plugin; but when I put it into another *.gmic and load it with cli_start, it doesn’t get picked up.


Closest solution to the 6 layers to 3 layers blend problem found! Not quite the solution as the 3rd layer seem to show blending if using 4 layers.

 repeat {int($!/2)} l[$>,{$>+1}] f "(i#0+i#1)/2"  endl done

The problem is even if I put if {$>%2==0} fi, it doesn’t work like the blend[standard] approach. Just this little step to finishing the modo cli command I have been working on.


It depends on which layers you would like to blend together. I mean, there are many ways to go from 6→3 alone. Right now, it looks like you are blending 0-3 layers when you have 6 layers. Would blending like this work in the case of 4→3?

gmic sp dog,cat,tiger,flower blend[0-1] average

PS If I recall correctly, the plugin has layer modes that might be useful to learn from.


I would like to see either odd or even layers to show blend result using 2 layers and no overlaps. Like how the blend standard does it. I copied and pasted the relevant part of blend standard and edited into my WIP modo CLI and it does not seem to behave similar. So, no to your question.

1,2,3,4,5,6 -> [1,2], [3,4], [5,6]