[Image-SIG] ImageMath power-function error

Mark Wendell mark.wendell at gmail.com
Mon Mar 16 15:09:48 CET 2009


Hmm. The 1.1.6 docs for the ImageMath module say "The module also supports
unary minus (-), modulo (%), and power (**) operators."

Still, if not, looking forward to having the functionality in 1.1.7.

thanks
Mark

On Mon, Mar 16, 2009 at 8:05 AM, Fredrik Lundh <fredrik at pythonware.com>wrote:

> No time to double-check, but I suspect the 1.1.6 version doesn't
> support ** - it's mentioned in the documentation, but I don't see any
> sign of it in the source code.  It's on my list of things to fix for
> 1.1.7.
>
> </F>
>
> 2009/3/15 Mark Wendell <mark.wendell at gmail.com>:
> > 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
> > _______________________________________________
> > Image-SIG maillist  -  Image-SIG at python.org
> > http://mail.python.org/mailman/listinfo/image-sig
> >
> >
>



-- 
--
Mark Wendell
mark.wendell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090316/e7b1990e/attachment-0001.htm>


More information about the Image-SIG mailing list