The Big Bad G'MIC Thread of Silly Questions

Yes, that would be nice. But are there even metaballs in G’MIC?

Anyway, this is a bit tricky to script ( for me). Maybe I should put this in GUI to play with sliders and see who does what.
And I have to do another branching level too.
What I don’t like for now is that all branches go in the same direction up or down, and they’re all the same. I added some randomization for t ( there are even 2 branches overlapping at the bottom right) he repeats so I get long or short branches but that’s all right now. I wanted more tortuous trees.

The easiest way is to do another repeat {}. The most flexible idea, well, you’re not gonna like the idea. You’d have to use the math parser, loop along multiple images and modify multiple images with math parser. This can be done with single repeat {} outside the math parser, and the creation of branches is done within the math parser.

Yes, i’ll nest 1 or 2 more repeats in there. I’m not sure what you mean by looping on multiple images? Just for info, i’m already drawing the branches on a second image here, then alpha blend. I’ve chosen to do so since i’m planning to have darker branches behind and lighter ones in front, to give some fake depth. I could also do this by darkening the ellipses color a bit ( on creation ) but it seems a little harder to manage.
Anyway that’s for later, my first concern is making more varied branches, since it’s a loop they all look the same for now. But at least i got some going left or right :stuck_out_tongue: (even though sometimes there are only 1 or 2 going in the same direction and that’s… awkward lol)

Not at home for the moment, but I’m interested by this.
One suggestion I can say is :

  • For this kind of recursive structures, it’s often better first to generate a complete description of the whole shape, e.g. as a list of coordinates/radii/whatever parameters you want to consider.
  • Then, in a second step, do the rendering itself by drawing all primitives on a canvas.

The interest of considering this in two steps is that between the two steps you can do interesting stuffs globally, like sorting the primitives before drawing them, etc. And you don’t mix the parts of the code that are indeed quite differents (you won’t need recursive calls to draw the primitives).

Thanks for the advice. For now i’ll try to keep going as i started, to see if i can get something at least somewhat good looking. If i try to rewrite it now like you described, i fear i’ll just mess things up again :stuck_out_tongue:
I’m not used to using sin, cos or other maths functions, so i don’t really know when to apply them. Never used arrays in G’MIC either, as (to me) it seems strange enough to see them stored as images too.

Sorting them? By size, etc? What could be the purpose?

@Reptorian BTW, i was looking at L-systems (yeah i like that but can’t do it :p) and saw this islands and lakes program.. I thought you’d like it.

See how fast i can screw things up? LOL:

EDIT: ended up with this a few minutes later:

But then i changed some stuff and screwed everything up again:


Level C (green) is not even showing up anymore.
But now i don’t even remember what i changed, so i guess it’s garbage time lol.
Unless you like trees & mushrooms.

If you haven’t closed or saved, KDE Kate supports infinite undos. Also, it’s a good idea to save a backup somewhere.

Nah, too late, I changed so much stuff everywhere. I can’t help it, I just keep on testing and testing… Nvm.

I was about to recommend this approach as well. Having coordinates handy allows you to do things such as path planning, analysis, interpolation and outlier removal.

Building trees is neat. Cannot wait for growth animation. :wink:

For example, animation of a growing spire:

I can’t do that, i don’t even understand what you’re talking about. I can only do basic stuff. The current code is completely broken and i can’t find why. Probably just a tiny thing that breaks everything. My fault for wanting to add randomization everywhere since i can’t stand clean stuff. Gotta start from scratch again.

Dumping code here for a laugh:

It's broken. Inherit my code. It's broken.

ellipse_tree:
# ... or at least some kinda trnuk
  1000,1000,1,3,-y #.
  n 0,255
  undul=.05
  X,Y,N,W,RAD,br_start,br_stop,brC_start,brC_stop,tr_seg,br_seg:=w*.5,h,2,h,35,h*.9,h*.3,w*.4,w*.6,100,150
  thinning=1
  r:=$RAD*.6
  rip:=$r*.99
  #~ O=.01
  #~ O=.1
  O=1

  repeat u(10,15) {
    find_new=1
    repeat u($tr_seg/2,$tr_seg) {
      col:=[u(180,140),70,20] ang:=(1*$>)*sin($>/u($rip))
      if $RAD>=0
       ellipse[0] $X,$Y,$RAD,$r,$ang,$O,$col
       w
        X,Y,RAD,r+=u(-1,1)*sin($</u(10)),u(-.5,-1),-.01,-.01
################ LEVEL B
      if $find_new&&$Y<$br_start&&$Y>$br_stop
        bX,bY,bRAD,br:=$X,$Y,$RAD*.8,$r
        if $bRAD>=0
          repeat u($br_seg/2,$br_seg) {
          col:=[u(80,140),70,20] 
          ang:=$>*sin($</u($rip))
          bRAD,br-=lerp(.05,.01,-$thinning)
          if u>.5 bX+=10 else bX-=10 fi
          bY+=u(-.1,-.8)+sin($>/u(4,6))-lerp($>*.015,.001,-.01)   # +/- branch up or down
          ellipse[0] $bX,$bY,$bRAD,$br,$ang,$O,$col
          w
################# LEVEL C
          if u>.95
            cX,cY,cRAD,cr:=$bX,$bY,$bRAD,$br
            # echo $cRAD
            if $cRAD>=0
              repeat u($br_seg/1.2,$br_seg) {
              col:=[u(80,40),70,20] ang:=10*$> #*sin($</u($rip))
              cRAD,cr-=lerp(.05,.01,-$thinning)
              if u>.5 cY+=2 else cY-=2 fi
              cX+=u(.1,.8)+sin($</u(4,6))-lerp($>*.015,.01,.01)   # +/- branch up or down
              if $cX<$brC_start||$cX>$brC_stop
              # echo $cX
                if $cY>h*.3
                  ellipse[0] $cX,$cY,$cRAD,$cr,$ang,$O,$col
                  w
                fi
              fi
              }
            fi
          fi
            }
          fi
        fi
    find_new=0
      fi
    }
  }

@afre

Since you like anime, here’s some old school Tenta for ya:)

Proof that i really want to waste time before rewriting that tree :


Hello Tenta!

I get the reference. Will this keyword reach a new audience once indexed by search engines? :safety_vest:

Proof that i don’t think enough.
Ah, what a world we live in.

You don’t need to censor it, but you could replace it with tentacles at least. The vast majority of us are adults, even by drinking age.

Hi ,

do anyone know how this things are called? Is there even a name for such things?
It’s made of splines and then mirroring. And can hurt your eyes too.

1 Like

I’m trying to work out which image of a group of images best matches a reference image. I have a dynamic array of ssim values which I can render to an image and I can use max_patch to find the maxima. How do I get the image number of the best match or matches (I’m new at this)?

Source image below as well as code. I’m trying to align geomorphic map tiles automatically. The input generates 150 images with vertical grid lines moved by 1 pixel each then compares them to the reference. The grid lines are 2px wide and 150px apart (x%150 used in inrange).

I’m a noob so if there is a better way to do this feel free to suggest something. $> wasn’t working for me (never set) so I’m using $! as a workaround.

gmic 0 HG37.png repeat 150 input 100%,100%,1,4,'[inrange(x%150,$!-2,$!-1,1,1)?204:0,inrange(x%150,$!-2,$!-1,1,1)?204:0,inrange(x%150,$!-2,$!-1,1,1)?204:0,inrange(x%150,$!-2,$!-1,1,1)?255:0]' ssim[-1] [1] eval 'da_push(#0,${})' done eval 'da_freeze(#0)' max_patch[0] 20 echo ${} normalize[0] 0,255 output[0] test.png```

Hi,

welcome to the forum!

But TBH i don’t think i can help you, as i’m probably more of a G’mic noob than you say you are. Also i don’t have enough RAM to run your pipeline…
Maybe @David_Tschumperle can help you there.

Anyway, here’s my noober attempt. I kept your original code (da_push, etc) in there too even if i don’t use it.
For some reason, this script doesn’t work if you change if $result<.04 to .05 , as it deletes everything. You can save this as a foo.gmic file and call it like this :
gmic foo.gmic 0 HG37.png foo

foo:

 repeat 150 {
 
 input 100%,100%,1,4,\
 '[inrange(x%150,$!-2,$!-1,1,1)?204:0,\
 inrange(x%150,$!-2,$!-1,1,1)?204:0,\
 inrange(x%150,$!-2,$!-1,1,1)?204:0,\
 inrange(x%150,$!-2,$!-1,1,1)?255:0]' 
 
 ssim[-1] [1] result=${} 
 
 if $result<.04 
    echo "Deleted "${}  # info spam
    rm.                 # eliminates low similarity images (below .04). Saves our ram!
 else
    =>. $result         # or gives higher sims a name, which is ssim results
    echo $result        # more info spam
    eval 'da_push(#0,$result)' 
 fi
 
 } 
 
 sort_list[^0-1] +,n   # sort_list by name, except image 0 and 1 
 
 eval 'da_freeze(#0)' 
 max_patch[0] 20 
 echo ${}             
 normalize[0] 0,255 
 output[-1] best.png  # output last image of the list which is the best match