It is currently Mon Apr 15, 2024 8:01 am


All times are UTC - 5 hours [ DST ]


Switch to mobile style

Post new topic Reply to topic  [ 81 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:09 am  (#1) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
This is one of Paul Harrison's older scripts that I thought I would give a try. I tried multiple ways to find information on the error, on my own, and came up short.

Error is:

Error while executing script-fu-patch-synthesize:

Error: =: argument 1 must be: number

The script:
; Patch-splat texture synthesis
; (Fast tilable texture synthesis script)

;    Copyright (C) 2003  Paul Francis Harrison

;    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

; Copy a random rectangle to clipboard
(define (grab-patch img layer patch-size patch-border)
  (let*
    (
      (width    (car (gimp-drawable-width layer)))
      (height   (car (gimp-drawable-height layer)))
    )

    (gimp-rect-select img
      (+ patch-border (rand (- width  (* patch-border 2) patch-size)))
      (+ patch-border (rand (- height (* patch-border 2) patch-size)))
      patch-size patch-size 2 1 (* patch-border 2))
    (gimp-edit-copy layer)
  )
)

; Paste the clipboard and apply Sharpen Feathering
(define (put-patch img layer x y use-sharp)
  (let*
    (
      (floater (car (gimp-edit-paste layer FALSE)))
    )
    (gimp-layer-set-offsets floater x y)
    (if (= use-sharp TRUE) (plug-in-sharpfeather 1 img floater))
    (gimp-floating-sel-anchor floater)
  )
)

; Shuffle a list randomly (hacky)
(define (shuffle old)
  (let*
    (
      (new '())
    )

    (while (not (= old '()))
      (if (= (rand 2) 1)
        (set! new (cons (car old) new))
   (set! new (append new (list (car old))))
      )
      (set! old (cdr old))
    )

    new
  )
)

(define (script-fu-patch-synthesize img layer out-width out-height patch-proportion patch-feather-proportion use-sharp)
  (let*
    (
      (width     (car (gimp-drawable-width layer)))
      (height    (car (gimp-drawable-height layer)))
      (type      (car (gimp-drawable-type layer)))
      (base-type (car (gimp-image-base-type img)))
      (new-img   (car (gimp-image-new out-width out-height base-type)))
      (new-layer (car (gimp-layer-new new-img out-width out-height type "Background" 100 0)))

      (patch-size (* (min width height out-width out-height) patch-proportion 0.5))
      (patch-border (* patch-size patch-feather-proportion 0.25))
      (patch-jitter (/ patch-size 8))
      (patch-total  (+ patch-size patch-border patch-border))

      (xx 0)
      (yy 0)
      (old-selection 0)
      (point-list '())
    )

    (gimp-image-add-layer new-img new-layer 0)
    (gimp-edit-clear new-layer)
    (gimp-display-new new-img)
    (gimp-displays-flush)

    (gimp-image-undo-freeze img)
    (gimp-image-undo-disable new-img)

    (set! old-selection (car (gimp-selection-save img)))

    (while (< xx out-width)
      (set! yy 0)
      (while (< yy out-height)
        (set! point-list (cons (cons xx yy) point-list))
        (set! yy (+ yy (- patch-size patch-border patch-border patch-jitter)))
      )
      (set! xx (+ xx (- patch-size patch-border patch-border patch-jitter)))
    )

    (set! point-list (shuffle point-list))
    (set! point-list (shuffle point-list))
    (set! point-list (shuffle point-list))
    (set! point-list (shuffle point-list))

    (while (not (= point-list nil))
      (grab-patch img layer patch-size patch-border)

      (let*
   (
     (x (+ (caar point-list) (rand patch-jitter)))
     (y (+ (cdar point-list) (rand patch-jitter)))
   )

   (put-patch new-img new-layer x y use-sharp)
   (if (>= x (- out-width patch-total))
     (put-patch new-img new-layer (- x out-width) y use-sharp)
   )
   (if (>= y (- out-height patch-total))
     (put-patch new-img new-layer x (- y out-height) use-sharp)
   )
   (if
     (and
       (>= x (- out-width patch-total))
       (>= y (- out-height patch-total))
     )   
     (put-patch new-img new-layer (- x out-width) (- y out-height) use-sharp)
   )
      )

      (if (= (fmod (length point-list) 8) 7) (gimp-displays-flush))

      (set! point-list (cdr point-list))
    )

    (gimp-selection-load old-selection)
    (gimp-image-remove-channel img old-selection)
   
    (gimp-image-undo-enable new-img)
    (gimp-image-undo-thaw img)

    (gimp-displays-flush)
  )
)

(script-fu-register "script-fu-patch-synthesize"
                    "<Image>/Script-Fu/Render/Synthesize Texture..."
          "Create a tilable texture of arbitrary size from a sample, by simply copying random patches of the sample. The edges of each patch are disguised using the 'Sharpen Feathering' plug-in."
          "Paul Harrison (pfh@csse.monash.edu.au)"
          "Paul Harrison"
          "18/3/2003"
          "RGB GRAY"
          SF-IMAGE "Input Image" 0
          SF-DRAWABLE "Input Layer" 0
          SF-VALUE "Output width" "300"
          SF-VALUE "Output height" "300"
          SF-ADJUSTMENT "Patch size" '(0.6 0.1 1.0 0.01 0.1 1 0)
          SF-ADJUSTMENT "Patch feathering" '(0.5 0.0 1.0 0.01 0.1 1 0)
          SF-TOGGLE "Use feather sharpen" 1
)

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


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: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:37 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
Believe that's one of the Script-fus that was for GIMP 1.2.4. That's one of the reasons that I keep GIMP 1.2.4 around. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:41 am  (#3) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
Did you try it?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:52 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
Yes; don't remember where I found the Windows Compile for this plugin. Don't think Paul will mind, so I'm attaching the Window Zip files here. Note it's for GIMP 1.2.4 of course. Works great for textures like grass and rocks; not so good for geometrics. The patchworks SCM is locate in this zipped file too. :)


Attachments:
textureops-0.2.zip [21.27 KiB]
Downloaded 147 times

_________________
Lyle

Psalm 109:8

Image
Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:54 am  (#5) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
Almost like you're reading my mind, Lyle, lol. I was planning on trying it with the ghost diagrams.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:56 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
Again, I don't think you will be happy with the results for using it with Ghost diagrams since they are pretty geometric. It will give results similar to Resynthesizer and I'm sure you know how that's going to look like. As a side note, I created seamless textures using the output from Ghost diagrams the old fashion and hard way. Aligned to where four points in a square would repeat; takes a lot of trial and error to get it right though; just among the many tricks I learned over the years to creating seamless textures which is sort of my passion and it's where I dedicated my Deviant solely too :)

Click below for my Deviant (SSP; lol).

http://lylejk.deviantart.com/

_________________
Lyle

Psalm 109:8

Image


Last edited by lylejk on Thu Mar 10, 2011 3:01 am, edited 1 time in total.

Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 3:01 am  (#7) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
Yep. I wasn't liking the results of that. Made it look like torn grafitti, very splotchy (ugly).

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 5:35 am  (#8) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
mahvin wrote:
Error: =: argument 1 must be: number


Try changing the following line:
(while (not (= old '()))

to:
(while (pair? old)

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 10:25 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
The script will run without the error on XP now (thanks Saulgoode).
My problem is they (The binaries) require libgimp-1.2.0.dll to work.
Wouldn't happen to be able to throw that in a zip and give it to us would you Lyle? :)

_________________
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: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 1:12 pm  (#10) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
No changes in Ubuntu 10.04, still throwing the same error.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 1:44 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2238
Location: Poland
A newer version texturetiler.exe [ http://www.aljacom.com/~gimp/greffons.html ]

download http://www.aljacom.com/~gimp/texturetiler-i686.zip

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 1:53 pm  (#12) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
So is fixed now ?

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:13 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2238
Location: Poland
Make Seamless Texture [Filters/Map/] - it works for Gimp 2.6 and 2.7.1 (XP)

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:15 pm  (#14) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
It's not fixed for me (patchsynth.scm). I've already compiled texturetiler on Ubuntu, along with sharpfeather (those are working fine for me, just not patchsynth.scm).

I also compared mareroq's link for the source code with Paul Harrison's source code, both are the same, although the Windows exe is compiled for 64bit.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:20 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
I installed the new texturetiler binary and now i get the same error you do Mahvin. :)

_________________
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: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:34 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
Rod wrote:
The script will run without the error on XP now (thanks Saulgoode).
My problem is they (The binaries) require libgimp-1.2.0.dll to work.
Wouldn't happen to be able to throw that in a zip and give it to us would you Lyle? :)


Not sure if this one will be of any use to you Rod, but I'm attaching it. If it does work, please tell me where you put this one at. Too chicken to try to put it in GIMP2.0's shared. :)


Attachments:
libgimp-1-2-0.zip [54.87 KiB]
Downloaded 118 times

_________________
Lyle

Psalm 109:8

Image
Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:35 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
I'm running 32-bit GIMP so I guess it won't work for me MareroQ. Oh well.

edit:

Went ahead and tried it anyway. It works. Much better the GIMP's make seamless filter imo. Thanks for the link MareroQ. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 2:53 pm  (#18) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Hard to follow
the script work now with GG correction and the updated binaries ?
And... still require the old libgimp ?(but if so why if the depending plugins were updated )

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 3:32 pm  (#19) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Thanks Lyle - i placed it along with libintl-1.dll, the older binaries of sharpen feather and texturetiler in my
user/gimp-2.6/plugins folder. No more on load errors, but neither will run.
I decided to go ahead and use the new texturetiler binary and wait to see if someone can give us some answers for the error with the scm file.

_________________
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: Patchsynth.scm Help
PostPosted: Thu Mar 10, 2011 3:34 pm  (#20) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Another thing is you can not find a newer version of sharpen feathering.

_________________
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 new topic Reply to topic  [ 81 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group