G'MIC fun with afre


(dumb) #21

Edit: it turned out that my earlier implementation was faster on my machine, not sure why. I’m using 2.4.1. Here’s what I’ve built around that:

#@gui 8-Bit planes : fx_bitplane8, fx_bitplane8_preview(1)
#@gui : Mode = choice("Decompose","Recompose")
#@gui : Split mode = choice("Z layers","Separate images")
#@gui : Scale mode = choice("True","1","255")
fx_bitplane8 :
if $1
if {!$2} s z fi
repeat {int($!/8)} l[$>-{$>+7}]
repeat 8
if {$3==0}
/ {2^$iter} cut 0,1 round 0,1 * {2^$iter}
elif {$3==1}
cut 0,1 round 0,1 * {2^$iter}
elif {$3==2}
/ 255 cut 0,1 round 0,1 * {2^$iter}
endl done
endl done
repeat 8
&[-1] {2^$>} 
if {$3==1}
/[-1] {2^$>}
elif {$3==2}
/[-1] {2^$>/255}
if {!$2} a[^0] z fi
#n 0,255
fx_bitplane8_preview :
fx_bitplane8 $*


Whatever works for you. As I said before, I prefer simple and elegant, short and sweet. :stuck_out_tongue:

(dumb) #23

I admit that it’s a bit of a mess but it seems to work exactly as I feel it should:

  • An option to keep true values, set values to either 0 or 1 or set them to either 0 or 255

  • Repeats on every 8 slices, doesn’t do anything else

  • Rounds values for idiotproofing (but being G’MIC code, it’s easily-hackable).

  • Options to keep 8 separate images or merge them along the Z axis

Given that in hindsight some of my commands have very questionable design choices (like that extra ‘recompute’ option which the commands require as arguments despite it only having a use to easily refresh any randomising things through the GUI without resetting parameters), I suppose I’ll need to redesign some of the commands I’ve made.