Place some points on outlines with G'MIC


(samj) #1

Bonjour,

Here are some lines of code to modify and copy-paste in G’MIC Gimp to get color points on contours and elsewhere …

-n[-1] 0,255
-blur[-1] 2 
-isophotes[-1] 6 
{w},{h},1,4
-repeat {{{w}+{h}}/2}
-line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,255,255,255,255
-point {u(100)}%,{u(100)}%,0,1,255,255,255,255
-done
-and[-1,-2]
-dilate_circ[-1] 2
-sponge[-1] 5

S’amuser avec G’MIC :o)


G'MIC exercises
#2

Some commands I’ve not seen before so had to investigate :slight_smile:
The ‘sponge’ command is random based, which lead me to wonder about other approaches and the possibility of controlling it (range 0 to 1):

example_pointoutline : skip ${1=0.12}
  normalize[-1] 0,255
  blur[-1] 2 
  isophotes[-1] 6 
  100%,100%,1,1
  noise[-1] 0.5,1
  lt. {$1-0.5}
  mul[-1,-2]
  _circle 5
  dilate[-2] [-1]
  rm.

Two problems though; I’ve cheated by using the internal ‘_circle’ command and the distribution won’t be quite like your line method!


(Lyle Kroll) #3

Looks like it would make for some cool star renders, samj. :slight_smile:


(samj) #4

Bonjour,

@garagecoder

Thanks for the tests and the filter ‘example_pointoutline’. I enclose a rendering example with a value of 0.2 in G’MIC GIMP.

@lylejk

It’s a good idea to make stars or maybe twinkles. You can give an example of your wishes on an image to see if it is possible to create this.

:o)


#5

@lylejk your idea gave me ideas!

Perhaps a ‘sprite cloud’ or shape average could do this, G’MIC indeed has the means. But what if we use convolution instead?

example_shapecloud : -check ${-is_image_arg\ $1}" && isval(${2=9})"
  -repeat $! -pass$1 0 -l[$>,-1]
    kw={$2+1-$2%2} r. $kw,$kw,1,1,5 n. 0,1
    +gt[0,1] 0 convolve[-2] [-1] -rm.
    convolve[0] [1] rm[1] +eq. 0 +[-2,-1] /
  -endl -done

Given this, we can continue as follows:

example_staroutline : skip ${1=0.2},${2=11}
  normalize[-1] 0,255
  blur[-1] 2
  isophotes[-1] 6
  100%,100%,1,1
  noise[-1] 0.5,1
  lt[-1] {$1-0.5}
  mul[-1,-2]
  shape_star ,
  example_shapecloud[-2] [-1],$2
  rm[-1]

And the output:


(samj) #6

@garagecoder

Bonjour,

There is a small typo error in the ‘example_shapecloud’ tests.
I enclose the code and an example of this very nice filter in G’MIC GIMP.

:o)

example_staroutline 0.05,10

example_shapecloud : -check ${"is_image_arg $1"}" && isval(${2=9})"
  -repeat $! -pass$1 0 -l[$>,-1]
    kw={$2+1-$2%2} r. $kw,$kw,1,1,5 n. 0,1
    +gt[0,1] 0 convolve[-2] [-1] -rm.
    convolve[0] [1] rm[1] +eq. 0 +[-2,-1] /
  -endl -done

example_staroutline : skip ${1=0.2},${2=11}
  normalize[-1] 0,255
  blur[-1] 2
  isophotes[-1] 6
  100%,100%,1,1
  noise[-1] 0.5,1
  lt[-1] {$1-0.5}
  mul[-1,-2]
  shape_star ,
  example_shapecloud[-2] [-1],$2
  rm[-1]


#7

Interesting! Next assignment would be to do a Tiger God or a cloud Mufasa :wink:.


(Lyle Kroll) #8

Cool stuff; what I actually meant was creating sky starts. Posted a tribute to Stephen Hawkings (link below) for what meant. Even so, like the idea of using any object. As a side note, I used voronoi stipper to place the points which I turned into starts. Added some additional background stars as well. :slight_smile:

https://www.dpreview.com/forums/post/60895796


(samj) #9

Bonjour

@lylejk
It seems to me that they are flickering and ‘white’ points about the tribute to Stephen Hawking. Thank you for this idea.

@afre
The tiger is the one of the Ghostscript examples. I use it because it is known and its contours are clear.

:o)

It’s an attempt to create stars twinkling but there is surely better.

-n[-1] 0,255
-blur[-1] 2
-isophotes[-1] 6 
{w},{h},1,4
-repeat {{{w}+{h}}/10}
-line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,255,255,255,255
-point {u(100)}%,{u(100)}%,0,1,255,255,255,255
-done
-and[-1,-2]
-i [-1]
-i [-1]
-dilate_circ[-3] 4
-dilate[-2] 10,1
-dilate[-1] 1,10
-blend[-1,-2,-3] alpha


(samj) #10

@lylejk

Here is an example of a rendering of Stephen Hawking’s photograph that uses star flickering (rendering needs to be improved).
(source https://i2-prod.mirror.co.uk/incoming/article9569949.ece/ALTERNATES/s615/Stephen-Hawking.jpg )

:o)

-n[-1] 128,255
-to_pseudogray[-1] 5,1,8
-blur[-1] 2
-isophotes[-1] 6 
{w},{h},1,4
-repeat {{{w}+{h}}/2}
-line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,255,255,255,255
-line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,0,0,0,0
-point {u(100)}%,{u(100)}%,0,1,255,255,255,255
-done
-and[-1,-2]
-i [-1]
-i [-1]
-dilate_circ[-3] 2
-dilate[-2] 6,1
-dilate[-1] 1,6
-blend[-1,-2,-3] alpha

Hommage_Stephen-Hawking


(Lyle Kroll) #11

Heard to beat GIMP’s own Sparkle filter. Still, your result looks promising. I took your latest code, then followed it by G’MIC’s morphological filter to squeeze the stars smaller, then ran GIMP’s sparkle preset (random orietation sparkles this time). :slight_smile:

Stephen-Hawkings


#12

@samj @garagecoder Could you please explain the commands a bit more?

– Is there a way to evenly distribute the objects along the contours?
– How do we add the shapes and also make them vary in size and orientation?


(samj) #13

Bonjour,

@lylejk
It’s hard to beat Gimp’s ‘sparkles’ filter…

@afre
Here is a commented example and the result

:o)

# normalize the colors between 128 and 255 to obtain lighter colors
-n[-1] 128,255
# get a 'gray' image with a richer gray
-to_pseudogray[-1] 5,1,8
# add blur for richer rendering with the 'isophotes' command
-blur[-1] 2
# to obtain contours according to the luminosite with a transparent background
-isophotes[-1] 6 
# create a new image with 4 channels to the dimensions of the current image
{w},{h},1,4
# n loops or n = (width + height) /1.5
-repeat {{{w}+{h}}/1.5} # delete points
 # draw a transparent line from the middle of image with a random length
 -line[-2] 50%,50%,{u(100)}%,{u(100)}%,1,0,0,0,0
-done
# loops 
-repeat {{{w}+{h}}/2}  # points on outlines
 # draw a white line with a random length
 -line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,255,255,255,255
-done
# loops 
-repeat {{{w}+{h}}/5}  # points outside the outlines
 # put white dots randomly on the image
 -point {u(100)}%,{u(100)}%,0,1,255,255,255,255
-done
# 'and' between the 2 images [-1,-2] to obtain a single resulting image
-and[-1,-2]
# 'circular dilation' by 3 pixels
-dilate_circ[-1] 3


(samj) #14

Another possibility to have other outlines (experimentation).

-tones[-1] 3
-isophotes[-1,-2]  3
-blend[-1,-2] alpha
-blend[-1,-2] alpha
-mul[-1] 255
-isophotes[-1] 3
{w},{h},1,4
-repeat {{{w}+{h}}/1.5} # delete points
 -line[-2] 50%,50%,{u(100)}%,{u(100)}%,1,0,0,0,0
-done
-repeat {{{w}+{h}}/2}  # points on outlines
 -line[-1] {u(100)}%,{u(100)}%,{u(100)}%,{u(100)}%,1,255,255,255,255
-done
-repeat {{{w}+{h}}/5}  # points outside the outlines
 -point {u(100)}%,{u(100)}%,0,1,255,255,255,255
-done
-and[-1,-2]
-dilate_circ[-1] 3
-c[-1] 0,255
-to_rgb[-1]


(samj) #15

Bonjour,

I grouped ideas from this thread into a G’MIC filter in Lyle Kroll’s folder.
Testing > Lylejk > Point Star Outline
(update filters)

:o)


Edit 20180405

A test :


#16

Thanks for turning this into a filter! Otherwise it was another thing on a very long list of “to do” :slight_smile: