ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
Re: [Image-SIG] Re: Image.eval problem with math.sqrt
by Bartek Wilczynski other posts by this author
Jul 14 2003 5:35PM messages near this date
[Image-SIG] IOError: cannot find glyph data file (sandra ruiz)> | [Image-SIG] Re: Image.eval problem with math.sqrt
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@salamander.com:

>  On 13 Jul 2003 20:10:17 -0400
>  "Alan Grosskurth" <alan.grosskurth@[...].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@[...].com             http://kiy.sattre-press.com/
>  



_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved