Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14805
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Running same code multiple times, while only changing two parameters |
| Date | 2015-01-04 23:10 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <m8ch9f$35d$2@dont-email.me> (permalink) |
| References | <7a2f6bc8-1f1d-4e65-98ea-f9d4f80e8c0b@googlegroups.com> <m8cefl$35d$1@dont-email.me> |
On Sun, 04 Jan 2015 22:22:45 +0000, Denis McMahon wrote:
> On Sun, 04 Jan 2015 08:47:05 -0800, semeon.risom wrote:
>
>> Any advice on a way to work this code to create the 600 images?
>
> 1) the code doesn't have to run on someone elses web server. With a few
> mods you can run it on any machine that has php installed, and php
> command line versions are available for windows, linux and macos.
>
> 2) separate the core functionality of the program (which I guess is the
> code to create one image given a set of params) from the supporting code
> which determines the params for the image, outputs the image etc. Put
> this core code into a single function that takes a set of params and
> outputs an image object.
>
> 3) write your own code to loop through the relevant param settings, call
> the image creation function with relevant params, and then save the
> generated image object to a suitable image file.
>
> 4) debug.
>
> 5) look at your shiny images.
In fact, on a machine with the right php installation (ie including
imagemagick I think) and a copy of libgabor.php, the following code is
all you need to generate your own gabor sets. Adjust parameters as
required:
<?php
// libgabor.php can be found at
// https://github.com/smathot/gabor-patch-generator/blob/master/src/
libgabor.php
require("libgabor.php");
/**
This wrapper defines the constant values to pass to the
generate_gabor function defined in libgabor.php.
The variable values are handled in the for loops below.
**/
function make_gabor($orient, $freq, $outfile) {
// The size of the patch in pixels.
$size = 96;
// The envelope, gaussian, linear, hann, hamming, circle,
// or rectangle.
$env = "gaussian";
// The standard deviation of the envelope, in case it is
// gaussian.
$std = 12;
// The phase of the patch.
$phase = 0.0;
// The background color as an RGB array.
$color0 = array(128, 128, 128);
// The first foreground color as an RGB array.
$color1 = array(255, 255, 255);
// The second foreground color as an RGB array.
$color2 = array(0, 0, 0);
generate_gabor($orient, $size, $env, $std, $freq, $phase,
$color0, $color1, $color2, $outfile);
}
for ($o = 30; $o < 61; $o += 5) // $orient values 30 .. 60
for ($f = 0.2; $f < 0.9 $f += 0.2) { // $freq values 0.2 .. 0.8
$fn = printf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
make_gabor($o, $f, $fn);
}
You may need to create the subdir gabor_patches to save files in before
running the program.
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 08:47 -0800
Re: Running same code multiple times, while only changing two parameters "J.O. Aho" <user@example.net> - 2015-01-04 19:13 +0100
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 13:18 -0800
Re: Running same code multiple times, while only changing two parameters Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-01-04 20:58 +0000
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-04 13:15 -0800
Re: Running same code multiple times, while only changing two parameters "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-04 23:21 +0100
Re: Running same code multiple times, while only changing two parameters Richard Damon <Richard@Damon-Family.org> - 2015-01-04 16:21 -0500
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 22:22 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 23:10 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-04 23:14 +0000
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-05 12:47 -0800
Re: Running same code multiple times, while only changing two parameters semeon.risom@gmail.com - 2015-01-05 12:50 -0800
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 00:42 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 18:59 +0000
Re: Running same code multiple times, while only changing two parameters Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-06 00:28 +0000
csiph-web