[Image-SIG] ImageMath power-function error

Mark Wendell mark.wendell at gmail.com
Sun Mar 15 18:15:08 CET 2009


Hey all,

I can't seem to use the power ("**") operator in the ImageMath module.


For example, multiplying an L-mode image by a factor of 2.0 works fine:

>>> out = ImageMath.eval( "convert( ( a*val ), 'L')", a=im, val=2.0)
(no errors)

However, raising the same image by a power of 2.0 generates a bad operand
type error:

>>> out = ImageMath.eval( "convert( ( a**val ), 'L')", a=im, val=2.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/ImageMath.py", line 203, in
eval
    out =__builtin__.eval(expression, args)
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/ImageMath.py", line 119, in
__pow__
    return self.apply("pow", self, other)
  File "/usr/lib/python2.5/site-packages/PIL/ImageMath.py", line 82, in
apply
    raise TypeError, "bad operand type for '%s'" % op
TypeError: bad operand type for 'pow'


Am I making a silly mistake?

thanks in advance,
Mark

Ubuntu 8.10 linux, python 2.5.2, Pil 1.1.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090315/82e78587/attachment.htm>


More information about the Image-SIG mailing list