next up previous contents index
Next: Evaluating expressions Up: Mathematical pixel operations (Image Previous: Predefined Variables   Contents   Index


Using image names as variables

In most situations, an image can be referred to either by its filename or by its number. The only exception is in image algebra formulas, where the filename must be enclosed in double quotes to avoid possible confusion with any variable names. In macro commands, this is not necessary, but quotes are allowed. The advantage of using names is that you need not worry about an image number changing when some other image is deleted.

For example, if the image "myimage" is image no. 2, all the following are valid:

   
      convert(myimage, 24);             (changes image to 24 bits/pixel)
      convert(2,24);                    (changes image to 24 bits/pixel)
      switchto(myimage);                (select "myimage")
      switchto("myimage");              (select "myimage")
      switchto(2);                      (select "myimage")
      r = green[2][0][x][y];            (sets green equal to red)
      r = green["myimage"][0][x][y];    (sets green equal to red)
      fft(2,1);                         (forward Fourier transform of myimage)
      fft(myimage, 1);                  (forward Fourier transform of myimage)
      im = real["myimage"][x][y];       (sets imaginary equal to real component)
      im = real[2][x][y];               (same)
      evaluate(imag[2][12][12]);        (display imaginary component at 12,12)
      evaluate(imag["myimage"][12][12]);(display imaginary component at 12,12)

If more than one image has the same name, all commands will be applied to the image with the lowest image number.



root 2006-11-13