From hancock@anansispaceworks.com Fri Mar 1 23:08:45 2002 From: hancock@anansispaceworks.com (Terry Hancock) Date: Fri, 01 Mar 2002 15:08:45 -0800 Subject: [Image-SIG] Scaling image pixels by a variable amount. References: <3C7CFA86.1080407@iue.tuwien.ac.at> Message-ID: <3C8009FD.F1F5991B@anansispaceworks.com> Hi all, This was a major pain to figure out, so I thought I'd share my experience: The PIL API doesn't appear to provide a simple means of scaling the value of image pixels (e.g. I want to multiply every pixel by some value S -- and I don't know what S is when I write the program). This is not necessarily a bad thing, and it's clear that you're supposed to use the ".point()" method to do this, though it can be a little tricky, as I want to demonstrate here. Naively, you might follow the Image.point examples, just substituting a variable for the constant scale factor used in the examples: def return_scaled_image( S ): im = Image.open('example.png') im.point( lambda x : x * S ) return im But this doesn't work -- lambda defines a function, and therefore a new name space -- and remember that Python namespaces do not nest! Thus, we can only use S if it's global, e.g.: def return_scaled_image( S ): global S_g S_g = S im.point( lambda x : x * S_g ) return im This *does* work, but it has a subtle problem, which I found out about only after I embedded the generated images into a Zope-based webpage. That problem is that this isn't thread-safe! I've made S_g global, so it is a state variable in the module. If different instances of return_scaled_image() are running in parallel, there will be a race-condition on S_g and the results will be somewhat random. I knew I didn't like it, but now I know why. I next tried replacing the lambda with a callable class, but that doesn't work, because the isSequenceType() test inside PIL (incorrectly?) identifies the class as a sequence (I don't know if this should be considered a bug, but I don't like it), and it then tries to use the mapping interpretation, which fails, of course. I also tried doing the mapping myself, but this also failed, for reasons I never really discovered. Perhaps some more specific test is possible? Just for grins, here's what that implementation looked like (though remember that this *doesn't* work): class scale_operator_class: def __init__(self): self.scaleby = 1.0 def __call__(self, pixel): return pixel * self.scaleby def return_scaled_image( S ): im = Image.open('example.png') scale_operator = scale_operator_class() scale_operator.scaleby = S im.point( scale_operator ) return im Finally, I came up with this, which works, and is thread-safe: class scale_operator_class: def __init__(self): self.scaleby = 1.0 def applyscale(self, pixel): return pixel * self.scaleby def return_scaled_image( S ): im = Image.open('example.png') scale_operator = scale_operator_class() scale_operator.scaleby = S im.point( scale_operator.applyscale ) return im Perhaps this should have been obvious -- but it took me awhile to figure it out. Or perhaps it's clever, and so it's a good idea to share it. But anyway, there you have it. I didn't put the scaleby attribute in the __init__() function because I actually wanted to reuse the same instance several times in the same function (just change scaleby each time), instead of defining a new one each time. If I have overlooked some better way to do this, or am missing some obvious shortcoming of this approach, I'd be interested in comments. Thanks! Terry -- ------------------------------------------------------ Terry Hancock hancock@anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com P.O. Box 60583 Pasadena, CA 91116-6583 ------------------------------------------------------ From fredrik@pythonware.com Sat Mar 2 18:46:58 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sat, 2 Mar 2002 19:46:58 +0100 Subject: [Image-SIG] Scaling image pixels by a variable amount. References: <3C7CFA86.1080407@iue.tuwien.ac.at> <3C8009FD.F1F5991B@anansispaceworks.com> Message-ID: <01e401c1c21b$68e3a720$ced241d5@hagrid> > But this doesn't work -- lambda defines a function, and > therefore a new name space -- and remember that Python > namespaces do not nest! they do, in 2.2 and later -- and in 2.1, if you switch it on: http://www.python.org/doc/2.1.2/ref/nested-scopes.html > Thus, we can only use S if it's > global, e.g.: > > def return_scaled_image( S ): > global S_g > S_g = S > im.point( lambda x : x * S_g ) > return im before 2.2, the standard pydiom was to explicitly bind the value to an argument: def return_scaled_image(S): return im.point( lambda x, S=S: x * S ) cheers /F From gritsch@iue.tuwien.ac.at Sun Mar 3 19:31:48 2002 From: gritsch@iue.tuwien.ac.at (Markus Gritsch) Date: Sun, 03 Mar 2002 20:31:48 +0100 Subject: [Image-SIG] Serious PIL Memory Leak Message-ID: <3C827A24.3010809@iue.tuwien.ac.at> This is a multi-part message in MIME format. --------------060008050502040509050106 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi! I think I have discovered a serious memory leak in PIL when using the text method of the ImageDraw.Draw class. The attached script reproduces the bug. Try to remove the 100ms delay, and your memory gets filled really fast ;-) Since I use this a lot in my webcam software (http://stud4.tuwien.ac.at/~e9326522/VideoCapture/), I would like to know if there is a workaround available? Markus --------------060008050502040509050106 Content-Type: text/plain; name="PIL_memory_leak.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="PIL_memory_leak.py" from PIL import Image, ImageFont, ImageDraw import time im = Image.new('RGB', (320, 240), 0x888888) font = ImageFont.load_path('helvB08.pil') text = 'memory leak test' textcolor = 0xffffff shadowcolor = 0x000000 y = -1 x = 2 draw = ImageDraw.Draw(im) i = 0 while (1): draw.text((x-1, y-1), text, font=font, fill=shadowcolor) draw.text((x+1, y-1), text, font=font, fill=shadowcolor) draw.text((x-1, y+1), text, font=font, fill=shadowcolor) draw.text((x+1, y+1), text, font=font, fill=shadowcolor) draw.text((x, y), text, font=font, fill=textcolor) #im.save('leak.bmp') # with this delay-value, approx. 1MB/s is leaked time.sleep(0.1) print i i += 1 --------------060008050502040509050106-- From hancock@anansispaceworks.com Mon Mar 4 06:44:36 2002 From: hancock@anansispaceworks.com (Terry Hancock) Date: Sun, 03 Mar 2002 22:44:36 -0800 Subject: [Image-SIG] Scaling image pixels by a variable amount. References: <3C7CFA86.1080407@iue.tuwien.ac.at> <3C8009FD.F1F5991B@anansispaceworks.com> <01e401c1c21b$68e3a720$ced241d5@hagrid> Message-ID: <3C8317D4.CBEA3D6B@anansispaceworks.com> Fredrik Lundh wrote: > > But this doesn't work -- lambda defines a function, and > > therefore a new name space -- and remember that Python > > namespaces do not nest! > they do, in 2.2 and later -- and in 2.1, if you switch > it on: > http://www.python.org/doc/2.1.2/ref/nested-scopes.html That's interesting to know. This is actually the first time I ever had to worry about it! > before 2.2, the standard pydiom was to explicitly bind the > value to an argument: > def return_scaled_image(S): > return im.point( lambda x, S=S: x * S ) Thanks. Actually someone pointed this out to me off list. I don't regret the educational experience of doing it the other way though. Thanks, Terry -- ------------------------------------------------------ Terry Hancock hancock@anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com P.O. Box 60583 Pasadena, CA 91116-6583 ------------------------------------------------------ From usenet123@samba-choro.com.br Tue Mar 5 01:08:36 2002 From: usenet123@samba-choro.com.br (Paulo Eduardo Neves) Date: Mon, 4 Mar 2002 22:08:36 -0300 Subject: [Image-SIG] Trying to achive better quality resizing images Message-ID: <20020305010837.7C337E766C@paulinho.samba-choro.com.br> I've noticed that when I resize my photograph jpg images with PIL I get a low quality out put. See this: The original image (big - 515K): http://www.samba-choro.com.br/s-c/imagens/teste/ Now resizing it to have a width of 500px with the same aspect ratio: http://www.samba-choro.com.br/s-c/imagens/teste/PILnearest.jpg http://www.samba-choro.com.br/s-c/imagens/teste/PILbilinear.jpg http://www.samba-choro.com.br/s-c/imagens/teste/PILbicubic.jpg I'm just opening the original image, and calling resize. Now the same resize using ImageMagick: http://www.samba-choro.com.br/s-c/imagens/teste/CentroMagick.jpg ImageMagick has, by far, the best output. I've found an old thread about it in this list: http://aspn.activestate.com/ASPN/Mail/Message/583399 Fredrik Lundh suggests: http://aspn.activestate.com/ASPN/Mail/Message/583404 I've tried it and achieved: http://www.samba-choro.com.br/s-c/imagens/teste/iteracaofinal.jpg it also doesn't have a good enough quality. Am I missing something? regards, -- Paulo Eduardo Neves Agenda do Samba & Choro, o boteco virtual do samba e choro http://www.samba-choro.com.br From schutte@fel.tno.nl Tue Mar 5 08:05:04 2002 From: schutte@fel.tno.nl (K Schutte) Date: Tue, 05 Mar 2002 09:05:04 +0100 Subject: [Image-SIG] Trying to achive better quality resizing images References: <20020305010837.7C337E766C@paulinho.samba-choro.com.br> Message-ID: <3C847C30.C3D51C96@fel.tno.nl> Dear Paulo, The key is that the reduction in size does introduce aliasing in your output. The remedy against aliasing is to first low-pass filter the image before doing a reduction. The standard filter ImageFilter.SMOOTH in PIL does a fairly good job on low-pass filtering for a reduction in size of about a factor two. So the following sequence: $ python Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Image >>> im = Image.open('CentroOriginal.jpg') >>> import ImageFilter >>> print im.size (1971, 1367) >>> out = im.filter(ImageFilter.SMOOTH) >>> out3 = out.resize((1971/2,1367/2)) >>> out4 = out3.filter(ImageFilter.SMOOTH) >>> out5 = out4.resize((500, 346)) >>> out5.show() >>> gave me a fairly decent resized image. I use ImageFilter.SMOOTH two times, as it works for a reduction in size for a factor two, and you seem to want to have a reduction in size of a factor 4 = 2 * 2. Note that the OPTIMAL aliasing reduction is dependent on your application. - For having the ability to reconstruct back towards a larger image you want to have frequency domain cutoff at Nyquist rate -- this is not in PIL, and will give not so nice visual results. - For speed you might want to have a uniform filter. This is not available in a fast version in PIL. - For nice visual results you want to have a Gaussian filter. A generic Gaussian filter is not available in PIL. - As a fairly standard trade of you might want to have a small convolution approaching a Gaussian. This is what ImageFilter.SMOOTH approaches for a factor-two reduction in size. Good luck, Klamer Paulo Eduardo Neves wrote: > > I've noticed that when I resize my photograph jpg images with PIL I get > a low quality out put. See this: > > The original image (big - 515K): > http://www.samba-choro.com.br/s-c/imagens/teste/ > > Now resizing it to have a width of 500px with the same aspect ratio: > http://www.samba-choro.com.br/s-c/imagens/teste/PILnearest.jpg > http://www.samba-choro.com.br/s-c/imagens/teste/PILbilinear.jpg > http://www.samba-choro.com.br/s-c/imagens/teste/PILbicubic.jpg > I'm just opening the original image, and calling resize. > > Now the same resize using ImageMagick: > http://www.samba-choro.com.br/s-c/imagens/teste/CentroMagick.jpg > > ImageMagick has, by far, the best output. > > I've found an old thread about it in this list: > http://aspn.activestate.com/ASPN/Mail/Message/583399 > > Fredrik Lundh suggests: > http://aspn.activestate.com/ASPN/Mail/Message/583404 > > I've tried it and achieved: > http://www.samba-choro.com.br/s-c/imagens/teste/iteracaofinal.jpg > it also doesn't have a good enough quality. > > Am I missing something? > > regards, > -- > Paulo Eduardo Neves > Agenda do Samba & Choro, o boteco virtual do samba e choro > http://www.samba-choro.com.br > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig -- Klamer Schutte, E-mail: Schutte@fel.tno.nl Electro-Optical Systems, TNO Physics and Electronics Laboratory Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671 From eaw@connactivity.connactivity.com Wed Mar 6 03:31:02 2002 From: eaw@connactivity.connactivity.com (Eric Woudenberg) Date: Tue, 05 Mar 2002 22:31:02 -0500 Subject: [Image-SIG] Trying to achive better quality resizing images In-Reply-To: Your message of "Tue, 05 Mar 2002 09:05:04 +0100." <3C847C30.C3D51C96@fel.tno.nl> Message-ID: <200203060331.g263V3n27884@connactivity.connactivity.com> Klamer Schutte writes: >The key is that the reduction in size does introduce aliasing in your >output. The remedy against aliasing is to first low-pass filter the image >before doing a reduction. > >The standard filter ImageFilter.SMOOTH in PIL does a fairly good job on >low-pass filtering for a reduction in size of about a factor two. So >the following sequence: >Note that the OPTIMAL aliasing reduction is dependent on your application. >- For having the ability to reconstruct back towards a larger image you > want to have frequency domain cutoff at Nyquist rate -- this is not in > PIL, and will give not so nice visual results. >- For speed you might want to have a uniform filter. This is not available > in a fast version in PIL. >- For nice visual results you want to have a Gaussian filter. A generic > Gaussian filter is not available in PIL. >- As a fairly standard trade of you might want to have a small convolution > approaching a Gaussian. This is what ImageFilter.SMOOTH approaches for > a factor-two reduction in size. Klamer, Thanks for the good explanation. I'm finding the same problem as Paulo, but in my case I can't do factor-of-two reductions, my source images vary in size and my target image is fixed (110x110pixels). Given that batch thumbnail generation and rescaling are precisely the sort of operations that PIL and Python are perfectly suited for, wouldn't it make sense for PIL to be improved to render scaled images with a quality similar to those produced by Photoshop, et al? Thanks, Eric Woudenberg From erlend@fuglum.net Fri Mar 8 01:44:42 2002 From: erlend@fuglum.net (Erlend Fuglum) Date: Fri, 8 Mar 2002 02:44:42 +0100 Subject: [Image-SIG] Pythonware PIL problems Message-ID: <007901c1c642$d2124b40$8567fea9@fuglum> Hello there. A question from a python newbie - I hope someone can help. I want to make a small script that automatically generates a html photo album for my web page. For this I need simple image processing capabilities. This other day I downloaded and installed Pythonware's PIL modules which seem to be perfect for my intentions. Installing is OK, everything seems to be right, but using the Image.resize function I get the following error: "ImportError: The _imaging C module is not installed" This message does not help me at all. I run Python 2.0.1 on Windows2000. If anyone could guide me through this I would be very thankful indeed. Erlend From kevin@cazabon.com Fri Mar 8 01:54:53 2002 From: kevin@cazabon.com (Kevin@Cazabon.com) Date: Thu, 7 Mar 2002 18:54:53 -0700 Subject: [Image-SIG] Pythonware PIL problems References: <007901c1c642$d2124b40$8567fea9@fuglum> Message-ID: <000f01c1c645$078d7a40$2f0aa8c0@duallie> If you're interested, and can run both Python and Perl based scripts on your web server, I have a full script already written and running that you can use if you like. The way it runs now, all you have to do is create directories full of images, and it will create albums for you automatically from there (dynamically), allowing the user to specify how many images to see at a time. It uses PIL to automatically resize the images for the client browser BEFORE sending them across the network (the client sends info through a JavaScript about the current screen size). While that takes a LITTLE work on the server, it saves a LOT on bandwidth and you only have to have one copy of the image on the server. I also have another script that does something similar, but allows you to automatically tie text descriptions and linked files into each image... Check out the following, and let me know if you want the source: http://www.cazabon.com/cgi-album/photoAlbum.cgi (photos of my wedding) http://www.cazabon.com/cgi-skydiving/skylog.cgi (skydiving videos, plus descriptions, etc) Kevin Cazabon. ----- Original Message ----- From: "Erlend Fuglum" To: Sent: Thursday, March 07, 2002 6:44 PM Subject: [Image-SIG] Pythonware PIL problems > Hello there. > > A question from a python newbie - I hope someone can help. > > I want to make a small script that automatically generates a html photo > album for my web page. For this I need simple image processing capabilities. > This other day I downloaded and installed Pythonware's PIL modules which > seem to be perfect for my intentions. > > Installing is OK, everything seems to be right, but using the Image.resize > function I get the following error: "ImportError: The _imaging C module is > not installed" > This message does not help me at all. I run Python 2.0.1 on Windows2000. > > If anyone could guide me through this I would be very thankful indeed. > > Erlend > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > From hughett@mercur.uphs.upenn.edu Fri Mar 8 20:04:53 2002 From: hughett@mercur.uphs.upenn.edu (Paul Hughett) Date: Fri, 8 Mar 2002 15:04:53 -0500 Subject: [Image-SIG] BBLimage release 0.66 is now available Message-ID: <200203082004.g28K4rr19772@mercur.uphs.upenn.edu> The source distribution kit for BBLimage version 0.66 is now available from http://www.med.upenn.edu/bbl/bblimage BBLimage is a collection of tools for processing volume images, especially medical images; it includes Pyvox, a Python extension for large multi-dimensional arrays. Features added in release 0.66 include: The qdv image viewer now supports 2x zoom, and linking the two displayed images so that image motion commands apply to both; this facilitates the comparison of related images using the blink comparator. Computation of the chamfer distance and various image statistics have been added. Most functions for array norms, metrics, and histograms now accept an optional weight argument. The registration classes now support the Pearson product moment correlation as a similarity metric; they also support an initial/baseline transform and yield a transform relative to that baseline. BBLimage is currently available as an alpha release under an open- source license and is written in ANSI C and designed to be easily portable to any Unix or Posix-compatible platform. Some programs also require the X Window System. Paul Hughett ================================================================ Paul Hughett, Ph.D. Research Associate Brain Behavior Laboratory 10th floor Gates Building Hospital of the University (215) 662-6095 (voice) of Pennsylvania (215) 662-7903 (fax) 3400 Spruce Street Philadelphia PA 19104 hughett@bbl.med.upenn.edu A rose by any other name confuses the issue. -Patrick E. Raume ================================================================ From fredrik@pythonware.com Sat Mar 9 17:02:07 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sat, 9 Mar 2002 18:02:07 +0100 Subject: [Image-SIG] Trying to achive better quality resizing images References: <200203060331.g263V3n27884@connactivity.connactivity.com> Message-ID: <005801c1c78c$2b7bb140$ced241d5@hagrid> Eric Woudenberg wrote: > Given that batch thumbnail generation and rescaling are precisely the > sort of operations that PIL and Python are perfectly suited for, > wouldn't it make sense for PIL to be improved to render scaled images > with a quality similar to those produced by Photoshop, et al? sure. it's just a small matter of programming ;-) (I might be able to do something about this for 1.1.3) From eaw@connactivity.connactivity.com Sat Mar 9 17:35:46 2002 From: eaw@connactivity.connactivity.com (Eric Woudenberg) Date: Sat, 09 Mar 2002 12:35:46 -0500 Subject: [Image-SIG] Trying to achive better quality resizing images In-Reply-To: Your message of "Sat, 09 Mar 2002 18:02:07 +0100." <005801c1c78c$2b7bb140$ced241d5@hagrid> Message-ID: <200203091735.g29HZk620677@connactivity.connactivity.com> Hi Fredrik, (Wow, email from Fredrik Lundh!) >(I might be able to do something about this for 1.1.3) Thanks very much for the reply. I didn't know you where involved in this (Actually I was just reading your Tkinter Introduction last night. I haven't used Tkinter since the Packer was the favored geometry manager, so it was interesting learning grid). >sure. it's just a small matter of programming ;-) Yes, I am not quite sure what I was trying to imply in my comment :-) I guess, only that it's the sort of feature one would expect to have in a package perfectly suited to batch mode image processing. I *do* appreciate that PIL is free and works amazingly well. Rick From lennart@regebro.nu Fri Mar 8 09:30:43 2002 From: lennart@regebro.nu (Lennart Regebro) Date: Fri, 8 Mar 2002 10:30:43 +0100 Subject: [Image-SIG] Pythonware PIL problems References: <007901c1c642$d2124b40$8567fea9@fuglum> Message-ID: <00a201c1c685$75d492a0$250aa8c0@torped.se> From: "Erlend Fuglum" > Installing is OK, everything seems to be right, but using the Image.resize > function I get the following error: "ImportError: The _imaging C module is > not installed" > This message does not help me at all. I run Python 2.0.1 on Windows2000. Tha means that the py files can not find the _imaging.dll file. It must be located somewhere in your python path. Are you using Zope for your webpage, or some other webserver? From fredrik@pythonware.com Sun Mar 10 17:49:22 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sun, 10 Mar 2002 18:49:22 +0100 Subject: [Image-SIG] ANN: PIL 1.1.3rc1 sneak release Message-ID: <013d01c1c85b$f58b70e0$ced241d5@hagrid> hi folks, I just uploaded a sneak release of PIL 1.1.3 release candidate 1 to effbot.org: http://effbot.org/downloads The handbook (currently in PDF format only) can be found here here: http://www.effbot.org/books/pil-handbook.pdf The final release will be released by Secret Labs AB. We expect to release the final 1.1.3 version before the end of March. Report bugs to this list or directly to me, as usual. enjoy /F -- changes in this version (relative to 1.1.2) -- + Added ANTIALIAS downsampling filter for high-quality "resize" and "thumbnail" operations. Also added filter option to the "thumbnail" operation; the default value is NEAREST, but this will most likely change in future versions. + Fixed plugin loader to be more robust if the __file__ variable isn't set. + Added seek/tell support (for layers) to the PhotoShop loader. Layer 0 is the main image. + Added new (but experimental) "ImageOps" module, which provides shortcuts for commonly used operations on entire images. + Don't mess up when loading PNG images if the decoder leaves data in the output buffer. This could cause internal errors on some PNG images, with some versions of ZLIB. (Bug report and patch provided by Bernhard Herzog.) + Don't mess up on Unicode filenames. + Don't mess up when drawing on big endian platforms. + Made the TIFF loader a bit more robust; it can now read some more slightly broken TIFF files (based on input from Ted Wright, Bob Klimek, and D. Alan Stewart) + Added OS/2 EMX build files (from Andrew MacIntyre) + Change "ImageFont" to reject image files if they don't have the right mode. Older versions could leak memory for "P" images. (Bug reported by Markus Gritsch). + Renamed some internal functions to avoid potential build problem on Mac OS X. + Added DL_EXPORT where relevant (for Cygwin, based on input from Robert Yodlowski) + (re)moved bogus __init__ call in BdfFontFile (bug spotted by Fred Clare) + Added "ImageGrab" support (Windows only) + Added support for XBM hotspots (based on code contributed by Bernhard Herzog). + Added support for Palm pixmaps (from Bill Janssen) + Added write support for more TIFF tags, namely the Artist, Copyright, DateTime, ResolutionUnit, Software, XResolution and YResolution tags (from Greg Couch) + Added TransposedFont wrapper to ImageFont module + Added "optimize" flag to GIF encoder. If optimize is present and non-zero, PIL will work harder to create a small file. + Raise "EOFError" (not IndexError) when reading beyond the end of a TIFF sequence. + Support rewind ("seek(0)") for GIF and TIFF sequences. + Load grayscale GIF images as mode "L" + Added DPI read/write support to the JPEG codec. The decoder sets the info["dpi"] attribute for JPEG files with JFIF dpi settings. The encoder uses the "dpi" option: im = Image.open("file.jpg") dpi = im.info["dpi"] # raises KeyError if DPI not known im.save("out.jpg", dpi=dpi) Note that PIL doesn't always preserve the "info" attribute for normal image operations. -- end -- From fredrik@pythonware.com Sun Mar 10 22:35:19 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sun, 10 Mar 2002 23:35:19 +0100 Subject: [Image-SIG] ANN: PIL 1.1.3rc1 sneak release References: <013d01c1c85b$f58b70e0$ced241d5@hagrid> Message-ID: <001101c1c883$dd4397b0$ced241d5@hagrid> > I just uploaded a sneak release of PIL 1.1.3 release > candidate 1 to effbot.org: buglet: the coefficient buffer in the new Antialias module wasn't properly allocated. this can cause segmentation violations in some cases. ::: here's a patch: ==== //modules/pil/libImaging/Antialias.c#5 ==== @@ -136,7 +136,7 @@ support = support * filterscale; /* coefficient buffer (with rounding safety margin) */ - k = malloc(((int) support + 10) * sizeof(float)); + k = malloc(((int) support * 2 + 10) * sizeof(float)); if (!k) return (Imaging) ImagingError_MemoryError(); ::: the setup.py file is also missing from the release kit (which probably was a good thing, because it was slightly broken). I'll ship a c2 release within a day or two. regards /F From fredrik@pythonware.com Mon Mar 11 18:38:35 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 11 Mar 2002 19:38:35 +0100 Subject: [Image-SIG] ANN: PIL 1.1.3rc1 sneak release References: <013d01c1c85b$f58b70e0$ced241d5@hagrid> Message-ID: <033101c1c92b$f53e6bd0$ced241d5@hagrid> > I just uploaded a sneak release of PIL 1.1.3 release > candidate 1 to effbot.org: > > http://effbot.org/downloads a distutils-produced Windows installer of 1.1.3c1 plus the patch I posted yesterday is now available from the same directory: http://effbot.org/downloads/PIL-1.1.3c2.win32-py2.1.exe (currently available for 2.1 only) From fredrik@pythonware.com Tue Mar 12 08:00:08 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 12 Mar 2002 09:00:08 +0100 Subject: [Image-SIG] ANN: PIL 1.1.3 release candidate 2 Message-ID: <0ad801c1c99b$f0f0a0a0$ced241d5@hagrid> hi folks, the second release candidate for PIL 1.1.3 is now available from effbot.org: http://effbot.org/downloads changes from the first release: + Added setup.py file (tested on Unix and Windows). You still need to build libImaging/imaging.lib in the traditional way, but the setup.py script takes care of the rest. The old Setup.in/Makefile.pre.in build method is still supported. + Fixed segmentation violation in ANTIALIAS filter (an internal buffer wasn't properly allocated). see the c1 announcement (or the CHANGES-113 file included in the release) for the full list of changes. enjoy /F From alobo@ija.csic.es Tue Mar 12 12:33:31 2002 From: alobo@ija.csic.es (Agustin Lobo) Date: Tue, 12 Mar 2002 13:33:31 +0100 (MET) Subject: [Image-SIG] Numpy array to image? Message-ID: Hi, I've just found the web pages on PIL and wonder if it's possible to convert a python 2D array to an image for display. Something like the Magick.ArrayToImage(arr) that seems to be available in pymagick (which is not available any more?) according to its doc in http://starship.python.net/~zack/pymagick/ Thanks Agus Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo@ija.csic.es From fredrik@pythonware.com Tue Mar 12 14:03:17 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 12 Mar 2002 15:03:17 +0100 Subject: [Image-SIG] Numpy array to image? References: Message-ID: <013801c1c9ce$ac52fb90$0900a8c0@spiff> Agustin Lobo wrote: > I've just found the web pages on PIL and wonder > if it's possible to convert a python > 2D array to an image for display. Something > like the Magick.ArrayToImage(arr) > that seems to be available in pymagick (which is > not available any more?) according to its doc in > http://starship.python.net/~zack/pymagick/ did you try typing the subject line into google instead of your mailer ;-) here's the second google hit for "Numpy array to image": http://mail.python.org/pipermail/image-sig/1998-October/000572.html Cheers /F From fredrik@pythonware.com Thu Mar 14 00:51:38 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 14 Mar 2002 01:51:38 +0100 Subject: [Image-SIG] ANN: PIL 1.1.3 release candidate 2 References: <0ad801c1c99b$f0f0a0a0$ced241d5@hagrid> Message-ID: <001101c1caf2$686fac50$ced241d5@hagrid> > the second release candidate for PIL 1.1.3 is now > available from effbot.org: an updated handbook can be found here: http://effbot.org/books/pil-handbook.pdf 1.1.3 final will be released on (or around) this friday, from http://www.pythonware.com/products/pil/ enjoy /F From clee@spiralis.merseine.nu Thu Mar 14 17:11:06 2002 From: clee@spiralis.merseine.nu (clee@spiralis.merseine.nu) Date: Thu, 14 Mar 2002 11:11:06 -0600 (CST) Subject: [Image-SIG] PIL rc2 build buglet Message-ID: <20020314171106.832687BB@spiralis.merseine.nu> Just tried building the new release on linux. One saw one problem during the "python setup.py build" stage. The setup script appears to expect a "Imaging-1.1.3c2/tk" ("tk" in all lowercase) directory to exist, but the distribution unpacks to an uppercase "Tk" directory. The build went smoothly once I created a symbolic link "ln -s ./Tk ./tk" Many thanks to \F for the new release. -chris From fredrik@pythonware.com Fri Mar 15 13:57:24 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 15 Mar 2002 14:57:24 +0100 Subject: [Image-SIG] ANN: Python Imaging Library 1.1.3 (march 15, 2002) Message-ID: <036101c1cc29$8f632750$0900a8c0@spiff> the secret labs proudly presents PIL 1.1.3: The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities. Version 1.1.3 adds distutils build scripts, improved resampling, screen grabbing support (windows only), and more (see below). Get your copy of the source kit here: http://www.pythonware.com/products/pil/ enjoy, the pil team "Secret Labs -- makers of fine pythonware since 1997." -- changes in this version (relative to 1.1.2) -- + Made setup.py look for old versions of zlib. For some back- ground, see: http://www.gzip.org/zlib/advisory-2002-03-11.txt + Added setup.py file (tested on Unix and Windows). You still need to build libImaging/imaging.lib in the traditional way, but the setup.py script takes care of the rest. The old Setup.in/Makefile.pre.in build method is still supported. + Fixed segmentation violation in ANTIALIAS filter (an internal buffer wasn't properly allocated). + Added ANTIALIAS downsampling filter for high-quality "resize" and "thumbnail" operations. Also added filter option to the "thumbnail" operation; the default value is NEAREST, but this will most likely change in future versions. + Fixed plugin loader to be more robust if the __file__ variable isn't set. + Added seek/tell support (for layers) to the PhotoShop loader. Layer 0 is the main image. + Added new (but experimental) "ImageOps" module, which provides shortcuts for commonly used operations on entire images. + Don't mess up when loading PNG images if the decoder leaves data in the output buffer. This could cause internal errors on some PNG images, with some versions of ZLIB. (Bug report and patch provided by Bernhard Herzog.) + Don't mess up on Unicode filenames. + Don't mess up when drawing on big endian platforms. + Made the TIFF loader a bit more robust; it can now read some more slightly broken TIFF files (based on input from Ted Wright, Bob Klimek, and D. Alan Stewart) + Added OS/2 EMX build files (from Andrew MacIntyre) + Change "ImageFont" to reject image files if they don't have the right mode. Older versions could leak memory for "P" images. (Bug reported by Markus Gritsch). =20 + Renamed some internal functions to avoid potential build problem on Mac OS X. + Added DL_EXPORT where relevant (for Cygwin, based on input from Robert Yodlowski) + (re)moved bogus __init__ call in BdfFontFile (bug spotted by Fred Clare) + Added "ImageGrab" support (Windows only) + Added support for XBM hotspots (based on code contributed by Bernhard Herzog). + Added support for Palm pixmaps (from Bill Janssen) + Added write support for more TIFF tags, namely the Artist, Copyright, DateTime, ResolutionUnit, Software, XResolution and YResolution tags (from Greg Couch) + Added TransposedFont wrapper to ImageFont module + Added "optimize" flag to GIF encoder. If optimize is present and non-zero, PIL will work harder to create a small file. + Raise "EOFError" (not IndexError) when reading beyond the end of a TIFF sequence. + Support rewind ("seek(0)") for GIF and TIFF sequences. + Load grayscale GIF images as mode "L" + Added DPI read/write support to the JPEG codec. The decoder sets the info["dpi"] attribute for JPEG files with JFIF dpi settings. The encoder uses the "dpi" option: im =3D Image.open("file.jpg") dpi =3D im.info["dpi"] # raises KeyError if DPI not known im.save("out.jpg", dpi=3Ddpi) Note that PIL doesn't always preserve the "info" attribute for normal image operations. -- end -- From fredrik@pythonware.com Fri Mar 15 18:58:02 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 15 Mar 2002 19:58:02 +0100 Subject: [Image-SIG] ANN: Python Imaging Library 1.1.3 (march 15, 2002) References: <036101c1cc29$8f632750$0900a8c0@spiff> Message-ID: <003d01c1cc53$56e7aca0$ced241d5@hagrid> > Get your copy of the source kit here: > > http://www.pythonware.com/products/pil/ for your convenience, I've posted an "inofficial" Windows build for Python 2.1 to effbot.org: http://effbot.org/downloads enjoy /F From webmaster@outsonic.com Sun Mar 17 04:39:46 2002 From: webmaster@outsonic.com (SiteChatter.com) Date: Sat, 16 Mar 2002 20:39:46 -0800 Subject: [Image-SIG] Add Live Support to your Website Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_1075_01C1CD2A.B583F890 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Live customer support is better then email anyday! Do you own a website? Have you ever thought, "If I only could allow my visitors to chat live with me while they browse my site?" Now you can! With SiteChat Pro you can do that and more! SiteChat Pro is a service offered by SiteChatter.com. It can be setup in minutes and customized with your logo and colors. It doesn't take a webmaster guru to setup and nothing needs to be installed as it runs on SiteChatter.com's server farm. Other services that compare to SiteChat Pro cost $100+ per support rep per month. SiteChat Pro pricing starts at $10 per month with unlimited support reps!!! Try our no-obligation FREE TRIAL today! SiteChatter.com support@sitechatter.com Click for Live Support! Note:The "Live Help" button above could be yours in as little as 5 minutes. It can be placed on your website or in HTML rich emails such as this one. To unsubscribe, reply to this email with "unsubscribe" in the subject. ------=_NextPart_000_1075_01C1CD2A.B583F890 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =0A= Add Live Customer Service to your site!

Live = customer support is better then email anyday!=0A=
Do you own a website? Have you ever thought, "If I only could allow = my visitors to chat live with me while they browse my site?" Now you = can!

With = SiteChat Pro you can do that and more! SiteChat Pro is a service offered = by SiteChatter.com. It can be setup in minutes and customized with your = logo and colors. It doesn't take a webmaster guru to setup and nothing = needs to be installed as it runs on SiteChatter.com's server = farm.

Other = services that compare to SiteChat Pro cost $100+ per support rep per = month. SiteChat Pro pricing starts at $10 per month with unlimited = support reps!!!

Try our no-obligation FREE TRIAL today!

SiteChatter.com=0A=
support@sitechatter.com

3D"Click
Note:The "Live Help" button above could be yours in as = little as 5 minutes. It can be placed on your website or in HTML rich = emails such as this one.

To unsubscribe, reply to this email with "unsubscribe" in the = subject.

=0A= ------=_NextPart_000_1075_01C1CD2A.B583F890-- From kevin@cazabon.com Sun Mar 17 23:18:12 2002 From: kevin@cazabon.com (Kevin@Cazabon.com) Date: Sun, 17 Mar 2002 16:18:12 -0700 Subject: [Image-SIG] Unsharp Masking? Message-ID: <001301c1ce0a$025e3dd0$2f0aa8c0@duallie> This is a multi-part message in MIME format. ------=_NextPart_000_000F_01C1CDCF.55D6CF30 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0010_01C1CDCF.55D6CF30" ------=_NextPart_001_0010_01C1CDCF.55D6CF30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Does anyone have a FAST unsharp-masking method for use with PIL? I wrote a brute-force module for this in Python today (attached, if it = gets through the newsgroup filters) that works just fine, but it's = mighty slow... anyone have something faster? The built in = ImageEnhance.Sharpness filter is OK for very basic stuff, but the best = way to sharpen is through an unsharp-mask type algorithm... it's much = more powerful and controllable. For those that don't know how unsharp masking works, here's the basics: 1) a copy of the image is blurred using a gaussian-type blurring = algorighm (this is the 'unsharp' part), with a user-defined radius for = the blur. 2) the blurred image is then compared (pixel by pixel if necessary) to = the original image 3) the amount of difference between the blurred pixel and original = pixel determines if it is an edge or not. If the difference is greater = than the user-specified "threshold", sharpening is performed in step 4) 4) the pixel is changed by the OPPOSITE amount of the difference = between the original and blurred pixels, multiplied by the user-defined = "percentage" Any help is appreciated in speeding this up! Kevin Cazabon. ------=_NextPart_001_0010_01C1CDCF.55D6CF30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Does anyone have a FAST unsharp-masking = method for=20 use with PIL?
 
I wrote a brute-force module for this = in Python=20 today (attached, if it gets through the newsgroup = filters) that works=20 just fine, but it's mighty slow... anyone have something faster?  = The built=20 in ImageEnhance.Sharpness filter is OK for very basic stuff, but the = best way to=20 sharpen is through an unsharp-mask type algorithm... it's much more = powerful=20 and controllable.
 
For those that don't know how unsharp = masking=20 works, here's the basics:
 
1)  a copy of the image is blurred = using a=20 gaussian-type blurring algorighm (this is the 'unsharp' part), with a=20 user-defined radius for the blur.
 
2)  the blurred image is then = compared (pixel=20 by pixel if necessary) to the original image
 
3)  the amount of difference = between the=20 blurred pixel and original pixel determines if it is an edge or = not.  If=20 the difference is greater than the user-specified "threshold", = sharpening is=20 performed in step 4)
 
4)  the pixel is changed by the = OPPOSITE=20 amount of the difference between the original and blurred pixels, = multiplied by=20 the user-defined "percentage"
 
 
 
Any help is appreciated in speeding = this=20 up!
 
Kevin = Cazabon.
------=_NextPart_001_0010_01C1CDCF.55D6CF30-- ------=_NextPart_000_000F_01C1CDCF.55D6CF30 Content-Type: text/plain; name="UnsharpMaskingModule.py" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="UnsharpMaskingModule.py" # EditStation -- Unsharp Masking # by Kevin Cazabon ( kevin@cazabon.com ) # Copyright 2002, all rights reserved ###################################################################### # Constants ###################################################################### ###################################################################### # Imports ###################################################################### import Image import array ###################################################################### # Functions ###################################################################### def unsharpMask (image, radius, weight, threshold): # perform a gaussian blur on the image, using radius as a PERCENTAGE = of the image size. # this will allow realistic previewing on smaller versions of the = same image. # radius is the size of matrix to use for blurring # weight is the percentage of how much of each out-lying pixel is = taken into account, # each, 'ring' is decreased by the same percentage. # # example: radius 5, weight 90 would result in a matrix like the = following: # # 66 73 81 73 66=20 # 73 81 90 81 73=20 # 81 90 100 90 81=20 # 73 81 90 81 73=20 # 66 73 81 73 66 # # then, use the difference between the orignal pixel and the new = value to determine how much to increase # the edge contrast. radius =3D float(image.size[0] * image.size[1] * radius) / 300000.0 weight =3D float(weight)/100.0 imArray =3D array.array('B', image.tostring()) if image.mode =3D=3D "RGB": channels =3D 3 elif image.mode =3D=3D "CMYK": channels =3D 4 elif image.mode =3D=3D "L": channels =3D 1 else: # cant process other mode images return image newImage =3D Image.new(image.mode, image.size) for column in range(image.size[0]): for row in range(image.size[1]): newPixel =3D [] for c in range (channels): totalValue =3D 0 origPixel =3D imArray[(column + (row * image.size[0])) * = channels + c] for xr in range(-int(radius/2), int(radius/2), 1): for yr in range(-int(radius/2), int(radius/2), 1): pixNumber =3D ((column + (row * image.size[0])) = * channels) + c + (xr * channels) + (yr * image.size[0] * channels) =20 if pixNumber < 0: pixNumber =3D column * channels elif pixNumber > len(imArray) - 1: pixNumber =3D (column + (row * = image.size[0])) * channels =20 pixValue =3D imArray[pixNumber] =20 pixWeight =3D pow(weight, (abs(xr) + abs(yr))) totalValue =3D totalValue + ((origPixel - = pixValue) * pixWeight) newValue =3D int(totalValue / (radius*radius) + 0.5) =20 if abs(origPixel - newValue) <=3D threshold: newValue =3D origPixel =20 newValue =3D origPixel + newValue newPixel.append(newValue) =20 newImage.putpixel((column, row), tuple(newPixel)) =20 return newImage ###################################################################### # Self Test ###################################################################### if __name__ =3D=3D "__main__": im =3D Image.open("c:\\temp\\testsmall.tif") im.show() radius =3D 5 weight =3D 100 threshold =3D 3.0 =20 im =3D unsharpMask(im, radius, weight, threshold) im.show() ------=_NextPart_000_000F_01C1CDCF.55D6CF30-- From kevin@cazabon.com Mon Mar 18 04:24:45 2002 From: kevin@cazabon.com (Kevin@Cazabon.com) Date: Sun, 17 Mar 2002 21:24:45 -0700 Subject: [Image-SIG] Unsharp Masking? References: Message-ID: <006501c1ce34$d7633970$2f0aa8c0@duallie> This is a multi-part message in MIME format. ------=_NextPart_000_0062_01C1CDFA.2929D510 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've cleaned it up a bit, and added documentation so you people other = than me understand what's going on in the code a little more. I've tried to move all the calculations upstream as much as possible, = but it's still only about 7% faster than the original... there's a LONG = way to go. On a dual 1.2ghz box, it's taking 30 seconds to sharpen a = 400x600 pixel image! Iterating over each channel of each pixel in Python is just too slow... = would trying to implement this type of thing in a C extension (like the = core _imaging.pyd file) help a lot? Unfortunately, I'm not much of a C = programmer. FRED!!! HELP!!! q:] I could do the calculations on a gray-scale version of the file and only = sharpen based on gray-contrast, but I'd rather not limit it that way... = (max 3x speed improvement, minus time to create grayscale version of = image) The updated version, if anyone can give me a hand is available at: = http://www.cazabon.com/python/unsharpMask/UnsharpMaskingModule.py (and it now can be used for gaussian blurring too, as an added bonus). Thanks, Kevin. ----- Original Message -----=20 From: Moodie, Craig CA=20 To: 'Kevin@Cazabon.com'=20 Sent: Sunday, March 17, 2002 7:05 PM Subject: RE: [Image-SIG] Unsharp Masking? Kevin, On first inspection I would suggest that you remove as much as is = physically possible from the inner loop. Put as much as you can into a = lookup table-----avoid calculations.You should be able to at least get a = speed increase of 2. For example pixNumber =3D ((column + (row * = image.size[0])) * channels) + c + (xr * channels) + (yr * image.size[0] = * channels) =20 if pixNumber < 0: pixNumber =3D column * channels elif pixNumber > len(imArray) - 1: pixNumber =3D (column + (row * = image.size[0])) * channels =20 pixValue =3D imArray[pixNumber] =20 pixWeight =3D pow(weight, (abs(xr) + = abs(yr)))----------------------->LUT totalValue =3D totalValue + ((origPixel - = pixValue) * pixWeight) the underlined could all be calculated outside the xr,yr loops. Cheers Craig -----Original Message----- From: Kevin@Cazabon.com [mailto:kevin@cazabon.com] Sent: Monday, March 18, 2002 10:18 AM To: image-sig@python.org Subject: [Image-SIG] Unsharp Masking? Does anyone have a FAST unsharp-masking method for use with PIL? I wrote a brute-force module for this in Python today (attached, if = it gets through the newsgroup filters) that works just fine, but it's = mighty slow... anyone have something faster? The built in = ImageEnhance.Sharpness filter is OK for very basic stuff, but the best = way to sharpen is through an unsharp-mask type algorithm... it's much = more powerful and controllable. For those that don't know how unsharp masking works, here's the = basics: 1) a copy of the image is blurred using a gaussian-type blurring = algorighm (this is the 'unsharp' part), with a user-defined radius for = the blur. 2) the blurred image is then compared (pixel by pixel if necessary) = to the original image 3) the amount of difference between the blurred pixel and original = pixel determines if it is an edge or not. If the difference is greater = than the user-specified "threshold", sharpening is performed in step 4) 4) the pixel is changed by the OPPOSITE amount of the difference = between the original and blurred pixels, multiplied by the user-defined = "percentage" Any help is appreciated in speeding this up! Kevin Cazabon. EOM=20 NOTICE - This message and any attached files may contain information = that is confidential and/or subject of legal privilege intended only for = use by the intended recipient. If you are not the intended recipient or = the person responsible for delivering the message to the intended = recipient, be advised that you have received this message in error and = that any dissemination, copying or use of this message or attachment is = strictly forbidden, as is the disclosure of the information therein. If = you have received this message in error please notify the sender = immediately and delete the message. ------=_NextPart_000_0062_01C1CDFA.2929D510 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I've cleaned it up a bit, and added = documentation=20 so you people other than me understand what's going on in the = code a=20 little more.
 
I've tried to move all the calculations = upstream as=20 much as possible, but it's still only about 7% faster than the = original...=20 there's a LONG way to go.  On a dual 1.2ghz box, it's taking 30 = seconds to=20 sharpen a 400x600 pixel image!
 
Iterating over each channel of each = pixel in Python=20 is just too slow... would trying to implement this type of thing in a C=20 extension (like the core _imaging.pyd file) help a lot?  = Unfortunately, I'm=20 not much of a C programmer.  FRED!!! HELP!!!  q:]
 
I could do the calculations on a = gray-scale version=20 of the file and only sharpen based on gray-contrast, but I'd rather not = limit it=20 that way... (max 3x speed improvement, minus time to create grayscale = version of=20 image)
 
The updated version, if anyone can = give me a=20 hand is available at:  http://www.cazabon.com/python/unsharpMask/UnsharpMaskingModule.py
 
(and it now can be used for gaussian = blurring too,=20 as an added bonus).
 
Thanks,
Kevin.
----- Original Message -----
From:=20 Moodie, Craig CA
Sent: Sunday, March 17, 2002 = 7:05=20 PM
Subject: RE: [Image-SIG] = Unsharp=20 Masking?

Kevin,
    On first inspection I would suggest that you = remove as=20 much as is physically possible from the inner loop. Put as much as you = can=20 into a lookup table-----avoid calculations.You should be able to at = least get=20 a speed increase of 2.
For=20 example
          &nbs= p;            = ;=20 pixNumber =3D ((column + (row * image.size[0])) * channels) + = c=20 + (xr * channels) + (yr * image.size[0] *=20 = channels)
          =             &= nbsp;=20 =
           &nb= sp;           =20 if pixNumber <=20 = 0:
           &= nbsp;           &n= bsp;   =20 pixNumber =3D column *=20 = channels
        &nbs= p;            = ;  =20 elif pixNumber > len(imArray) -=20 = 1:
         &nbs= p;            = ;     =20 pixNumber =3D (column + (row * image.size[0])) *=20 = channels
        &nbs= p;            = ;      =20 =
           &nb= sp;           =20 pixValue =3D=20 = imArray[pixNumber]
        &nb= sp;           &nbs= p;  =20 =
           &nb= sp;           =20 pixWeight =3D pow(weight, (abs(xr) +=20 = abs(yr)))----------------------->LUT
   &nb= sp;           &nbs= p;       =20 totalValue =3D totalValue + ((origPixel - pixValue) * = pixWeight)
the=20 underlined could all be calculated outside the xr,yr=20 loops.
    Cheers
       =20 Craig
-----Original Message-----
From: = Kevin@Cazabon.com=20 [mailto:kevin@cazabon.com]
Sent: Monday, March 18, 2002 = 10:18=20 AM
To: image-sig@python.org
Subject: [Image-SIG] = Unsharp=20 Masking?

Does anyone have a FAST = unsharp-masking method=20 for use with PIL?
 
I wrote a brute-force module for = this in Python=20 today (attached, if it gets through the newsgroup = filters) that=20 works just fine, but it's mighty slow... anyone have something = faster? =20 The built in ImageEnhance.Sharpness filter is OK for very basic = stuff, but=20 the best way to sharpen is through an unsharp-mask type algorithm... = it's=20 much more powerful and controllable.
 
For those that don't know how = unsharp masking=20 works, here's the basics:
 
1)  a copy of the image is = blurred using a=20 gaussian-type blurring algorighm (this is the 'unsharp' part), with = a=20 user-defined radius for the blur.
 
2)  the blurred image is then = compared=20 (pixel by pixel if necessary) to the original image
 
3)  the amount of difference = between the=20 blurred pixel and original pixel determines if it is an edge or = not. =20 If the difference is greater than the user-specified "threshold", = sharpening=20 is performed in step 4)
 
4)  the pixel is changed by = the OPPOSITE=20 amount of the difference between the original and blurred pixels, = multiplied=20 by the user-defined "percentage"
 
 
 
Any help is appreciated in speeding = this=20 up!
 
Kevin = Cazabon.

EOM


NOTICE - This message and any attached = files may=20 contain information that is confidential and/or subject of legal = privilege=20 intended only for use by the intended recipient. If you are not the = intended=20 recipient or the person responsible for delivering the message to the = intended=20 recipient, be advised that you have received this message in error and = that=20 any dissemination, copying or use of this message or attachment is = strictly=20 forbidden, as is the disclosure of the information therein. If you = have=20 received this message in error please notify the sender immediately = and delete=20 the message.

------=_NextPart_000_0062_01C1CDFA.2929D510-- From schutte@fel.tno.nl Mon Mar 18 16:15:34 2002 From: schutte@fel.tno.nl (K Schutte) Date: Mon, 18 Mar 2002 17:15:34 +0100 Subject: [Image-SIG] Unsharp Masking? References: <006501c1ce34$d7633970$2f0aa8c0@duallie> Message-ID: <3C9612A6.493E6339@fel.tno.nl> Three suggestions here: 1. The C code is implemented for convolutions in Imaging-1.1.2/libImaging/Filter.c Here you can specify filter coefficients yourself. 2. Gaussian smoothing can be implemented as a separable filter. This means that instead of convoluting with a 5x5 kernel you can convolve first with a 5x1 kernel, followed by a convolutiuon with a 1x5 filter. This means that you have to perform not 25 but only 10 operations per pixel. 3. A nice thing about Gaussian distributions is that they follow the Central Limit Theorem. Which tells you that enough times applying about any (bla bla bla on fairly standard assumptions) convolution to an image will result in a more-or-less Gaussian blurring. Starting with something like a Gaussian blurring (with a smaller sigma) will help. So will the filter ImageFilter.SMOOTH might be a nice choice. Experimenting helps you to decide how much times you should apply this filter to reach a sigma (radius in your code) preferred to your application. It is my guess this is a limited amount and gives you much faster execution. Klamer > "Kevin@Cazabon.com" wrote: > > I've cleaned it up a bit, and added documentation so you people other than > me understand what's going on in the code a little more. > > I've tried to move all the calculations upstream as much as possible, but it's > still only about 7% faster than the original... there's a LONG way to go. On > a dual 1.2ghz box, it's taking 30 seconds to sharpen a 400x600 pixel image! > > Iterating over each channel of each pixel in Python is just too slow... would > trying to implement this type of thing in a C extension (like the core > _imaging.pyd file) help a lot? Unfortunately, I'm not much of a C > programmer. FRED!!! HELP!!! q:] > > I could do the calculations on a gray-scale version of the file and only > sharpen based on gray-contrast, but I'd rather not limit it that way... (max > 3x speed improvement, minus time to create grayscale version of image) > > The updated version, if anyone can give me a hand is available at: > http://www.cazabon.com/python/unsharpMask/UnsharpMaskingModule.py > > (and it now can be used for gaussian blurring too, as an added bonus). > > Thanks, > Kevin. > > ----- Original Message ----- > From: Moodie, Craig CA > To: 'Kevin@Cazabon.com' > Sent: Sunday, March 17, 2002 7:05 PM > Subject: RE: [Image-SIG] Unsharp Masking? > > Kevin, > On first inspection I would suggest that you remove as much as > is physically possible from the inner loop. Put as much as you can > into a lookup table-----avoid calculations.You should be able to at > least get a speed increase of 2. > For example > pixNumber = ((column + (row * > image.size[0])) * channels) + c + (xr * channels) + (yr * > image.size[0] * channels) > > if pixNumber < 0: > pixNumber = column * channels > elif pixNumber > len(imArray) - 1: > pixNumber = (column + (row * > image.size[0])) * channels > > pixValue = imArray[pixNumber] > > pixWeight = pow(weight, (abs(xr) + > abs(yr)))----------------------->LUT > totalValue = totalValue + ((origPixel - > pixValue) * pixWeight) > the underlined could all be calculated outside the xr,yr loops. > Cheers > Craig > > -----Original Message----- > From: Kevin@Cazabon.com [mailto:kevin@cazabon.com] > Sent: Monday, March 18, 2002 10:18 AM > To: image-sig@python.org > Subject: [Image-SIG] Unsharp Masking? > > Does anyone have a FAST unsharp-masking method for use > with PIL? > > I wrote a brute-force module for this in Python > today (attached, if it gets through the newsgroup > filters) that works just fine, but it's mighty slow... > anyone have something faster? The built in > ImageEnhance.Sharpness filter is OK for very basic stuff, > but the best way to sharpen is through an unsharp-mask > type algorithm... it's much more powerful > and controllable. > > For those that don't know how unsharp masking works, > here's the basics: > > 1) a copy of the image is blurred using a gaussian-type > blurring algorighm (this is the 'unsharp' part), with a > user-defined radius for the blur. > > 2) the blurred image is then compared (pixel by pixel if > necessary) to the original image > > 3) the amount of difference between the blurred pixel and > original pixel determines if it is an edge or not. If the > difference is greater than the user-specified "threshold", > sharpening is performed in step 4) > > 4) the pixel is changed by the OPPOSITE amount of the > difference between the original and blurred pixels, > multiplied by the user-defined "percentage" > > > > Any help is appreciated in speeding this up! > > Kevin Cazabon. > > EOM > > NOTICE - This message and any attached files may contain information > that is confidential and/or subject of legal privilege intended only > for use by the intended recipient. If you are not the intended > recipient or the person responsible for delivering the message to > the intended recipient, be advised that you have received this > message in error and that any dissemination, copying or use of this > message or attachment is strictly forbidden, as is the disclosure of > the information therein. If you have received this message in error > please notify the sender immediately and delete the message. -- Klamer Schutte, E-mail: Schutte@fel.tno.nl Electro-Optical Systems, TNO Physics and Electronics Laboratory Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671 From clee@spiralis.merseine.nu Mon Mar 18 16:26:25 2002 From: clee@spiralis.merseine.nu (clee@spiralis.merseine.nu) Date: Mon, 18 Mar 2002 10:26:25 -0600 Subject: [Image-SIG] Unsharp Masking? In-Reply-To: <006501c1ce34$d7633970$2f0aa8c0@duallie> References: <006501c1ce34$d7633970$2f0aa8c0@duallie> Message-ID: <15510.5425.423798.816839@spiralis.merseine.nu> >>>>> "kevin" == kevin writes: kevin> I've cleaned it up a bit, and added documentation so you kevin> people other than me understand what's going on in the code kevin> a little more. I've tried to move all the calculations kevin> upstream as much as possible, but it's still only about 7% kevin> faster than the original... there's a LONG way to go. On a kevin> dual 1.2ghz box, it's taking 30 seconds to sharpen a kevin> 400x600 pixel image! I haven't looked very closely at your code, but it sounds like you're doing something close to what something I'm familiar with from imaging processsing. I've used the Numeric/scipy utils to do this sort of thing before for fast convolutions. (The new bbl_image package might also provide the tools you need.) Here's an example assuming grayscale images. RGB is trickier (it's often better to use an HSV representation of color for this sort of work.) Assuming you have your image as a Numeric floating point array, called "I", I believe this code will do approximately what you want: ---------------------------------------------------------------------------- I = import Numeric as num import scipy.signal as signal # create a filter kernel called K (taken from your comment) K = array([[ 66, 73, 81, 73, 66 ] [ 73, 81, 90, 81, 73 ] [ 81, 90, 100, 90, 81 ] [ 73, 81, 90, 81, 73 ] [ 66, 73, 81, 73, 66]] # you probably want to normalize it in some way K = K/num.sum(num.sum(K)) G1 = signal.convolve2d(I, K, mode='same') # G stands for gausian blur L1 = I - cnv_image # L stands for Laplacian (2D difference) # note original image I = G1 + L1 # now you would like to do a thresholding operation of some sort # I'm not sure exactly what you want but something like this this # seesm to get the gist of what you want to do # say theshold for change is 5.0, rich comparion operator ">" requires # python version >= 2.1 (otherwise use older comparison function) threshold = 5.0 changemask = L1 > threshold # compute how much to change the original image multiplier = 2.0 # 2.0 <- percentage = 200 increase or whatever L1change = L1 * multiplier # set the values above threshold to the new L1change value putmask(L1, changemask, L1change) # now reconstruct sharpI = G1 + L1 # enhanced image -------------------------------------------------------------------------- Hope this helps, -chris From oliver.skiebe@gmx.net Thu Mar 21 16:10:18 2002 From: oliver.skiebe@gmx.net (Oliver Skiebe) Date: Thu, 21 Mar 2002 17:10:18 +0100 Subject: [Image-SIG] Compilation prob on solaris 8 Message-ID: Hi there, we just faced a problem trying to compile PIL 1.1.3 on a solaris box w/sunos 5.8 -> gcc version 2.95.3 -> python 2.1.2 Configure said: # CC=3D"cc -ansi" ./configure creating cache ./config.cache checking for --without-gcc... no checking for gcc... cc -ansi checking whether the C compiler (cc -ansi ) works... yes checking whether the C compiler (cc -ansi ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether cc -ansi accepts -g... yes checking for ranlib... : checking for ar... ar checking MACHDEP... sunos5 checking for jpeg_destroy_compress in -ljpeg... yes checking for deflate in -lz... yes checking how to run the C preprocessor... cc -ansi -E checking for ANSI C header files... no checking for inline... __inline__ checking whether byte ordering is bigendian... yes checking size of char... 0 checking size of short... 0 checking size of int... 0 checking size of long... 0 checking size of float... 0 checking size of double... 0 checking for working const... yes checking for prototypes... yes checking for unistd.h... yes checking for getpagesize... yes checking for working mmap... no updating cache ./config.cache creating ./config.status creating Makefile creating ImConfig.h make returned: #make cc -ansi -O -I./. -I/usr/local/include -DHAVE_CONFIG_H -c -o coretest.o coretest.c In file included from Imaging.h:21, from coretest.c:19: ImPlatform.h:18: #error Sorry, this library requires ANSI header files. ImPlatform.h:36: #error Cannot find required 32-bit integer type ImPlatform.h:48: #error Cannot find required 32-bit floating point type make: *** [coretest.o] Error 1 sorry, i=B4m quite new to this stuff - thank you a lot for any suggestions! -oliver From fredrik@pythonware.com Thu Mar 21 21:01:20 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 21 Mar 2002 22:01:20 +0100 Subject: [Image-SIG] Compilation prob on solaris 8 References: Message-ID: <005e01c1d11b$b92cfce0$ced241d5@hagrid> oliver wrote: > we just faced a problem trying to compile PIL 1.1.3 on a > solaris box for some reason, configure doesn't like your compiler: > checking for ANSI C header files... no check the config.log file for further clues. trying without the -ansi option might also help (-ansi forces gcc to use a "strict ansi" mode which might be too strict...) From rtrocca@libero.it Fri Mar 22 08:56:43 2002 From: rtrocca@libero.it (=?iso-8859-1?Q?rtrocca@libero.it?=) Date: Fri, 22 Mar 2002 09:56:43 +0100 Subject: [Image-SIG] =?iso-8859-1?Q?Compilation_problems_on_cygwin?= Message-ID: SSdtIHRyeWluZyB0byBjb21waWxlIFBJTCAxLjEuMyBvbiBjeWd3aW4gd2l0aCB0aGUgVEsg c3VwcG9ydC4NClRoZSBmaXJzdCBwcm9ibGVtIGlzIHRoYXQgb24gY3lnd2luIHRoZSBYMTEg aW5jbHVkZXMgYXJlIGluDQovdXNyL1gxMVI2L2luY2x1ZGUgYW5kIHRoZSBzZXR1cCBzY3Jp cHQgY2Fubm90IGZpbmQgdGhlbS4NCkkgZG9uJ3Qga25vdyBpZiBpdCBpcyBiZXR0ZXIgdG8g Y29uZmlndXJlIHRoZSBzeXN0ZW0gcGF0aCBvciBmaXgNCnNldHVwLnB5LiBJJ20gbm90IGEg Y3lnd2luIG9yIHVuaXggZXhwZXJ0Lg0KYW5vdGhlciBwcm9ibGVtIGlzIHRoYXQgc2V0dXAu cHkgY29tcGxhaW5zIHRoYXQgbGQgaXMgbm90IGZpbmRpbmcgdGs4MA0KdG8gIGxpbmsgdG8u DQppbiAiL2xpYi8iIHRoZXJlIGlzIGEgbGlidGs4MC5hLCBob3cgY2FuIEkgY29udmluY2Ug c2V0dXAgdG8gdXNlIHRoYXQ/DQpJIHRyaWVkIGNoYW5naW5nIHRoZSBuYW1lIGluIHNldHVw LnB5IHRvIGxpYnRrLCBhZGRpbmcgL2xpYi8uLiAuYnV0IGxkDQpzdGlsbCBjb21wbGFpbnMu IEFueSBoZWxwPw0KSSB0aGluayB0aGF0IHRoZSBzYW1lIHByb2JsZW0gd2lsbCBhcHBlYXIg d2l0aCBsaWJ0Y2wuLi4NCg0KVGhhbmtzLA0KICAgIFJpY2NhcmRvDQoNCkkgdHJpZWQgdG8g YWRkIHRoZSBwYXRoIGV4cGxpY2l0bHkgaW4gdGhlIHNldHVwIHByb2dyYW0sIGJ1dCBpdCBk aWRuJ3QNCndvcmsuIEknbSBub3QgYSBjeWd3aW4gZXhwZXJ0LCBidXQg From oliver.skiebe@gmx.net Fri Mar 22 15:29:29 2002 From: oliver.skiebe@gmx.net (Oliver Skiebe) Date: Fri, 22 Mar 2002 16:29:29 +0100 Subject: [Image-SIG] Still Compilation prob on solaris 8 In-Reply-To: Message-ID: Hi, thanks for replying - compiling without -ansi doesn=B4t work either Here=B4s what config.log says after a straight ./configure - Same output, same error doing make... I don=B4t have a confdefs.h file on this machine - why can=B4t it find those header files resp. where to get them? I installed gcc as a sun package... any clues what i might do? Thank you a lot, oliver=20 configure:558: checking for --without-gcc configure:588: checking for gcc configure:665: checking whether the C compiler (gcc ) works configure:679: gcc -o conftest conftest.c 1>&5 configure:699: checking whether the C compiler (gcc ) is a cross-compiler configure:704: checking whether we are using GNU C configure:713: gcc -E conftest.c configure:728: checking whether gcc accepts -g configure:758: checking for ranlib configure:790: checking for ar configure:829: checking MACHDEP configure:857: checking for jpeg_destroy_compress in -ljpeg configure:876: gcc -o conftest -g -O2 conftest.c -ljpeg 1>&5 configure:920: checking for deflate in -lz configure:939: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure:969: checking how to run the C preprocessor configure:990: gcc -E conftest.c >/dev/null 2>conftest.out configure:1030: checking for ANSI C header files configure:1043: gcc -E conftest.c >/dev/null 2>conftest.out configure:1110: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1099 "configure" #include "confdefs.h" #include #define ISLOWER(c) ('a' <=3D (c) && (c) <=3D 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i =3D 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) !=3D TOUPPER (i)) exit(2); exit (0); } configure:1136: checking for inline configure:1150: gcc -c -g -O2 conftest.c 1>&5 configure:1177: checking whether byte ordering is bigendian configure:1195: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:1190: `bogus' undeclared (first use in this function) configure:1190: (Each undeclared identifier is reported only once configure:1190: for each function it appears in.) configure:1190: parse error before `endian' configure: failed program was: #line 1184 "configure" #include "confdefs.h" #include #include int main() { #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif ; return 0; } configure:1243: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1230 "configure" #include "confdefs.h" main () { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l =3D 1; exit (u.c[sizeof (long) - 1] =3D=3D 1); } configure:1268: checking size of char configure:1287: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1276 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(char)); exit(0); } configure:1307: checking size of short configure:1326: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1315 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(short)); exit(0); } configure:1346: checking size of int configure:1365: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1354 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(int)); exit(0); } configure:1385: checking size of long configure:1404: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1393 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(long)); exit(0); } configure:1425: checking size of float configure:1444: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1433 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(float)); exit(0); } configure:1464: checking size of double configure:1483: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1472 "configure" #include "confdefs.h" #include main() { FILE *f=3Dfopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(double)); exit(0); } configure:1504: checking for working const configure:1558: gcc -c -g -O2 conftest.c 1>&5 configure:1581: checking for prototypes configure:1590: gcc -c -g -O2 conftest.c 1>&5 configure:1608: checking for unistd.h configure:1618: gcc -E conftest.c >/dev/null 2>conftest.out configure:1647: checking for getpagesize configure:1675: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure:1700: checking for working mmap configure:1848: gcc -o conftest -g -O2 conftest.c -lz -ljpeg 1>&5 configure: failed program was: #line 1708 "configure" #include "confdefs.h" /* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: mmap private not fixed mmap private fixed at somewhere currently unmapped mmap private fixed at somewhere already mapped mmap shared not fixed mmap shared fixed at somewhere currently unmapped mmap shared fixed at somewhere already mapped For private mappings, we should verify that changes cannot be read() back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the VM page cache was not coherent with the filesystem buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get propogated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */ #include #include #include /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE # ifdef HAVE_UNISTD_H # include # endif /* Assume that all systems that can run configure have sys/param.h. */ # ifndef HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 # endif # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE # else /* no EXEC_PAGESIZE */ # ifdef NBPG # define getpagesize() NBPG * CLSIZE # ifndef CLSIZE # define CLSIZE 1 # endif /* no CLSIZE */ # else /* no NBPG */ # ifdef NBPC # define getpagesize() NBPC # else /* no NBPC */ # ifdef PAGESIZE # define getpagesize() PAGESIZE # endif /* PAGESIZE */ # endif /* no NBPC */ # endif /* no NBPG */ # endif /* no EXEC_PAGESIZE */ # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ # endif /* no _SC_PAGESIZE */ #endif /* no HAVE_GETPAGESIZE */ #ifdef __cplusplus extern "C" { void *malloc(unsigned); } #else char *malloc(); #endif int main() { char *data, *data2, *data3; int i, pagesize; int fd; pagesize =3D getpagesize(); /* * First, make a file with some known garbage in it. */ data =3D malloc(pagesize); if (!data) exit(1); for (i =3D 0; i < pagesize; ++i) *(data + i) =3D rand(); umask(0); fd =3D creat("conftestmmap", 0600); if (fd < 0) exit(1); if (write(fd, data, pagesize) !=3D pagesize) exit(1); close(fd); /* * Next, try to mmap the file at a fixed address which * already has something else allocated at it. If we can, * also make sure that we see the same garbage. */ fd =3D open("conftestmmap", O_RDWR); if (fd < 0) exit(1); data2 =3D malloc(2 * pagesize); if (!data2) exit(1); data2 +=3D (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 !=3D mmap(data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) exit(1); for (i =3D 0; i < pagesize; ++i) if (*(data + i) !=3D *(data2 + i)) exit(1); /* * Finally, make sure that changes to the mapped area * do not percolate back to the file as seen by read(). * (This is a bug on some variants of i386 svr4.0.) */ for (i =3D 0; i < pagesize; ++i) *(data2 + i) =3D *(data2 + i) + 1; data3 =3D malloc(pagesize); if (!data3) exit(1); if (read(fd, data3, pagesize) !=3D pagesize) exit(1); for (i =3D 0; i < pagesize; ++i) if (*(data + i) !=3D *(data3 + i)) exit(1); close(fd); unlink("conftestmmap"); exit(0); } From janssen@parc.xerox.com Sat Mar 23 03:33:53 2002 From: janssen@parc.xerox.com (Bill Janssen) Date: Fri, 22 Mar 2002 19:33:53 PST Subject: [Image-SIG] Palm support in PIL 1.1.3? Can't find it! Message-ID: <02Mar22.193356pst."3456"@watson.parc.xerox.com> Fredrik, I see that the changelog for 1.1.3 says that the Palm support patches I contributed are in the 1.1.3 release, but that's not quite correct. It looks like the quantization patches I sent have been incorporated, which makes it possible to accurately quantize a color image to a specific palette (required for Palm 8-bit color support), but the actual Palm image support (PIL/PalmImagePlugin.py) isn't there. Any idea what happened? Did the API change or some such? (By the way, PalmImagePlugin.py is still available in ftp://ftp.parc.xerox.com/transient/janssen/PILpalm.tgz.) Bill From edcjones@erols.com Sat Mar 30 16:16:17 2002 From: edcjones@erols.com (Edward C. Jones) Date: Sat, 30 Mar 2002 11:16:17 -0500 Subject: [Image-SIG] [ANN] IM + PIL + Numeric + OpenCV Message-ID: <3CA5E4D1.8050503@erols.com> IM (pronounced with a long I) is an Python module that makes it easy to use Numeric and PIL together in programs. Typical functions in IM are: Open: Opens an image file using PIL and converts it to Numeric, PIL, or OpenCV formats. Save: Converts an array to PIL and saves it to a file. Array_ToArrayCast: Converts images between formats and between pixel types. In addition to Numeric and PIL, IM works with the Intel OpenCV computer vision system (http://www.intel.com/research/mrl/research/opencv/). OpenCV is available for Linux at the OpenCV Yahoo Group (http://groups.yahoo.com/group/OpenCV/). IM currently runs under Linux only. It should not be too difficult to port the basic IM system to Windows or Mac. The OpenCV wrapper is large and complex and uses SWIG. It will be harder to port. The IM system appears to be pretty stable. On the other hand, the OpenCV wrapper is probably very buggy. To download the software go to http://members.tripod.com/~edcjones/pycode.html and download "PyCV.032502.tgz". Edward C. Jones edcjones@hotmail.com