It is currently Tue Nov 10, 2026 1:08 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: non-interactive call to voronoi (updated)
PostPosted: Tue Jul 11, 2017 10:34 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
GIMP Version: 2.8.22
Operating System: Windows
GIMP Experience: Basic Level

List any relevant plug-ins or scripts:
voronoi

List any ERROR messages you received:
none



Did someone ever try to use voronoi from inside a filter?
Yesterday I tried it.
As opposed to qbist (which is not callable non-interactively, as ofnuts confirmed to me), I do not get any error, simply it doesn't do anything.
Here my initial code (I tried to reproduce the list of parameters used interactivelky, which works fine):
#!/usr/bin/env python
from gimpfu import *

def EasyVoronoiMosaic (inImage, inDrawable, inSize) :

    pdb.gimp_context_push
    currFG = pdb.gimp_context_get_foreground()
    currBG = pdb.gimp_context_get_background()
   
    # -------------------------------------------------------------------------------------
    newImage = pdb.gimp_image_new(inImage.width, inImage.height, RGB)
   
    BG_Layer = pdb.gimp_layer_new_from_drawable (inDrawable,newImage)
    BG_Layer.name = "Background Layer"
    BG_Layer.mode = NORMAL_MODE
    newImage.add_layer(BG_Layer, 0)
   
    VORONOI_Layer = BG_Layer.copy()
    VORONOI_Layer.name = "Voronoi Layer"
    VORONOI_Layer.mode = MULTIPLY_MODE
    newImage.add_layer(VORONOI_Layer, 0)
   
    alpha=pdb.gimp_drawable_has_alpha(VORONOI_Layer)
    if (alpha==False):
        pdb.gimp_layer_add_alpha (VORONOI_Layer)    #  RGBA
     
    pdb.plug_in_voronoi (newImage, VORONOI_Layer,
                         11,        #seed
                         -1,        #cell-type: -1 = random, 0=square
                         inSize,    #avg cell size
                         0.15,      #unused when cell-type = random
                         0.7,       #unused when cell-type = random
                         True,      #hori tileable
                         True,      #vert tileable
                         0.0,       #value rescale(log)
                         0.0,       #value shift
                         1,         #coloring method: 0=independent RGB 1=gradient
                         0.0,       #unused when cell-type = random
                         0.0,       #unused when cell-type = random
                         0.0,       #random color weight
                         0.0,       #radial distanmce weight
                         0.0,       #segment distance weight
                         1.0,       #border distance weight
                         0.0,       #second nearest distance weight
                         0.0,       #scalar product weight
                         True,      #invert gradient
                         "Abstract 1",
                         )   
                     
    pdb.gimp_drawable_update (VORONOI_Layer, 0, 0, VORONOI_Layer.width, VORONOI_Layer.height)

    # --------------------------------------------------------------------------------------
    # ...
    # do your stuff
    # ...
    # ...
   
    pdb.gimp_context_pop
    pdb.gimp_context_set_foreground(currFG)
    pdb.gimp_context_set_background(currBG)
   
    pdb.gimp_display_new (newImage)
   
    return

register(
    "EasyVoronoiMosaic",    "EasyVoronoiMosaic",    "EasyVoronoiMosaic",
    "DN",    "Open source (BSD 3-clause license)",    "2017",
    "EasyVoronoiMosaic",
    "RGB*",
    [
      (PF_IMAGE, "image", "Input image", None),
      (PF_DRAWABLE, "drawable", "Input drawable", None),
      (PF_ADJUSTMENT, "size", "Size of the cell", 20, (10, 40, 1)),   
    ],
    [],
    EasyVoronoiMosaic,
    menu="<Image>/Diego/Ancillary"
    )
main()

If I do the same steps interactively (i.e.: open an image, duplicate it, duplicate the layer, run voronoi with those parameters) I get a nice result.
Using this on-going filter with the embedded call I simply get the layer duplicated, no voronoi.
What's wrong?
Thanks

update (13 August)
I wrote to the author.
He said to me that after 15 or so years he doesn't even remember what a Gimp plug-in does, so he cannot help me directly.
According to what he remembers the plug-in was intended to run also non-interactively.
Hence I update here my request:
- can anyone expert in C read the source (attached in a subsequent post here) and understand what inhibits the plug-in to run non-interactively with the current Gimp version?
As stated previously, my pseudo-filter attached here as example does not return any error, simply does nothing.
If the problem is found, the source could be recompiled...
Spes ultima dea !

_________________
"Where am I ?"


Last edited by dinasset on Sun Aug 13, 2017 12:14 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: non-interactive call to voronoi
PostPosted: Wed Jul 12, 2017 1:27 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
No Voronoi in my install. What are you trying to do with pdb.gimp_drawable_update()?

PS: the doc to gimp_layer_add_alpha() says: "This procedure adds an additional component to the specified layer if it does not already possess an alpha channel." so you can avoid a test in your code.

PPS: pdb.gimp_context_pop without parentheses does nothing. It just evaluates the function object but doesn't call it. Same for the "push" part.

_________________
Image


Top
 Post subject: Re: non-interactive call to voronoi
PostPosted: Wed Jul 12, 2017 1:46 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Thanks ofnuts.

No Voronoi in my install.
I don't remember to have added this function, I find it under Filter/Render/Pattern/Voronoi

What are you trying to do with pdb.gimp_drawable_update()?
It was my "desperate" attempt to see the layer updated...

PS: the doc to gimp_layer_add_alpha() says: "This procedure adds an additional component to the specified layer if it does not already possess an alpha channel." so you can avoid a test in your code.
OK, thanks, I will remember

PPS: pdb.gimp_context_pop without parentheses does nothing. It just evaluates the function object but doesn't call it. Same for the "push" part.
OK, many thanks, I will remember

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi
PostPosted: Wed Jul 12, 2017 1:54 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
OK, doing a search I found from where it comes:
Attachment:
voronoi-2.2_32bits-64bits_gimp-2.8_win.zip [140.94 KiB]
Downloaded 245 times


So, it was an addition by me.
You may try it, if you like (the package contains also the source)

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi
PostPosted: Wed Jul 12, 2017 2:03 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12855
Yeah; the voronoi pattern generator makes cool patterns but unfortunately not adaptive ones. I wish it would have. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: non-interactive call to voronoi
PostPosted: Wed Jul 12, 2017 2:16 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Nevertheless I like them if used as an overlaying layer on the source image, to add some structure.
But sofar I didn't succeed in having my on-going filter working.

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Sun Aug 13, 2017 12:14 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
see post #1 for the update

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Mon Aug 14, 2017 7:24 am  (#8) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16252
dinasset wrote:
GIMP Version: 2.8.22
Operating System: Windows
GIMP Experience: Basic Level

List any relevant plug-ins or scripts:
voronoi

List any ERROR messages you received:
none



Did someone ever try to use voronoi from inside a filter?
Yesterday I tried it.
As opposed to qbist (which is not callable non-interactively, as ofnuts confirmed to me), I do not get any error, simply it doesn't do anything.
Here my initial code (I tried to reproduce the list of parameters used interactivelky, which works fine):

If I do the same steps interactively (i.e.: open an image, duplicate it, duplicate the layer, run voronoi with those parameters) I get a nice result.
Using this on-going filter with the embedded call I simply get the layer duplicated, no voronoi.
What's wrong?
Thanks

update (13 August)
I wrote to the author.
He said to me that after 15 or so years he doesn't even remember what a Gimp plug-in does, so he cannot help me directly.
According to what he remembers the plug-in was intended to run also non-interactively.
Hence I update here my request:
- can anyone expert in C read the source (attached in a subsequent post here) and understand what inhibits the plug-in to run non-interactively with the current Gimp version?
As stated previously, my pseudo-filter attached here as example does not return any error, simply does nothing.
If the problem is found, the source could be recompiled...
Spes ultima dea !

    pdb.plug_in_voronoi (newImage, VORONOI_Layer,


Don't you need a "1" before newImage?
    pdb.plug_in_voronoi (1,newImage, VORONOI_Layer,
                         11,        #seed
                         -1,        #cell-type: -1 = random, 0=square
                         inSize,    #avg cell size
                         0.15,      #unused when cell-type = random
                         0.7,       #unused when cell-type = random
                         True,      #hori tileable
                         True,      #vert tileable
                         0.0,       #value rescale(log)
                         0.0,       #value shift
                         1,         #coloring method: 0=independent RGB 1=gradient
                         0.0,       #unused when cell-type = random
                         0.0,       #unused when cell-type = random
                         0.0,       #random color weight
                         0.0,       #radial distanmce weight
                         0.0,       #segment distance weight
                         1.0,       #border distance weight
                         0.0,       #second nearest distance weight
                         0.0,       #scalar product weight
                         True,      #invert gradient
                         "Abstract 1",
                         )   

INTERACTIVE = 0
NON-INTERACTIVE = 1

_________________
Image


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Mon Aug 14, 2017 11:31 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Hi Rod,
the interactive/non-interactive flag (run mode) is mentioned in all PDB help (procedure browser), but never used (in a python filter).
If I add it, I get the error "wrong number of parameters".
Thanks anyhow.

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Tue Aug 15, 2017 2:15 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2010
Posts: 2253
Location: Retired Moderator Slowly Returning to the Living.
I know this isn't what you were looking for but I wanted to share it, in the hopes it will help. I do want to find a way to call this up with Shellout.

I just saw this post and it started me thinking about using voronoi years ago. It was a DOS program that ran in a command window. I decided to play with it a bit and, although I don't have it working through Gimp yet, I wrote a DOS batch file that should certainly make using it easier. I have the batch file located in the Voronoi folder inside the Program Files (x86) folder. Once I wrote the script I right clicked the .bat and selected Create Shortcut. I right clicked on the shortcut and had it pinned to the start menu. Now I just put the png file I want to stipple in the voronoi folder and run the script through the start menu.

It looks like this when you run it. NOTE: The red outline box shows the four pieces of input data.
I don't have defaults set yet, because I have to remember how to do it.
Attachment:
StippleBatImage.png
StippleBatImage.png [ 19.74 KiB | Viewed 3782 times ]


The resulting image, after playing with it in Gimp, is this:
Attachment:
BirdpaintScriptedSm.png
BirdpaintScriptedSm.png [ 2.1 MiB | Viewed 3782 times ]


Here is the batch file text. I named it Stipple.bat and I hope this helps.
;Voronoi Launcher Batch File
;PhotoMaster (aka Moose)
;08/15/2017
;voronoi -a g -t 5 -s 100000 -I %1 -O %1.svg

@echo off
c:
cd\program files (x86)\voronoi\
cls
@echo ******************************************
@echo **           Voronoi Launcher           **
@echo **       By PhotoMaster (aka Moose)     **
@echo **              08/15/2017              **
@echo ******************************************
@echo **    Source File Must Be A png file    **
@echo ******************************************


set /p source=Source file name? 
set /p thresh=Threshold (rec is 5) 
set /p points=Points (rec is 100000) 
set /p name=SVG file name? 

voronoi -a g  -t %thresh% -s %points% -I %source%.png -O %name%.svg

_________________
Artists aren't crazy! We're eccentric! ~G.M. Ross

Image

My Sigs = My Photos
Check out my work at http://www.flickr.com/photos/photomastergreg.


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Tue Aug 15, 2017 2:24 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2010
Posts: 2253
Location: Retired Moderator Slowly Returning to the Living.
Attachment:
WilburVoronoi.png
WilburVoronoi.png [ 58.81 KiB | Viewed 1444 times ]

_________________
Artists aren't crazy! We're eccentric! ~G.M. Ross

Image

My Sigs = My Photos
Check out my work at http://www.flickr.com/photos/photomastergreg.


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Tue Aug 15, 2017 6:51 am  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Thanks PM.
As you said, not what I am looking for: I like to write python filters which calls internally (non-interactively) the voronoi plug-in with random parameters then continue the image processing. The reason for it is that I like "random" results (in many of my filters I use a random selection among the options), but currently my voronoi filter can only choose randomly among pre-generated voronoi patterns.
(Similar request I posted also for Qbist).

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Tue Aug 15, 2017 7:01 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
PS:
PM, if you like play with external programs you may have a look also to http://gwyddion.net/apps/gimp-plugin-replacements.php

_________________
"Where am I ?"


Top
 Post subject: Re: non-interactive call to voronoi (updated)
PostPosted: Tue Aug 15, 2017 11:46 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2010
Posts: 2253
Location: Retired Moderator Slowly Returning to the Living.
Cool! Something new to play with!

_________________
Artists aren't crazy! We're eccentric! ~G.M. Ross

Image

My Sigs = My Photos
Check out my work at http://www.flickr.com/photos/photomastergreg.


Top
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group