[Image-SIG] Re: Image.eval problem with math.sqrt
Bartek Wilczynski
bartek at rezolwenta.eu.org
Mon Jul 14 20:35:23 EDT 2003
This is probably much slower than the point (or eval) operation, but it works.
>>> image = Image.new('I', (10, 10))
>>> img = Image.eval(image, math.sqrt)
>>> for x in xrange(img.size[0]):
... for y in xrange(img.size[1]):
... img.putpixel((x,y),math.sqrt(image.getpixel((x,y))))
...
BTW I'm wondering what's the reason for this special form lambda in the point
operator
Hope that helps.
--
regards
Bartek Wilczyñski
Quoting wmcclain at salamander.com:
> On 13 Jul 2003 20:10:17 -0400
> "Alan Grosskurth" <alan.grosskurth at utoronto.ca> wrote:
>
> > That works fine for 8-bit images, but I'm
> > still have trouble with mode 'I' images (32-bit integer):
> >
> > image = Image.new('I', (10, 10))
> > out = Image.eval(image, math.sqrt)
>
> This gets beyond my knowledge. That code calls point(), and according to
> the docs:
>
> If the image has mode "I" (integer) or "F" (floating point), you
> must use a function, and it must have the following format: argument
> * scale+ offset
>
> Example: Map floating point images
>
> out = im.point(lambda i: i * 1.2 + 10)
>
> You can leave out either the scale or the offset.
>
> Using the example lambda works in your eval(), but I don't see how to
> get in a sqrt(). Perhaps someone with better Python knowledge can help?
>
> -Bill
> --
> Sattre Press The King in Yellow
> http://sattre-press.com/ by Robert W. Chambers
> info at sattre-press.com http://kiy.sattre-press.com/
>
More information about the Image-SIG
mailing list