KyleCrothers.com     
Contribute  :  Advanced Search  :  Site Statistics  :  Directory  :  Web Resources  :  Polls  
 Wednesday, September 08 2010 @ 09:34 PM EDT

Gimp Digital camo script

   
ProjectsWhen I wanted a GIMP script to create digital camo I searched the internet and found several places where people made requests for scripts but there weren't any. So, like any good geek I wrote one.





















I'm not 100% happy with the script but I don't want to put any more time into it and it works just good enough.

Enjoy!


;
; This code is by Kyle Crothers
; and is largely based on the previous work of
; Chris Gutteridge (cjg@ecs.soton.ac.uk)
; At ECS Dept, University of Southampton, England.

; 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-digitalcamo-pattern inSize inGrain inColor1 inColor1Slice inColor2 inColor2Slice inColor3 inColor3Slice inColor4 inColor4Slice inPixelize inPixAmount inFlatten)

  (let* (
        (theWidth inSize)
        (theHeight inSize)
        (theImage (car (gimp-image-new theWidth theHeight RGB)))
        (baseLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Background" 100 NORMAL-MODE)))
        (basePLayer 0)
        (thickLayer 0)
        (bushLayer 0)
        (thinLayer 0)
        (grassLayer 0)
        (earthLayer 0)
        (shadowLayer 0)
        (doubleGrain 0)
        )

    (gimp-context-push)

    (gimp-image-add-layer theImage baseLayer 0)

    (set! doubleGrain (* 2 inGrain) )
    
    (set! basePLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Camo Base Layer" 100 NORMAL-MODE)))
    (gimp-image-add-layer theImage basePLayer 0)
    (gimp-drawable-set-name basePLayer "Base Layer")

    (gimp-selection-all theImage)
    (gimp-context-set-background inColor1)
    (gimp-drawable-fill baseLayer BACKGROUND-FILL)

    (plug-in-plasma RUN-NONINTERACTIVE
			 theImage basePLayer (rand 65536) 7)
    (gimp-desaturate basePLayer)

    (set! thickLayer (car (gimp-layer-copy basePLayer TRUE)))
    (gimp-drawable-set-name thickLayer "Layer 1")
    (set! bushLayer (car (gimp-layer-copy basePLayer TRUE)))
    (gimp-drawable-set-name bushLayer "Layer 2")
    (set! thinLayer (car (gimp-layer-copy basePLayer TRUE)))
    (gimp-drawable-set-name thinLayer "Layer 3")
    (set! grassLayer (car (gimp-layer-copy basePLayer TRUE)))
    (gimp-drawable-set-name grassLayer "Layer 4")

    (gimp-image-add-layer theImage thickLayer 0)
    (gimp-image-add-layer theImage bushLayer 0)
    (gimp-image-add-layer theImage thinLayer 0)
    (gimp-image-add-layer theImage grassLayer 0)
    
    (gimp-threshold basePLayer inColor1Slice 255)    ;  Layer 1
    (gimp-threshold thickLayer inColor2Slice 192)    ;  Layer 2
    (gimp-threshold bushLayer inColor3Slice 128)      ;  Layer 3
    (gimp-threshold thinLayer inColor4Slice 64)        ;  Layer 4
    (gimp-threshold grassLayer 200 255)
    ;(gimp-threshold earthLayer 100  200)
    ;(gimp-threshold shadowLayer 0  100)



    ;;;;  Base Layer
    (gimp-context-set-background inColor4)
    (gimp-by-color-select basePLayer
			  '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear basePLayer)
    (gimp-selection-none theImage)
    (plug-in-pixelize RUN-NONINTERACTIVE theImage basePLayer inPixAmount)
    (gimp-by-color-select basePLayer
			  '(255 255 255) 1 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear basePLayer)
    (gimp-selection-invert theImage)
    (gimp-edit-fill basePLayer BACKGROUND-FILL)
    (gimp-selection-none theImage)
    



    ;;;;  Layer 1
    (gimp-context-set-background inColor1)
    (gimp-by-color-select thickLayer
			  '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear thickLayer)
    (gimp-selection-none theImage)
    (plug-in-pixelize RUN-NONINTERACTIVE theImage thickLayer inPixAmount)
    (gimp-by-color-select thickLayer
			  '(255 255 255) 1 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear thickLayer)
    
    (gimp-edit-fill thickLayer BACKGROUND-FILL)
    (gimp-selection-none theImage)
       



    ;;;;  Layer 2
    (gimp-context-set-background inColor2)
    (gimp-by-color-select bushLayer
			  '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear bushLayer)
    (gimp-selection-none theImage)
    (plug-in-pixelize RUN-NONINTERACTIVE theImage bushLayer inPixAmount)
    (gimp-by-color-select bushLayer
			  '(255 255 255) 1 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear bushLayer)
    ;(gimp-selection-invert theImage)
    (gimp-edit-fill bushLayer BACKGROUND-FILL)
    (gimp-selection-none theImage)
       



    ;;;;  Layer 3
    (gimp-context-set-background inColor3)
    (gimp-by-color-select thinLayer
			  '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear thinLayer)
    (gimp-selection-none theImage)
    (plug-in-pixelize RUN-NONINTERACTIVE theImage thinLayer inPixAmount)
    (gimp-by-color-select thinLayer
			  '(255 255 255) 1 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear thinLayer)
    ;(gimp-selection-invert theImage)
    (gimp-edit-fill thinLayer BACKGROUND-FILL)
    (gimp-selection-none theImage)
    ;(if (= inSmooth TRUE)
    ;    (script-fu-tile-blur theImage thinLayer theBlur TRUE TRUE FALSE)
    ;)
       



    ;;;;  Layer 4
    (gimp-context-set-background inColor4)
    (gimp-by-color-select grassLayer
			  '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear grassLayer)
    (gimp-selection-none theImage)
    (plug-in-pixelize RUN-NONINTERACTIVE theImage grassLayer inPixAmount)
    (gimp-by-color-select grassLayer
			  '(255 255 255) 1 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
    (gimp-edit-clear grassLayer)
    ;(gimp-selection-invert theImage)
    (gimp-edit-fill grassLayer BACKGROUND-FILL)
    (gimp-selection-none theImage)
    ;(if (= inSmooth TRUE)
    ;    (script-fu-tile-blur theImage grassLayer theBlur TRUE TRUE FALSE)
    ;)



    (if (= inFlatten TRUE)
        (gimp-image-flatten theImage)
    )


    (gimp-display-new theImage)

    (gimp-context-pop)
  )
)


; Register the function with GIMP:

(script-fu-register
  "script-fu-digitalcamo-pattern"
  _"_Digital Camouflage..."
  _"Create an image filled with a digital camouflage pattern"
  "Kyle Crothers"
  "12-24-2009"
  ""
  ""
  SF-ADJUSTMENT _"Image size"    '(512 10 2000 1 10 0 1)
  SF-ADJUSTMENT _"Granularity"   '(15 0 15 1 1 0 0)
  SF-COLOR      _"Primary Color"       '(89 105 105)
  SF-ADJUSTMENT _"Color 1 Slice"   '(192 192 255 1 1 0 0)
  SF-COLOR      _"Color 2"       '(130 130 130)
  SF-ADJUSTMENT _"Color 2 Slice"   '(128 128 192 1 1 0 0)
  SF-COLOR      _"Color 3"       '(155 155 155)
  SF-ADJUSTMENT _"Color 3 Slice"   '(64 64 128 1 1 0 0)
  SF-COLOR      _"Color 4"       '(180 180 180)
  SF-ADJUSTMENT _"Color 4 Slice"   '(0 0 64 1 1 0 0)
  SF-TOGGLE     _"Pixelize"       TRUE
  SF-ADJUSTMENT _"Pixelize Amount"   '(6 0 16 1 1 0 0)
  SF-TOGGLE     _"Flatten image" TRUE
)


(script-fu-menu-register "script-fu-digitalcamo-pattern"
                         "/File/Create/Patterns")
 

What's Related

Story Options

Gimp Digital camo script | 1 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Gimp Digital camo script
Authored by: kcrothers on Monday, January 04 2010 @ 11:55 PM EST
The image posted is the raw output. It looks very nice if you apply artistic/canvas afterward.
 Copyright © 2010 KyleCrothers.com
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.24 seconds