Author Topic: PixelMath Avg() with symbols  (Read 3087 times)

Offline Mike Reid

  • Newcomer
  • Posts: 47
    • Mike's Astro
PixelMath Avg() with symbols
« on: 2012 March 02 00:48:06 »
This pixel math expression,

   IMG = foo;
   Avg(IMG)

yields this error,

   Avg() takes either a single image reference argument or a set of two or more arguments:
   IMG = foo; Avg( |IMG )

It works fine if you don't use a variable, like this,

   Avg(foo)

Note in the error message that a pipe is shown in the argument of Avg.  Seems like a clue.

Thanks,
Mike

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PixelMath Avg() with symbols
« Reply #1 on: 2012 March 02 04:50:59 »
Hi Mike,

If foo is an existing image and IMG is a declared PixelMath symbol, this Pixelmath expression:

IMG = foo

assigns the current pixel of foo to the IMG variable. It does not create an alias to foo, which is what I think you expected it to do. Hence, the expression:

avg( IMG )

is illegal because IMG is neither an image nor a set of two or more variables. This works:

avg( foo )

because foo is an image. In this case avg() is an invariant subexpression, computed once at the beginning of PixelMath execution as the mean pixel value of the current channel of foo.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/