Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14797 > unrolled thread
| Started by | semeon.risom@gmail.com |
|---|---|
| First post | 2015-01-04 08:47 -0800 |
| Last post | 2015-01-06 00:28 +0000 |
| Articles | 15 — 6 participants |
Back to article view | Back to comp.lang.php
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
| From | semeon.risom@gmail.com |
|---|---|
| Date | 2015-01-04 08:47 -0800 |
| Subject | Running same code multiple times, while only changing two parameters |
| Message-ID | <7a2f6bc8-1f1d-4e65-98ea-f9d4f80e8c0b@googlegroups.com> |
Hello -
Beginner at PHP. I'm attempting to run the piece of code (attached below) that will generate an image. What I'm attempting to do is run the same piece of code 600 times to create 600 images. The only change is two parameters labeled "orientation" and "frequency", which I have a list of values I'm hoping to feed into the code.
As it is, the code gives the option of including each value into their respective parameters at once, but unfortunately creates an image for all possible pairs of values (600^2, I think). I also get the following message if I exceed a 30 second loading time:
"Fatal error: Maximum execution time of 30 seconds exceeded in /home/cogscinl/public_html/files/software/gabor/libgabor.php on line 69
Any advice on a way to work this code to create the 600 images?
Thanks!
- Semeon
<?php
/**
* This file is part of <http://www.cogsci.nl>.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
**/
require_once("libgabor.php");
if (array_key_exists("generate", $_GET)) {
$orient = $_GET["orient"];
$size = $_GET["size"];
$std = $_GET["std"];
$env = $_GET["env"];
$freq = $_GET["freq"];
$phase = $_GET["phase"];
$red0 = $_GET["red0"];
$green0 = $_GET["green0"];
$blue0 = $_GET["blue0"];
$red1 = $_GET["red1"];
$green1 = $_GET["green1"];
$blue1 = $_GET["blue1"];
$red2 = $_GET["red2"];
$green2 = $_GET["green2"];
$blue2 = $_GET["blue2"];
} else {
$orient = 45;
$std = 12;
$size = 8 * $std;
$env = "gaussian";
$freq = 0.1;
$phase = 0.0;
$red0 = 128;
$green0 = 128;
$blue0 = 128;
$red1 = 255;
$green1 = 255;
$blue1 = 255;
$red2 = 0;
$green2 = 0;
$blue2 = 0;
}
?>
<p>
Gabor patches are sinusoidal gratings, typically with a Gaussian envelope, which are frequently used as stimuli in psychological experiments. Using this page you can easily create and download high quality Gabor patches.
As with most topics, you can find out more about Gabor patches on <a href="http://en.wikipedia.org/wiki/Gabor_filter" target="newwindow">Wikipedia</a>.
</p>
<p>
In order to generate multiple Gabor patches at once, you can enter multiple values separated by a comma (",").
You can download generated stimuli separately or at once as a .zip file.
Please note that the script may time out if you generate too many or very large stimuli.
</p>
<p>
If you are here in the hope of training your eyesight, see <a href='http://www.cogsci.nl/blog/miscellaneous/226-can-you-brain-train-your-way-to-perfect-eyesight'>this post</a> for a critical discussion of recent claims that visual training with Gabor patches improves vision.
</p>
<h2>Specify and generate</h2>
<?php require("gaborform.php"); ?>
<h2>View and download</h2>
<?php
error_reporting(E_ALL);
$zipfile = "tmp/gabor-" . rand() . ".zip";
$zip = new ZipArchive();
if ($zip->open($zipfile, ZIPARCHIVE::CREATE)!==TRUE) {
print "<p><b>Warning:</b> failed to create zip archive!</p>\n";
}
echo "<p align=\"center\"><a href=\"$zipfile\">Download all patches as a .zip file</a></p>\n";
echo "<table width=\"100%\" class=\"defaulttable\">\n";
foreach (explode(",", $orient) as $_orient) {
$_orient = floatval($_orient);
foreach (explode(",", $size) as $_size) {
$_size = floatval($_size);
foreach (explode(",", $std) as $_std) {
$_std = floatval($_std);
foreach (explode(",", $freq) as $_freq) {
$_freq = floatval($_freq);
foreach (explode(",", $phase) as $_phase) {
$_phase = floatval($_phase);
foreach (explode(",", $red0) as $_red0) {
$_red0 = floatval($_red0);
foreach (explode(",", $green0) as $_green0) {
$_green0 = floatval($_green0);
foreach (explode(",", $blue0) as $_blue0) {
$_blue0 = floatval($_blue0);
foreach (explode(",", $red1) as $_red1) {
$_red1 = floatval($_red1);
foreach (explode(",", $green1) as $_green1) {
$_green1 = floatval($_green1);
foreach (explode(",", $blue1) as $_blue1) {
$_blue1 = floatval($_blue1);
foreach (explode(",", $red2) as $_red2) {
$_red2 = floatval($_red2);
foreach (explode(",", $green2) as $_green2) {
$_green2 = floatval($_green2);
foreach (explode(",", $blue2) as $_blue2) {
$_blue2 = floatval($_blue2);
$color0 = array($_red0, $_green0, $_blue0);
$color1 = array($_red1, $_green1, $_blue1);
$color2 = array($_red2, $_green2, $_blue2);
$fname = show_gabor($_orient, $_size, $_std, $_freq,
$_phase, $color0, $color1, $color2, $env);
$zip->addFile($fname);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$zip->close();
echo "</table>\n";
?>
<p><i><a href='https://github.com/smathot/gabor-patch-generator'>Source code</a></i></p>
[toc] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2015-01-04 19:13 +0100 |
| Message-ID | <cgte6nFfurfU1@mid.individual.net> |
| In reply to | #14797 |
On 04/01/15 17:47, semeon.risom@gmail.com wrote:
> Hello -
>
> Beginner at PHP. I'm attempting to run the piece of code (attached below) that will generate an image.
> What I'm attempting to do is run the same piece of code 600 times to create 600 images.
> The only change is two parameters labeled "orientation" and "frequency", which I have a list of values I'm hoping to feed into the code.
You need to make it into a function which takes the which takes all the
variables that can change as in parameters.
function generate_my_picture($var1, $var2) {
/* the code here */
}
Then you can make a for-loop or something that generates the images in
question by calling the function with the different values.
> As it is, the code gives the option of including each value into their respective parameters at once,
> but unfortunately creates an image for all possible pairs of values (600^2, I think).
Remove the foreach you don't need, just use the static value you need
for that variable.
> I also get the following message if I exceed a 30 second loading time:
>
> "Fatal error: Maximum execution time of 30 seconds exceeded in /home/cogscinl/public_html/files/software/gabor/libgabor.php on line 69
This for your php.ini (my be in control of your web hosting company)
limits the execution time to 30 seconds, if it takes longer, it will
stop the execution of the script.
Scripts that executes a long time ain't meant as web pages, but cli
script would be a better option, as you will not be limited in execution
time.
> if (array_key_exists("generate", $_GET)) {
> $orient = $_GET["orient"];
> $size = $_GET["size"];
> $std = $_GET["std"];
> $env = $_GET["env"];
> $freq = $_GET["freq"];
> $phase = $_GET["phase"];
> $red0 = $_GET["red0"];
> $green0 = $_GET["green0"];
> $blue0 = $_GET["blue0"];
> $red1 = $_GET["red1"];
> $green1 = $_GET["green1"];
> $blue1 = $_GET["blue1"];
> $red2 = $_GET["red2"];
> $green2 = $_GET["green2"];
> $blue2 = $_GET["blue2"];
This is really bad and dangerous way of handling user input, you should
ALWAYS validate the data before use.
--
//Aho
[toc] | [prev] | [next] | [standalone]
| From | semeon.risom@gmail.com |
|---|---|
| Date | 2015-01-04 13:18 -0800 |
| Message-ID | <a431fea1-bfe3-4d8e-8230-cad2832fef54@googlegroups.com> |
| In reply to | #14798 |
On Sunday, 4 January 2015 12:13:52 UTC-6, J.O. Aho wrote:
> On 04/01/15 17:47, semeon.risom@gmail.com wrote:
> > Hello -
> >
> > Beginner at PHP. I'm attempting to run the piece of code (attached below) that will generate an image.
> > What I'm attempting to do is run the same piece of code 600 times to create 600 images.
> > The only change is two parameters labeled "orientation" and "frequency", which I have a list of values I'm hoping to feed into the code.
>
> You need to make it into a function which takes the which takes all the
> variables that can change as in parameters.
>
> function generate_my_picture($var1, $var2) {
> /* the code here */
> }
>
> Then you can make a for-loop or something that generates the images in
> question by calling the function with the different values.
>
>
> > As it is, the code gives the option of including each value into their respective parameters at once,
> > but unfortunately creates an image for all possible pairs of values (600^2, I think).
>
> Remove the foreach you don't need, just use the static value you need
> for that variable.
>
>
> > I also get the following message if I exceed a 30 second loading time:
> >
> > "Fatal error: Maximum execution time of 30 seconds exceeded in /home/cogscinl/public_html/files/software/gabor/libgabor.php on line 69
>
> This for your php.ini (my be in control of your web hosting company)
> limits the execution time to 30 seconds, if it takes longer, it will
> stop the execution of the script.
>
> Scripts that executes a long time ain't meant as web pages, but cli
> script would be a better option, as you will not be limited in execution
> time.
>
>
>
> > if (array_key_exists("generate", $_GET)) {
> > $orient = $_GET["orient"];
> > $size = $_GET["size"];
> > $std = $_GET["std"];
> > $env = $_GET["env"];
> > $freq = $_GET["freq"];
> > $phase = $_GET["phase"];
> > $red0 = $_GET["red0"];
> > $green0 = $_GET["green0"];
> > $blue0 = $_GET["blue0"];
> > $red1 = $_GET["red1"];
> > $green1 = $_GET["green1"];
> > $blue1 = $_GET["blue1"];
> > $red2 = $_GET["red2"];
> > $green2 = $_GET["green2"];
> > $blue2 = $_GET["blue2"];
>
>
> This is really bad and dangerous way of handling user input, you should
> ALWAYS validate the data before use.
>
>
> --
>
> //Aho
Thank you!
- Semeon
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-01-04 20:58 +0000 |
| Message-ID | <874ms6z2jp.fsf@bsb.me.uk> |
| In reply to | #14797 |
semeon.risom@gmail.com writes: > Beginner at PHP. I'm attempting to run the piece of code (attached > below) that will generate an image. What I'm attempting to do is run > the same piece of code 600 times to create 600 images. The only change > is two parameters labeled "orientation" and "frequency", You mean "orient" and "freq" I think. > which I have > a list of values I'm hoping to feed into the code. > > As it is, the code gives the option of including each value into their > respective parameters at once, but unfortunately creates an image for > all possible pairs of values (600^2, I think). Only if you have 600 different "orient" values and 600 different "freq" values, and you ask the code to run them all at once. You'd get 600 images if you had, for example, 24 orientations and 25 frequencies. > I also get the following message if I exceed a 30 second loading time: > > "Fatal error: Maximum execution time of 30 seconds exceeded in > /home/cogscinl/public_html/files/software/gabor/libgabor.php on line > 69 This is a common limit for PHP (it's the default limit in fact). You might be able to change it, but that usually requires you to have some sort of administrator rights. > Any advice on a way to work this code to create the 600 images? I'm not sure what the problem is. For what different parameter values do you want to generate images? (At a guess, I think you really want all 600*600 images but because of this time limit you want to generate them 600 at a time, but guessing is a flawed method of giving advice.) <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | semeon.risom@gmail.com |
|---|---|
| Date | 2015-01-04 13:15 -0800 |
| Message-ID | <8e0a3f82-6daa-4f62-9f1b-b89918b0417c@googlegroups.com> |
| In reply to | #14799 |
On Sunday, 4 January 2015 14:58:10 UTC-6, Ben Bacarisse wrote: > semeon.risom@gmail.com writes: > > > Beginner at PHP. I'm attempting to run the piece of code (attached > > below) that will generate an image. What I'm attempting to do is run > > the same piece of code 600 times to create 600 images. The only change > > is two parameters labeled "orientation" and "frequency", > > You mean "orient" and "freq" I think. > > > which I have > > a list of values I'm hoping to feed into the code. > > > > As it is, the code gives the option of including each value into their > > respective parameters at once, but unfortunately creates an image for > > all possible pairs of values (600^2, I think). > > Only if you have 600 different "orient" values and 600 different "freq" > values, and you ask the code to run them all at once. You'd get 600 > images if you had, for example, 24 orientations and 25 frequencies. > > > I also get the following message if I exceed a 30 second loading time: > > > > "Fatal error: Maximum execution time of 30 seconds exceeded in > > /home/cogscinl/public_html/files/software/gabor/libgabor.php on line > > 69 > > This is a common limit for PHP (it's the default limit in fact). You > might be able to change it, but that usually requires you to have some > sort of administrator rights. > > > Any advice on a way to work this code to create the 600 images? > > I'm not sure what the problem is. For what different parameter values > do you want to generate images? > > (At a guess, I think you really want all 600*600 images but because of > this time limit you want to generate them 600 at a time, but guessing is > a flawed method of giving advice.) > > <snip> > -- > Ben. Yes, "orient" and "freq" are the parameters I'm referring to. I have 600 images I am trying to generate. Each image has specific orientation and frequency values. Unfortunately, if I include all the values directly into the code, the code tries to generate all possible combinations. Generating past 100 images creates the Fatal Error mentioned. Example: Frequency Image 1) 50 Image 2) 65 Image 3) 97 ... Orientation Image 1) 65 Image 2) 45 Image 3) 66 ... What I want (Frequency, Orientation) Image 1) 50, 65 Image 2) 65, 45 Image 3) 97, 66 ... What's happening (Frequency, Orientation) Image 1) 50, 65 Image 2) 50, 45 Image 3) 50, 66 Image 4) 65, 65 Image 5) 65, 45 Image 6) 65, 66 Image 7) 97, 65 Image 8) 97, 45 Image 9) 97, 66
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2015-01-04 23:21 +0100 |
| Message-ID | <m8cedb$30c$2@solani.org> |
| In reply to | #14800 |
semeon.risom@gmail.com wrote:
> Example:
> Frequency
> Image 1) 50
> Image 2) 65
> Image 3) 97
> ...
>
> Orientation
> Image 1) 65
> Image 2) 45
> Image 3) 66
> ...
>
> What's happening (Frequency, Orientation)
> [9 "images"]
That is because you are nesting two loops, e.g.
foreach (array(50, 65, 97) as $freq) {
foreach (array(65, 45, 66) as $orient) {
// do something with $freq and $orient here
}
}
> What I want (Frequency, Orientation)
> [3 "images"]
Then you should use only one loop, e.g.
$pairs = array(array(50, 65), array(65, 45), array(97, 66));
foreach ($pairs as $pair) {
list($freq, $orient) = explode($pair);
// do something with $freq and $orient here
}
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Richard Damon <Richard@Damon-Family.org> |
|---|---|
| Date | 2015-01-04 16:21 -0500 |
| Message-ID | <n9iqw.1205379$yK.716818@fx14.iad> |
| In reply to | #14797 |
On 1/4/15 11:47 AM, semeon.risom@gmail.com wrote: > Hello - > > Beginner at PHP. I'm attempting to run the piece of code (attached > below) that will generate an image. What I'm attempting to do is run > the same piece of code 600 times to create 600 images. The only > change is two parameters labeled "orientation" and "frequency", which > I have a list of values I'm hoping to feed into the code. > > As it is, the code gives the option of including each value into > their respective parameters at once, but unfortunately creates an > image for all possible pairs of values (600^2, I think). I also get > the following message if I exceed a 30 second loading time: > > "Fatal error: Maximum execution time of 30 seconds exceeded in > /home/cogscinl/public_html/files/software/gabor/libgabor.php on line > 69 > > > Any advice on a way to work this code to create the 600 images? > > Thanks! > > - Semeon While it depends a bit on the final application for the images, what I've done in situations like this is make the script take as parameters in the URL the values (and validate them in the script) and the script generates a SINGLE image and sends it to the browser. The script could also write out the file for that image, and at its start, check if the file exist and just copy it to the output to save time. For the page using those images just call the script as the image source (or check if the file exists, if so use the file, else the script to be more efficient). You could also just make a page (or pages) that references all the scripts and run it once to generate the files. This way, each script only needs to generate 1 file in the 30 seconds allocated to it.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-04 22:22 +0000 |
| Message-ID | <m8cefl$35d$1@dont-email.me> |
| In reply to | #14797 |
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. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-04 23:10 +0000 |
| Message-ID | <m8ch9f$35d$2@dont-email.me> |
| In reply to | #14804 |
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
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-04 23:14 +0000 |
| Message-ID | <m8chgs$35d$3@dont-email.me> |
| In reply to | #14805 |
On Sun, 04 Jan 2015 23:10:39 +0000, Denis McMahon wrote:
Two corrections are needed to this code:
> 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
.............................^
insert ";" character
> $fn = printf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
................^^^^^^
sprintf
> make_gabor($o, $f, $fn);
> }
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | semeon.risom@gmail.com |
|---|---|
| Date | 2015-01-05 12:47 -0800 |
| Message-ID | <4616b72a-9c1f-48d0-92f7-30a6c3e77352@googlegroups.com> |
| In reply to | #14806 |
On Sunday, 4 January 2015 17:15:08 UTC-6, Denis McMahon wrote:
> On Sun, 04 Jan 2015 23:10:39 +0000, Denis McMahon wrote:
>
> Two corrections are needed to this code:
>
> > 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
> .............................^
>
> insert ";" character
>
> > $fn = printf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
> ................^^^^^^
>
> sprintf
>
> > make_gabor($o, $f, $fn);
> > }
>
> --
> Denis McMahon, denismfmcmahon@gmail.com
Sorry for the pestering questions, but if I wanted to paste the values into the syntax, would they be included like the example below?
Note: I'm using Notepad++ to edit the syntax.
Example: orient values: 30 28 42 98; freq values .30 .38 .37 .41
.......
.......
for ($o = 30 28 42 98; $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 = sprintf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
make_gabor($o, $f, $fn);
[toc] | [prev] | [next] | [standalone]
| From | semeon.risom@gmail.com |
|---|---|
| Date | 2015-01-05 12:50 -0800 |
| Message-ID | <fc602659-a8e6-4863-b701-94ec4f63cfc6@googlegroups.com> |
| In reply to | #14809 |
On Monday, 5 January 2015 14:47:55 UTC-6, semeon...@gmail.com wrote:
> On Sunday, 4 January 2015 17:15:08 UTC-6, Denis McMahon wrote:
> > On Sun, 04 Jan 2015 23:10:39 +0000, Denis McMahon wrote:
> >
> > Two corrections are needed to this code:
> >
> > > 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
> > .............................^
> >
> > insert ";" character
> >
> > > $fn = printf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
> > ................^^^^^^
> >
> > sprintf
> >
> > > make_gabor($o, $f, $fn);
> > > }
> >
> > --
> > Denis McMahon, denismfmcmahon@gmail.com
>
> Sorry for the pestering questions, but if I wanted to paste the values into the syntax, would they be included like the example below?
>
> Note: I'm using Notepad++ to edit the syntax.
>
> Example: orient values: 30 28 42 98; freq values .30 .38 .37 .41
> .......
> .......
> for ($o = 30 28 42 98; $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 = sprintf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
> make_gabor($o, $f, $fn);
Unfortunately, I'm getting the error below after replacing the original gabor.php file with the syntax you provided.
Parse error: syntax error, unexpected 'require' (T_REQUIRE) in C:\xampp\htdocs\amit\gabor-patch-generator\src\gabor.php on line 6
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-06 00:42 +0000 |
| Message-ID | <m8fb1t$ppm$2@dont-email.me> |
| In reply to | #14810 |
On Mon, 05 Jan 2015 12:50:26 -0800, semeon.risom wrote:
> Unfortunately, I'm getting the error below after replacing the original
> gabor.php file with the syntax you provided.
>
> Parse error: syntax error, unexpected 'require' (T_REQUIRE) in
> C:\xampp\htdocs\amit\gabor-patch-generator\src\gabor.php on line 6
Yes, this is an issue caused by line wrapping in usenet.
I would have hoped that you would have sufficient php skill to realise
that in the file, the url for the gabor library ends with the filename,
and in the next line, the require statement is on it's own.
ie:
The code that wrapped like this:
------------------------------------------------------
<?php
// libgabor.php can be found at //
https://github.com/smathot/gabor-patch-generator/blob/master/src/
libgabor.php require("libgabor.php");
------------------------------------------------------
should be in the file like this:
------------------------------------------------------
<?php
// libgabor.php can be found at
// https://github.com/smathot/ ... /src/libgabor.php
require("libgabor.php");
------------------------------------------------------
(which I hope has now wrapped correctly)
As an alternative, replace it with:
------------------------------------------------------
<?php
/******
libgabor.php can be found at
https://github.com/smathot/gabor-patch-generator/blob/master/src/
libgabor.php
******/
require("libgabor.php");
------------------------------------------------------
If you still don't understand what bit is the comment text and what bit
is the statement, perhaps you need to find a very basic introduction to
php tutorial.
The one at
http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/
should be reasonable, you may wish to ignore web specific html etc bits.
Please DO NOT under any circumstances follow w3schools tutorials, they
are frequently inaccurate and flawed.
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-06 18:59 +0000 |
| Message-ID | <m8hb9v$nc$1@dont-email.me> |
| In reply to | #14812 |
On Tue, 06 Jan 2015 00:42:37 +0000, Denis McMahon wrote:
> should be in the file like this:
>
> ------------------------------------------------------
> <?php
>
> // libgabor.php can be found at // https://github.com/smathot/ ...
> /src/libgabor.php require("libgabor.php");
> ------------------------------------------------------
>
> (which I hope has now wrapped correctly)
It didn't! Here it is again with extra blank lines:
------------------------------------------------------
<?php
// libgabor.php can be found at
// https://github.com/smathot/ ... /src/libgabor.php
require("libgabor.php");
------------------------------------------------------
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-01-06 00:28 +0000 |
| Message-ID | <m8fa7a$ppm$1@dont-email.me> |
| In reply to | #14809 |
On Mon, 05 Jan 2015 12:47:45 -0800, semeon.risom wrote:
> On Sunday, 4 January 2015 17:15:08 UTC-6, Denis McMahon wrote:
>> On Sun, 04 Jan 2015 23:10:39 +0000, Denis McMahon wrote:
>>
>> Two corrections are needed to this code:
>>
>> > 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
>> .............................^
>>
>> insert ";" character
>>
>> > $fn = printf("gabor_patches/patch_%02d_%02d.png", $o, $f *
>> > 10);
>> ................^^^^^^
>>
>> sprintf
>>
>> > make_gabor($o, $f, $fn);
>> > }
>>
>> --
>> Denis McMahon, denismfmcmahon@gmail.com
>
> Sorry for the pestering questions, but if I wanted to paste the values
> into the syntax, would they be included like the example below?
>
> Note: I'm using Notepad++ to edit the syntax.
>
> Example: orient values: 30 28 42 98; freq values .30 .38 .37 .41 .......
> .......
> for ($o = 30 28 42 98; $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 = sprintf("gabor_patches/patch_%02d_%02d.png", $o, $f * 10);
> make_gabor($o, $f, $fn);
No, the way I wrote the for loops is to step through a range of values in
a given increment.
If you want a non linear range, I suggest you create an array of values
and use a foreach loop to step through the array. Note that in this
example I'm also using 3 digit orient and freq in the file names, and
I've reduced the code inside the loop to a single statement (that will
wrap because of usenet limitations).
example:
$orients = array(30, 28, 42, 98); // all the orient vals
$freqs = array(.30, .38, .37, .41); // all the freq vals
foreach ($orients as $o)
foreach ($freqs as $f)
make_gabor($o, $f, sprintf("gabor_patches/patch_%03d_%03d.png",
$o, $f * 100));
--
Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web