It is currently Tue May 07, 2024 11:10 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Is a Propogation Script Possible
PostPosted: Tue Jul 23, 2013 8:48 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
Hi everyone.

I will often times run through a process where I

1. Duplicate a Layer
2. Set the layer to Darken only Mode
3. Propogate the layer Using the Value Propogate with More Black as the only setting.
4. Do this 6 more times, creating layers that have the dark pixels spread out one pixel each time.
5. Then I take each of the 7 layers and use the curves on them to in efect make a bevel trailing out from the original image. I use the curves and drag the left slider node up to the levels of the dividend of the whole. The math would divide the 256 by 7 to get each layers setting. Know what I mean?

Here is what I am doing:

Image

This process is much like the Light to Height script but it uses darken only and propogates out in all directions.

Anyway if someone could show me how to make a script to do this it woud save me a lot of time. I do this often to give heightmap images a beveled edge to accomodate for a pencil shaped carving bit.

pegsli


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: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:42 am  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Please try the following when you get a chance.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License

(define (script-fu-sg-height-bevel image drawable)
  (gimp-image-undo-group-start image)
  (gimp-selection-none image)
  (gimp-layer-set-mode drawable DARKEN-ONLY-MODE)
  (let loop ((iterations 6)
             (layers (list drawable)) )
    (if (zero? iterations)
      (map (lambda (layer low-output)
             (gimp-levels layer HISTOGRAM-VALUE 0 255 1.0 low-output 255) )
           (cdr (reverse layers))
           '(36 73 109 146 182 219) )
      (let ((layer (car (gimp-layer-copy (car layers) FALSE))))
        (gimp-image-insert-layer image layer 0 -1)
        (gimp-image-lower-layer image layer)
        (gimp-layer-set-mode layer DARKEN-ONLY-MODE)
        (plug-in-vpropagate RUN-NONINTERACTIVE
                            image
                            layer
                            1 ; darker
                            15 ; all channels
                            1.0 ; rate 0-1
                            15 ; all directions
                            0
                            255 )
        (loop (pred iterations) (cons layer layers)) )))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )
                           
(script-fu-register "script-fu-sg-height-bevel"
"Height Bevel per Pegleg44"
"Adds beveled layers per Pegleg44"
"Saul Goode"
"Saul Goode"
"July 2013"
"*"
SF-IMAGE    "Image"    0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-sg-height-bevel"
  "<Image>/Filters/Decor/"
  )

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 11:16 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
That works great soulgoode!

I tried it and it's great. I found that it only makes 7 steps so I changed the line
(let loop ((iterations 6) to
(let loop ((iterations 7)
and changed to histgram value I think it is to: '(32 64 96 128 160 192 224) )

Now I wonder if you could add one more thing to the script. You see if you could make it possible to changethe high value as well as the low it would make it possible for me to have a gradual taper according to the height of the edge. Now I explained before that I dragged the low value slider on the curves (left node slider on the curves dialog box) up but it would also make a better script if I could move the (top left node int the curves box to the left the same amount as the low level goes up. In other works your script in effect does this:
Image

But I think it would be nice if it could do this:
Image

Here's an example of what it looks like. I'm shooting for the bottom right image.
Image

If I could work the high values at the same time as the low values it would be terrific.

pegstro


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:01 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
In the script, try changing the 'map' statement from:
      (map (lambda (layer low-output)
             (gimp-levels layer HISTOGRAM-VALUE 0 255 1.0 low-output 255) )
           (cdr (reverse layers))
           '(36 73 109 146 182 219) )

to:
      (map (lambda (layer low-output high-input)
             (gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
           (cdr (reverse layers))
           '( 32  64  96 128 160 192 224)
           '(224 192 160 128  96  64  32) )


Note: even though I am using the Levels filter to adjust the brightness, the resulting curve is identical to the one attained had I used the Curves filter (it's just a little easier to code).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:12 pm  (#5) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
:oops: I copied the script into my script folder and now I don't know how to work it.

_________________
Image


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:15 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Well, the command is added as "Filters->Decor->Height Bevel per Pegleg44". As to how to use it, you will have to wait for Pegleg to explain that. :)

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:17 pm  (#7) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
Ok, thanks Saul.

_________________
Image


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 12:58 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
molly wrote:
:oops: I copied the script into my script folder and now I don't know how to work it.

The script uses darken only mode which blends two greycale images together very well. I don't think it would work on colored images very well. You would most likeley use the script on a greyscale image with a while backround color.

Thanks for that tip soulgoode. I'll try to add that into the code and see if I can get it to work. Is there a list of code and what it does available somewhere? I'm looking at the code you wrote and see some stuff but I could use a beginers guide or something.

Thanks!

pegstro


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 1:02 pm  (#9) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
I saved the code as a scm and put it in my scripts folder and it does show up in Gimp, I made a black cross on a transparent layer with a white background, ran alpha to selection and it ran but didn't do anything.

_________________
Image


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 1:27 pm  (#10) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
molly wrote:
I saved the code as a scm and put it in my scripts folder and it does show up in Gimp, I made a black cross on a transparent layer with a white background, ran alpha to selection and it ran but didn't do anything.

The script only works on the painted parts of a layer (for all intents and purposes, it is meant for layers without any transparency).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 1:30 pm  (#11) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
o, I didn't know that, thanks Saul

_________________
Image


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 1:46 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
molly wrote:
I saved the code as a scm and put it in my scripts folder and it does show up in Gimp, I made a black cross on a transparent layer with a white background, ran alpha to selection and it ran but didn't do anything.

You may need to zoom in to see any difference along the edges. The way the script works is noticable only along high contrast areas between pixels. To make it more noticable you could ad more iterations in the script and then put in more numbers.

Here is the script with 31 iterations:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License

(define (script-fu-sg-height-bevel image drawable)
(gimp-image-undo-group-start image)
(gimp-selection-none image)
(gimp-layer-set-mode drawable DARKEN-ONLY-MODE)
(let loop ((iterations 31)
(layers (list drawable)) )
(if (zero? iterations)
(map (lambda (layer low-output high-input)
(gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
(cdr (reverse layers))
'(8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168 176 184 192 200 208 216

224 232 240 248)
'(248 240 232 224 216 208 200 192 184 176 168 160 152 144 136 128 120 112 104 96 88 80 72 64 56 48

40 32 24 16 8) )
(let ((layer (car (gimp-layer-copy (car layers) FALSE))))
(gimp-image-insert-layer image layer 0 -1)
(gimp-image-lower-layer image layer)
(gimp-layer-set-mode layer DARKEN-ONLY-MODE)
(plug-in-vpropagate RUN-NONINTERACTIVE
image
layer
1 ; darker
15 ; all channels
1.0 ; rate 0-1
15 ; all directions
0
255 )
(loop (pred iterations) (cons layer layers)) )))
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)

(script-fu-register "script-fu-sg-height-bevel"
"Height Bevel per Pegleg44"
"Adds beveled layers per Pegleg44"
"Saul Goode"
"Saul Goode"
"July 2013"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-sg-height-bevel"
"<Image>/Filters/Decor/"
)


Alan


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 2:04 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
Here's an example of 31 iterations on some text filled with a Black to white gradient.

Of coarse I also flattend it and did an Emboss and Colorize on it too.

Image

Pretty cool stuff!

Thanks soulgoode,

pegsly


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 5:52 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
This will launch a widget asking for iterations 0-1000 although 12 seems to be a good limit. :)
Just an example of how you can add a different value each time without editing the scm file all the time for iteration steps/loops.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License

(define (script-fu-sg-height-bevel image drawable iterations)
  (gimp-image-undo-group-start image)
  (gimp-selection-none image)
  (gimp-layer-set-mode drawable DARKEN-ONLY-MODE)
  (let loop ((iterations iterations)
             (layers (list drawable)) )
    (if (zero? iterations)
      (map (lambda (layer low-output high-input)
             (gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
           (cdr (reverse layers))
           '( 32  64  96 128 160 192 224)
           '(224 192 160 128  96  64  32) )
      (let ((layer (car (gimp-layer-copy (car layers) FALSE))))
        (gimp-image-insert-layer image layer 0 -1)
        (gimp-image-lower-layer image layer)
        (gimp-layer-set-mode layer DARKEN-ONLY-MODE)
        (plug-in-vpropagate RUN-NONINTERACTIVE
                            image
                            layer
                            1 ; darker
                            15 ; all channels
                            1.0 ; rate 0-1
                            15 ; all directions
                            0
                            255 )
        (loop (pred iterations) (cons layer layers)) )))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )
                           
(script-fu-register "script-fu-sg-height-bevel"
"Height Bevel per Pegleg44"
"Adds beveled layers per Pegleg44"
"Saul Goode"
"Saul Goode"
"July 2013"
"*"
SF-IMAGE    "Image"    0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "Iterations" '(15 0 1000 1 1 0 1)
)
(script-fu-menu-register "script-fu-sg-height-bevel"
  "<Image>/Filters/Decor/"
  )

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 8:18 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
Rod wrote:
This will launch a widget asking for iterations 0-1000 although 12 seems to be a good limit. :)
Just an example of how you can add a different value each time without editing the scm file all the time for iteration steps/loops.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License

(define (script-fu-sg-height-bevel image drawable iterations)
  (gimp-image-undo-group-start image)
  (gimp-selection-none image)
  (gimp-layer-set-mode drawable DARKEN-ONLY-MODE)
  (let loop ((iterations iterations)
             (layers (list drawable)) )
    (if (zero? iterations)
      (map (lambda (layer low-output high-input)
             (gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
           (cdr (reverse layers))
           '( 32  64  96 128 160 192 224)
           '(224 192 160 128  96  64  32) )
      (let ((layer (car (gimp-layer-copy (car layers) FALSE))))
        (gimp-image-insert-layer image layer 0 -1)
        (gimp-image-lower-layer image layer)
        (gimp-layer-set-mode layer DARKEN-ONLY-MODE)
        (plug-in-vpropagate RUN-NONINTERACTIVE
                            image
                            layer
                            1 ; darker
                            15 ; all channels
                            1.0 ; rate 0-1
                            15 ; all directions
                            0
                            255 )
        (loop (pred iterations) (cons layer layers)) )))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )
                           
(script-fu-register "script-fu-sg-height-bevel"
"Height Bevel per Pegleg44"
"Adds beveled layers per Pegleg44"
"Saul Goode"
"Saul Goode"
"July 2013"
"*"
SF-IMAGE    "Image"    0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "Iterations" '(15 0 1000 1 1 0 1)
)
(script-fu-menu-register "script-fu-sg-height-bevel"
  "<Image>/Filters/Decor/"
  )

Hi Rod

That's a good script to have the iterations available for modifications. I get these error messages though when its in the middle of changing the levels:

Image

peglo


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 8:28 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
This is the file i use with no errors. :)

Attachment:
sg-height-bevel.scm [1.72 KiB]
Downloaded 163 times

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 8:43 pm  (#17) 
Offline
GimpChat Member

Joined: May 23, 2012
Posts: 150
Saul
Great job high-bevel, I think several other scripts and plug-ins could
use multi iteration processes as well, if I knew script-fu and gimp
commands as well as you, I would change the code a little
to make a multi iteration drop shadow, and perspective shadow, at 1,
or 5 percent shade for each iteration. Maybe wrap multi iteration and
some others or, a multi iteration drop in scripts or plug-in,
template wrapper skeleton, if possible.
A multi iteration, to create pattern, texture, gradient, brush shape.
Repeat last command is only good for some things.
Sounds like a lot of work, sorry just spouting suggestions.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Wed Jul 24, 2013 10:40 pm  (#18) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
Rod wrote:
This is the file i use with no errors. :)

Attachment:
sg-height-bevel.scm


It's the same code that I saved as a .scm file. Is the name of .scm file important?

Or maybe since I have other files in my scripts folder it messes things up. (I made three .scm files with different iteration settings).

The original script has high input and low output numbers written in the code for changing each created layers color values. And these numbers correspond with the number of layers made. Does your script just overlook this and figure it out itself for the number of layers and or iterations in the dialog box?

Shouldn't there be some kind of thing that figures out the math for the layer high and low values to match up with the iterations to get the right bevel?

pegleg


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Thu Jul 25, 2013 3:28 am  (#19) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
PegLeg44 wrote:
Shouldn't there be some kind of thing that figures out the math for the layer high and low values to match up with the iterations to get the right bevel?

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

(define (script-fu-sg-height-bevel image drawable nb-levels)
  (set! nb-levels (truncate nb-levels))
  (gimp-image-undo-group-start image)
  (gimp-selection-none image)
  (gimp-layer-set-mode drawable DARKEN-ONLY-MODE)
  (let ((levels (let loop ((count (- nb-levels 1))
                           (result '(0)) )
                  (if (zero? count)
                    (cdr (reverse result))
                    (loop (- count 1)
                          (cons (+ (/ 256 nb-levels)
                                   (car result) )
                                result ))))))
    (let loop ((iterations (- nb-levels 1))
               (layers (list drawable)) )
      (if (zero? iterations)
        (map (lambda (layer low-output high-input)
               (gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
             (cdr (reverse layers))
             levels
             (reverse levels) )
        (let ((layer (car (gimp-layer-copy (car layers) FALSE))))
          (gimp-image-insert-layer image layer 0 -1)
          (gimp-image-lower-layer image layer)
          (gimp-layer-set-mode layer DARKEN-ONLY-MODE)
          (plug-in-vpropagate RUN-NONINTERACTIVE
                              image
                              layer
                              1 ; darker
                              15 ; all channels
                              1.0 ; rate 0-1
                              15 ; all directions
                              0
                              255 )
          (loop (pred iterations) (cons layer layers)) ))))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )
                           
(script-fu-register "script-fu-sg-height-bevel"
"Height Bevel per Pegleg44..."
"Add beveled layers per Pegleg44"
"Saul Goode"
"Saul Goode"
"July 2013"
"*"
SF-IMAGE    "Image"    0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "Number of levels" '( 8 2 100 1 5 0 1)
)
(script-fu-menu-register "script-fu-sg-height-bevel"
  "<Image>/Filters/Decor/"
  )

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Is a Propogation Script Possible
PostPosted: Thu Jul 25, 2013 10:33 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Feb 14, 2012
Posts: 426
So

(set! nb-levels (truncate nb-levels)) brings up the dialog box.

(count (- nb-levels 1) This count lets you put in your input.

(result '(0)) ) says it needs a result

(if (zero? count) this says use the count

(cdr (reverse result)) this says reverse the count for the white levels

--------------------------------------------

(let ((levels (let loop ((count (- nb-levels 1))
(result '(0)) )
(if (zero? count)
(cdr (reverse result))
(loop (- count 1)
(cons (+ (/ 256 nb-levels)
(car result) )
result ))))))
(let loop ((iterations (- nb-levels 1))
(layers (list drawable)) )

This code says figure out the iterations by the number set in the dialog.

--------------------------------------------------------------

(if (zero? iterations)
(map (lambda (layer low-output high-input)
(gimp-levels layer HISTOGRAM-VALUE 0 high-input 1.0 low-output 255) )
(cdr (reverse layers))
levels
(reverse levels) )

This tells the layers to change levels when called upon.

-----------------------------------------------------------

(let ((layer (car (gimp-layer-copy (car layers) FALSE))))
(gimp-image-insert-layer image layer 0 -1)
(gimp-image-lower-layer image layer)
(gimp-layer-set-mode layer DARKEN-ONLY-MODE)
(plug-in-vpropagate RUN-NONINTERACTIVE
image
layer
1 ; darker
15 ; all channels
1.0 ; rate 0-1
15 ; all directions
0
255 )

This creates layers and propogates them.

----------------------------------------------------------------

(loop (pred iterations) (cons layer layers)) ))))
(gimp-image-undo-group-end image)
(gimp-displays-flush)

This says go back and do the levels on the various layers the way that was figured out earlier.

--------------------------------------------------------

I'm not going to be able to jump in and start coding stuff. I'm much more interested in creating art. My son is starting to play around with code for his minecraft game. I think he'll get into it much more than me. He's 10

I'm going to play around with the all directions for the propogate and see if I can make it do this in various directions. I think there are 0 through 15 directrions to try.

Alan


Top
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Looking for Script Coder to make Script of my VHS effect

2

No new posts Attachment(s) A liitle Start Help with a Script-Fu Script

3

No new posts Attachment(s) Cannot run test script-fu script via console

7

No new posts Attachment(s) Script-fu

6

No new posts Attachment(s) Rotate Hue Script

74



* Login  



Powered by phpBB3 © phpBB Group