From Dirk.Engelmann@iwr.uni-heidelberg.de Tue Jul 1 10:55:29 1997 From: Dirk.Engelmann@iwr.uni-heidelberg.de (Dirk Engelmann) Date: Tue, 1 Jul 1997 11:55:29 +0200 (MET DST) Subject: [IMAGE-SIG] tix Message-ID: Tix and tkappinit don't work together. Is there a way to fix it ? Thanks for help! Cheers/ Dirk Engelmann Dirk.Engelmann@iwr.uni-heidelberg.de _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From dek@cgl.ucsf.EDU Sun Jul 6 07:13:30 1997 From: dek@cgl.ucsf.EDU (David Konerding) Date: Sat, 05 Jul 97 23:13:30 -0700 Subject: [IMAGE-SIG] fun with Numeric and PIL Message-ID: <199707060613.XAA19107@socrates.ucsf.EDU> I heard Numeric would work with PIL, so I tried it. Seems to work fine. I'm looking into playing around with FFTs on images; anybody done this and have sample code (using Numeric/PIL)? Here's a nifty little test program to demonstrate PIL + Numeric: ## This isn't really a PyOpenGL demo, but it's a nice ## example of how Numeric, Tkinter, and PIL can be used ## together to create all sorts of images. ## see http://picasso.ucsf.edu/~dek/PyOpenGLDemo import Numeric import FFT import Tkinter import Image import ImageTk import sys w = 256 h = 256 if __name__ == '__main__': data = Numeric.arrayrange(w*h) data = data.astype('l') im = Image.new("RGBA", (w, h)) print len(data.tostring()) print len(im.tostring()) im.fromstring(data.tostring()) root = Tkinter.Tk() image = ImageTk.PhotoImage(im) x = Tkinter.Label(root, image=image) x.pack() root.mainloop() ----------------------------------------------------------------------------- Email: dek@cgl.ucsf.edu David Konerding WWW: http://picasso.ucsf.edu/~dek ----------------------------------------------------------------------------- _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From piers@cs.su.oz.au Mon Jul 7 05:43:18 1997 From: piers@cs.su.oz.au (Piers Lauder) Date: Mon, 07 Jul 1997 14:43:18 +1000 Subject: [IMAGE-SIG] problem reading .xbm files in PIL 0.3a1 Message-ID: I have 2 .xbm format files: : s facemail ; ls -l *face.xbm -rw-rw---- 1 piers piers 1529 Jul 3 15:50 newface.xbm -rw-rw---- 1 piers piers 1850 Jul 7 14:32 oldface.xbm I can read one with PIL, but not the other. Both display fine with xv. >>> import Image >>> im=Image.open('newface.xbm') >>> im=Image.open('oldface.xbm') Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.4/local/Image.py", line 713, in open raise IOError, "cannot identify image file" IOError: cannot identify image file >>> 'newface' was created with PIL and looks like: : s facemail ; sed 10q newface.xbm #define im_width 48 #define im_height 48 static char im_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,0x00,0x00,0x26, 0x06,0x00,0x00,0x00,0x80,0x09,0x11,0x00,0x00,0x00,0x40,0x04,0x40,0x00,0x00, 0x00,0xa0,0x02,0xa0,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x58,0x01, 'oldface' was created with xv, and looks like: : s facemail ; sed 10q oldface.xbm #define face_width 48 #define face_height 48 static char face_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x78, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x80, 0xbe, 0xfe, 0x02, 0x00, Will the next release be able to read the 'xv' format? (Or should I start writing a conversion routine :-) ________________________________________________________________________________ Computer Science, Sydney University, Madsen Bldg F09, Sydney NSW 2006, Australia Phone: +61 2 9351 2824 Fax: +61 2 9351 3838 http://www.cs.su.oz.au/~piers _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From piers@cs.su.oz.au Mon Jul 7 06:05:39 1997 From: piers@cs.su.oz.au (Piers Lauder) Date: Mon, 07 Jul 1997 15:05:39 +1000 Subject: [IMAGE-SIG] Re: problem reading .xbm files in PIL 0.3a1 Message-ID: I said something misleading in my previous query: 'oldface.xbm' was created with the program 'bitmap', not 'xv'. Sorry for any confusion. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" This is a multi-part message in MIME format. ------=_NextPart_000_01BC8AC0.2696C420 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit >Will the next release be able to read the [bitmap] format? Because of this &%&" mailer, I'm not sure if there were tabs in there, or multiple spaces. Anyway, the current implementation expects a single space (on the other hand, it works perfectly fine with files created on bitmap on my machine). The spec I have shows a single space only, but doesn't say anything on how to tokenize the file. Oh well... I've attached a version of XbmImagePlugin.py that hopefully works better (if not, mail me an uu/mime-encoded version of the file). Cheers /F ------=_NextPart_000_01BC8AC0.2696C420 Content-Type: application/octet-stream; name="xbmimageplugin.py" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xbmimageplugin.py" # # The Python Imaging Library. # $Id: XbmImagePlugin.py,v 1.3 1996/11/10 17:52:14 fredrik Exp $ # # XBM File handling # # History: # 95-09-08 fl Created # 96-11-01 fl Added save support # 97-07-07 fl Made header parser more tolerant # # Copyright (c) Fredrik Lundh 1996-97. All rights reserved. # # See the README file for information on usage and redistribution. # __version__ = "0.2" import regex, string import Image, ImageFile # XBM header xbm_head = regex.compile("^#define[ \t]+[^_]*_width[ \t]+\([0-9]*\)\n" "#define[ \t]+[^_]*_height[ \t]+\([0-9]*\)\n" ".*char[ \t]+[^_]*_bits\[\]") class XbmImageFile(ImageFile.ImageFile): format = "XBM" format_description = "X11 Bitmap" def _open(self): s = xbm_head.match(self.fp.read(512)) if s > 0: xsize = string.atoi(xbm_head.group(1)) ysize = string.atoi(xbm_head.group(2)) self.mode = "1" self.size = xsize, ysize self.tile = [("xbm", (0, 0)+self.size, s, None)] def _save(im, fp, filename): if im.mode != "1": raise IOError, "cannot write mode %s as XBM" % im.mode fp.write("#define im_width %d\n" % im.size[0]) fp.write("#define im_height %d\n" % im.size[1]) fp.write("static char im_bits[] = {\n") ImageFile._save(im, fp, [("xbm", (0,0)+im.size, 0, None)]) fp.write("};\n") Image.register_open("XBM", XbmImageFile) Image.register_save("XBM", _save) Image.register_extension("XBM", ".xbm") Image.register_mime("XBM", "image/xbm") ------=_NextPart_000_01BC8AC0.2696C420-- _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Daniel.Michelson@smhi.se Thu Jul 10 12:49:30 1997 From: Daniel.Michelson@smhi.se (Daniel Michelson) Date: Thu, 10 Jul 1997 13:49:30 +0200 Subject: [IMAGE-SIG] installation of PIL 0.3a1 Message-ID: <33C4CC4A.2C67@smhi.se> Hej PIL people! Just a few comments on my installation experience, so that it may be avoided in future releases and by others who may be more newbie than I (if this is possible...): The installation instructions say: 4. To check that this library works as it should, type: $ make check It isn't much of a test, but it shouldn't crash, at least :-) This is what I got... % make check =2E/coretest make: *** [check] Floating point exception (core dumped) =2E..running on a DEC Alpha with DEC UNIX 4.0. I guess this is Fred's ide= a of a coretest. ;-) Then there were 2 compiler warnings to _imagingmodule.c: lines 845 and 1249 ("signed char" being incompatable with "unsigned char") The installation seems to result in an OK PIL, apart from these glitches. Then again, I haven't put PIL to the test yet. Who knows what will come out of the woodwork... We hope to use PIL as one of a number of building blocks to a Python-based weather radar software system. = best, -d +------------------+--------------------------------------------------+ | | Daniel B. Michelson | | /\ |\ /| | | | | Swedish Meteorological and Hydrological Institute| | \ | \/ | |__| | | S-601 76 Norrk=F6ping, Sweden |= | \ | | | | | | Telephone: +46 11 - 15 84 94 | | \/ | | | | | | Telefax: +46 11 - 17 02 07 | | | Internet: Daniel.Michelson@smhi.se | +------------------+--------------------------------------------------+ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Daniel.Michelson@smhi.se Thu Jul 10 13:37:43 1997 From: Daniel.Michelson@smhi.se (Daniel Michelson) Date: Thu, 10 Jul 1997 14:37:43 +0200 Subject: [Fwd: [IMAGE-SIG] installation of PIL 0.3a1] Message-ID: <33C4D797.7566@smhi.se> Hej again, > The installation seems to result in an OK PIL, apart from these > glitches. Then again, I haven't put PIL to the test yet. Who knows what= > will come out of the woodwork... As I was saying ... despite my configuring the jpeg lib (6) without a hitch, and pointing PIL at it according to the instructions, PIL won't associate itself with it: Python 1.4 (Feb 4 1997) [C] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Image >>> this =3D Image.open("Images/lena.jpg") >>> this.show() Traceback (innermost last): File "", line 1, in ? File "./Lib/Image.py", line 533, in show _showxv(self, title) File "./Lib/Image.py", line 780, in _showxv file =3D self._dump() File "./Lib/Image.py", line 227, in _dump self.load() File "./Lib/ImageFile.py", line 119, in load d =3D Image._getdecoder(d, e, a, self.decoderconfig) File "./Lib/Image.py", line 144, in _getdecoder raise IOError, "decoder %s not available" % d IOError: decoder jpeg not available >>> = I have a vague memory of someone else running into the same problem a while back. = Please tell me how to get jpeg into PIL. best, -d +------------------+--------------------------------------------------+ | | Daniel B. Michelson | | /\ |\ /| | | | | Swedish Meteorological and Hydrological Institute| | \ | \/ | |__| | | S-601 76 Norrk=F6ping, Sweden |= | \ | | | | | | Telephone: +46 11 - 15 84 94 | | \/ | | | | | | Telefax: +46 11 - 17 02 07 | | | Internet: Daniel.Michelson@smhi.se | +------------------+--------------------------------------------------+ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" > IOError: decoder jpeg not available > > I have a vague memory of someone else running into the same problem a > while back. What versions are you using? For smooth installation, you need libjpeg 6.0 (not 6.0a!), and PIL 0.3a1. If you have PIL 0.2b4, you have to edit the Setup file so the jpeg gets linked in (see comments in the file for details). In 0.3a1, this is done by default. If you have version 6.0a of the JPEG library, you have to change "METHODDEF xxx" to "METHODDEF(xxx)" in the JpegDecode.c and JpegEncode.c files (see the libjpeg README for more info). It is also likely that ./configure fails to identify 6.0a, which means that you must hack libImaging/ImConfig.h to make sure HAVE_LIBJPEG is defined. Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Daniel.Michelson@smhi.se Thu Jul 10 15:52:19 1997 From: Daniel.Michelson@smhi.se (Daniel Michelson) Date: Thu, 10 Jul 1997 16:52:19 +0200 Subject: [Fwd: [IMAGE-SIG] installation of PIL 0.3a1] References: <9707101438.AA11560@arnold.image.ivab.se> Message-ID: <33C4F723.4DAA@smhi.se> Fredrik Lundh wrote: > = > Check libImaging/ImConfig.h; the problem is probably that ./configure > didn't find the libraries (it only searches in a few places, and doesn'= t > care about what you typed in the Setup file). Aha, I thought it did. > Change the file to define HAVE_LIBJPEG and HAVE_LIBZ. Then > remove the object files (just type "make clean") and rebuild > the imaging library and the interface module. That did the trick. Thanks. Now, back to the woodwork... best, -d +------------------+--------------------------------------------------+ | | Daniel B. Michelson | | /\ |\ /| | | | | Swedish Meteorological and Hydrological Institute| | \ | \/ | |__| | | S-601 76 Norrk=F6ping, Sweden |= | \ | | | | | | Telephone: +46 11 - 15 84 94 | | \/ | | | | | | Telefax: +46 11 - 17 02 07 | | | Internet: Daniel.Michelson@smhi.se | +------------------+--------------------------------------------------+ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Thu Jul 10 16:23:05 1997 From: amk@magnet.com (Andrew Kuchling) Date: Thu, 10 Jul 1997 11:23:05 -0400 (EDT) Subject: [IMAGE-SIG] Changing a displayed image Message-ID: <199707101523.LAA01758@lemur.magnet.com> How does one change an image being displayed under Tkinter using ImageTk.PhotoImage? Here's the code that creates the widget displaying the image: im=Image.open('/scratch/rob.ppm') image = ImageTk.PhotoImage(im) self.viewer=Tk.Label(self, image=image, bd=0) self.viewer.pack(side=RIGHT, fill=Y) I'm trying to update the image on hitting a button, using the following code, which destroys the Label widget and recreates it: im=Image.open('/scratch/rob.ppm') im=im.transpose(Image.ROTATE_90) image = ImageTk.PhotoImage(im) self.viewer.destroy() self.viewer=Tk.Label(self, image=image, bd=0) self.viewer.pack(side=RIGHT, fill=Y) When this code gets run, the window resizes as appropriate (since the image isn't square) but the image isn't displayed; the area remains blank. What am I missing? (Presumably this is due to my poor understanding of Tkinter.) Andrew Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" >When this code gets run, the window resizes as appropriate (since the >image isn't square) but the image isn't displayed; the area remains >blank. What am I missing? (Presumably this is due to my poor >understanding of Tkinter.) You must make sure to keep a reference to the PhotoImage object. See the following page for more info: http://starship.skyport.net/crew/fredrik/tkintro/PhotoImage.htm And yes, to change the image, just reconfigure the label: self.viewer.config(image=image) self.viewer.image = image # keep a reference! Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From arb@connect.com.au Mon Jul 14 07:21:53 1997 From: arb@connect.com.au (Anthony Baxter) Date: Mon, 14 Jul 1997 16:21:53 +1000 Subject: [IMAGE-SIG] python plugin for GIMP? Message-ID: <199707140621.QAA15995@jambu.off.connect.com.au> GIMP now has a scripting interface. Currently there's scheme and tcl interfaces - anyone interested in doing a Python interface? http://scam.XCF.Berkeley.EDU/~gimp/ - the GIMP home page. http://www.xcf.berkeley.edu/~gimp/script-fu/script-fu.html - script-fu, the scheme interface Anthony _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" NOTE: Majordomo seems to interpret messages with "help" in the subject line as requests for help with mailing list issues, meaning that the mails end up on the list administrator address... >Date: Mon, 14 Jul 1997 18:01:50 +1000 >From: piers@cs.su.oz.au (Piers Lauder) >To: Python Image SIG >Subject: Help with PIL ImageTk.PhotoImage > >I've been using ImageTk.BitmapImage successfully, and >then I thought I'd try something more adventurous, but >it doesn't work. Basically I'm trying to create a >PhotoImage from a JPEG file: > [code sample removed] > >and I get: > Traceback (innermost last): > File "./showfaces.py", line 243, in ? > main() > File "./showfaces.py", line 200, in main > UpdateFaces(root, Top, mbox) > File "./showfaces.py", line 99, in UpdateFaces > _UpdateFaces(root, Top, mbox) > File "./showfaces.py", line 161, in _UpdateFaces > Faces.append((name, date, getface.GetFaceImage(addr))) > File "./getface.py", line 75, in GetFaceImage > tkim = makeface(face, file) > File "./getface.py", line 102, in makeface > return ImageTk.PhotoImage(im) > File "/usr/local/lib/python1.4/local/ImageTk.py", line 65, in __init__ > self.paste(image) > File "/usr/local/lib/python1.4/local/ImageTk.py", line 81, in paste > self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) > TclError: invalid command name "PyImagingPhoto" > exception in BitmapImage.__del__() ignored > exception in BitmapImage.__del__() ignored > >I'm using Tcl/Tk 7.6/7.2 with PIL 0.3a1. >Does anyone know of an obvious solution? > >________________________________________________________________________________ >Computer Science, Sydney University, Madsen Bldg F09, Sydney NSW 2006, Australia >Phone: +61 2 9351 2824 Fax: +61 2 9351 3838 http://www.cs.su.oz.au/~piers Have you linked _tkinter with the PhotoImage interface? See the README (and Tk/tkImaging.c) for details. Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Mon Jul 14 17:58:05 1997 From: amk@magnet.com (Andrew Kuchling) Date: Mon, 14 Jul 1997 12:58:05 -0400 (EDT) Subject: [IMAGE-SIG] Spatial histograms Message-ID: <199707141658.MAA19890@lemur.magnet.com> There don't seem to be functions to compute spatial histograms of images. For example, an X histogram is the same width as the image, and each element is the sum of all the colour values in the corresponding column; a Y histogram is all the values in each row added up. I can't think of an efficient way to do this using PIL's existing primitives, so Frederik--would you have any objection to adding a function to do this if I implemented it? If the idea is OK with you, any suggestions on an interface? Unfortunately histogram() is already taken for the colour distribution. How about: im.spat_hist(string), where string is either 'x' or 'y' depending on what you want? (You could overload histogram() to do this, but IMHO it's too confusing to have histogram doing two such different analyses.) Another thing: I haven't written my image segmentation code yet, but suspect it'll wind up having to be written in C for speed. Here's a proposal to simplify customizing PIL: Image objects have a __setattr__ method such that, when you access im.foo, PIL tries to import a module named imageop_foo (or something like that), and if it succeeds, returns imageop_foo.F . Otherwise, AttributeError is raised as usual. This way, you would just write a module containing a single function F, which did whatever analysis you desired, and could just do im.foo() to access it. Thoughts? Also: I've updated the SANE interface on my project page yet again; the only user-visible change is that there's now an explicit close() method on SaneDev objects. There are also changes to improve the error handling when trying to access an already-closed device. I've also started working on a SaneDialog class, but it isn't going to be completed any time soon and isn't on that page; it works for the QuickCam and for the PNM driver, and that's all I care about at the moment, but it won't work in general. Minor documentation nit, at least in 0.2b3's docs: the description of Image's point() method should state that a modified copy is returned; that's not obvious from the text (though most of the other functions do the same, so it's not hard to guess the behaviour). Andrew Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From da@maigret.cog.brown.edu Mon Jul 14 18:22:53 1997 From: da@maigret.cog.brown.edu (David Ascher) Date: Mon, 14 Jul 1997 13:22:53 -0400 (EDT) Subject: [IMAGE-SIG] Spatial histograms In-Reply-To: <199707141658.MAA19890@lemur.magnet.com> Message-ID: On Mon, 14 Jul 1997, Andrew Kuchling wrote: > There don't seem to be functions to compute spatial histograms of > images. For example, an X histogram is the same width as the image, > and each element is the sum of all the colour values in the > corresponding column; a Y histogram is all the values in each row > added up. I can't think of an efficient way to do this using PIL's > existing primitives, so Frederik--would you have any objection to > adding a function to do this if I implemented it? Why not use NumPy instead? > Another thing: I haven't written my image segmentation code > yet, but suspect it'll wind up having to be written in C for speed. Again, NumPy is probably the place to start -- or at least that's where I'd start -- C is too much of a pain, and NumPy is faster than my C code =). --da _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" >> Another thing: I haven't written my image segmentation code >> yet, but suspect it'll wind up having to be written in C for speed. > >Again, NumPy is probably the place to start -- or at least that's where >I'd start -- C is too much of a pain, and NumPy is faster than my C code >=). Now, if you tell me how to implement image segmentation with NumPy, I promise to make PIL a NumPy addon, rather than a separate library... On the other hand, I can probably talk PythonWare into releasing a stripped-down version of their segmentation module for public consumption ;-) Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" >There don't seem to be functions to compute spatial histograms of >images. For example, an X histogram is the same width as the image, >and each element is the sum of all the colour values in the >corresponding column; a Y histogram is all the values in each row >added up. I can't think of an efficient way to do this using PIL's >existing primitives, so Frederik--would you have any objection to >adding a function to do this if I implemented it? Would only take a few minutes to implement this based on the (not yet documented) getprojection method. So I guess coming up with an interface is the real problem... Let me get back to you on this one... >Another thing: I haven't written my image segmentation code >yet, but suspect it'll wind up having to be written in C for speed. And on this one... I have a fast and efficient crack coder up and running, developed for PythonWare. It would probably be possible to stuff a somewhat stripped-down version of this into the next PIL release. >Here's a proposal to simplify customizing PIL: Image objects have a >__setattr__ method such that, when you access im.foo, PIL tries to >import a module named imageop_foo (or something like that), and if it >succeeds, returns imageop_foo.F . Otherwise, AttributeError is raised >as usual. This way, you would just write a module containing a single >function F, which did whatever analysis you desired, and could just do >im.foo() to access it. Thoughts? Not sure what to think about this. I would prefer to use a separate segmentation object (similar to ImageDraw). Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Mon Jul 14 21:01:07 1997 From: amk@magnet.com (Andrew Kuchling) Date: Mon, 14 Jul 1997 16:01:07 -0400 (EDT) Subject: [IMAGE-SIG] Spatial histograms In-Reply-To: from "David Ascher" at Jul 14, 97 01:22:53 pm Message-ID: <199707142001.QAA27775@lemur.magnet.com> David Ascher wrote: > Again, NumPy is probably the place to start -- or at least that's where > I'd start -- C is too much of a pain, and NumPy is faster than my C code One installation of NumPy (without too much rat in it) later... Hmm... seems workable. It's certainly a better fit for implementing algorithms that go poking around at the pixel level, since changing a single pixel's value in PIL requires a call to both the setink() and point() methods of an ImageDraw object. There's probably no burning need to make PIL a NumPy add-on (though that would be neat); it would be enough to add a simple .matrix() method to Image objects which handled the conversion to a NumPy array object, and died with an ImportError if NumPy wasn't availabe. Andrew "Put all your eggs in one basket, having made sure it's a really good basket" Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" >Hmm... seems workable. It's certainly a better fit for >implementing algorithms that go poking around at the pixel level, >since changing a single pixel's value in PIL requires a call to both >the setink() and point() methods of an ImageDraw object. On the other hand, that will change Real Soon Now (tm). Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From da@maigret.cog.brown.edu Mon Jul 14 21:50:25 1997 From: da@maigret.cog.brown.edu (David Ascher) Date: Mon, 14 Jul 1997 16:50:25 -0400 (EDT) Subject: [IMAGE-SIG] Spatial histograms In-Reply-To: <9707141850.AA28259@arnold.image.ivab.se> Message-ID: On Mon, 14 Jul 1997, Fredrik Lundh wrote: > >Again, NumPy is probably the place to start -- or at least that's where > >I'd start -- C is too much of a pain, and NumPy is faster than my C code > >=). > > Now, if you tell me how to implement image segmentation with > NumPy, I promise to make PIL a NumPy addon, rather than a > separate library... >From where I'm sitting, there are thousands of ways to do image segmentation depending on your needs, how many PhD theses you're willing to slog through, and how slow you want it to be. I can do image segmentation in one line of NumPy, but you probably won't like the result. I agree that a clean NumPy/PIL interface would be nice. I haven't had to do much w/ PIL recently, though, so what's there might be good enough, I don't know. > On the other hand, I can probably talk PythonWare into releasing > a stripped-down version of their segmentation module for public > consumption ;-) Sounds interesting... --da _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Fredrik Lundh" >From where I'm sitting, there are thousands of ways to do image >segmentation depending on your needs, how many PhD theses you're >willing to slog through, and how slow you want it to be. I can do >image segmentation in one line of NumPy, but you probably won't like the >result. Well, there's probably a few thousand ways to interpret "image segmentation" (I had edge following methods in mind, which is what the PW module supports), but that doesn't stop me from wanting to see that line. Please ;-) Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From da@maigret.cog.brown.edu Mon Jul 14 22:40:05 1997 From: da@maigret.cog.brown.edu (David Ascher) Date: Mon, 14 Jul 1997 17:40:05 -0400 (EDT) Subject: [IMAGE-SIG] Spatial histograms In-Reply-To: <9707142102.AA25024@arnold.image.ivab.se> Message-ID: On Mon, 14 Jul 1997, Fredrik Lundh wrote: > Well, there's probably a few thousand ways to interpret "image > segmentation" (I had edge following methods in mind, which is > what the PW module supports), but that doesn't stop me from > wanting to see that line. Please ;-) Here's one: dark, light = where(greater(picture, .5), 0, picture)), \ where(lessthan(picture, .5), 0, picture)) Hell, here's a few thousand: for th in arange(0,1.0,.0001): dark, light = where(greater(picture, th), 0, picture)), \ where(lessthan(picture, th), 0, picture)) untested, but who needs testing anyway Before this degenerates too much, my only point is that I can't think of a single image segmentation routine which will satisfy 95% of the users (the other 5% will never be satisfied anyway). For example I believe it was AMK who wanted to do OCR -- an image segmenter for OCR purposes will be different than an image segmenter for robot vision, face targeting, tank recognition, weather-map creation, etc. Way too much text for such a small point. --da _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From richard.jones@bom.gov.au Tue Jul 15 07:08:13 1997 From: richard.jones@bom.gov.au (Richard Jones) Date: Tue, 15 Jul 1997 06:08:13 +0000 Subject: [IMAGE-SIG] time to play - animations Message-ID: <199707150608.GAA06551@mage.ho.bom.gov.au> OK, I've finally got some time to play around with PIL, Numeric and satellite imagery. In the intrests of producing All Things Pretty, I'd like to write animations from PIL. Has anyone written an extension that does this - or am I being dumb and missing something obvious in the PIL distribution itself? I'd prefer it to be in one of the more common formats such as MPEG, AVI, Quicktime, etc. Richard -- Richard Jones, Satellite Section at the Bureau of Meteorology, Australia. MIME and PGP accepted. Work phone: +61-3-9669-4539 _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Anthony Baxter Tue Jul 15 08:14:38 1997 From: Anthony Baxter (Anthony Baxter) Date: Tue, 15 Jul 1997 17:14:38 +1000 Subject: [IMAGE-SIG] time to play - animations In-Reply-To: Your message of "Tue, 15 Jul 1997 06:08:13 GMT." <199707150608.GAA06551@mage.ho.bom.gov.au> Message-ID: <199707150714.RAA19285@jambu.off.connect.com.au> the only builder for the animations that I know of is the mpeg application from UC - I don't know about many others. I suspect the codec may be a problem - it seems like many of them are proprietry. Anthony _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Tue Jul 15 10:54:41 1997 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 15 Jul 1997 11:54:41 +0200 Subject: [IMAGE-SIG] time to play - animations Message-ID: <199707150954.FAA22557@python.org> > OK, I've finally got some time to play around with PIL, Numeric and >satellite imagery. In the intrests of producing All Things Pretty, I'd >like to write animations from PIL. Has anyone written an extension that >does this - or am I being dumb and missing something obvious in the PIL >distribution itself? I'd prefer it to be in one of the more common formats >such as MPEG, AVI, Quicktime, etc. gifmaker? ;-) seriously, I've been looking into using the Windows multimedia extensions from PIL, but haven't had time to do anything serious about it yet. there's a few MPEG codecs out there, but besides those and "motion JPEG" versions, I don't know any other non-proprietary format that's suitable for photographic images. but an mpegmaker script would be cool. does anyone know an MPEG codec that builds on unix and windows, and is fairly easy to integrate? Cheers /F fredrik@pythonware.com http://www.pythonware.com _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From dcb@lems.brown.edu Tue Jul 15 21:16:51 1997 From: dcb@lems.brown.edu (Dale Bertrand) Date: Tue, 15 Jul 1997 16:16:51 -0400 Subject: [IMAGE-SIG] Numeric Error Message-ID: <33CBDAB3.41A4@lems.brown.edu> I've written a c function which returns a string representing 7 doubles. I wish to convert this string into a Numeric array for further processing. Unfortunately, Numeric dumps a core when I call Numeric.fromstring. I am sure the string is the right lenghth and have no idea what is going on. Shouldn't Numeric accept the data as long as it's the right length? Is there something I'm missing? Thanks in advance. -- code -- f = "/vision/medprojects/crisco/shocks/quad1-surfaces/quad1-0.00--0.50-00%d.raw" % i print "filename: ", f shocks_string = sd.detect(f,135,135) print "length of string: ", len(shocks_string) print "string: ", shocks_string aa = Numeric.fromstring(shocks_string, Numeric.Float) print aa -- output -- filename: /vision/medprojects/crisco/shocks/quad1-surfaces/quad1-0.00--0.50-001.raw length of string: 280 string: @G ^m@65*ðh?ðHfãQæ@JpnäN@cÕ P¶ôÀH>sOz?¬@2aE­aJ@[s?ónè(ÀCÍ¢ÆoÀ@U=lQAzÀdyÔ Ø@[@@[¹ d@[q\ãOñø?ödW§à<ÀbÊJ%I8À/Ú¾¿î¢@RÒ/AÇxô?ø(1ÈL_@Udµ$ o@6À?Ó?ð;±ªú@aÏ_éÉÀ]þÔµ@DJ°¨¶@GöfáAü@5ñ|¬±Ú?ðÑe@/M(@evÚàÌ^À3u\ÖO Segmentation fault (core dumped) dcb@lems61 396 > -- sig -- Dale Bertrand (dcb@lems.brown.edu) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Thu Jul 17 17:08:10 1997 From: amk@magnet.com (Andrew Kuchling) Date: Thu, 17 Jul 1997 12:08:10 -0400 (EDT) Subject: [IMAGE-SIG] fromstring/tostring problem Message-ID: <199707171608.MAA12053@lemur.magnet.com> This is almost certainly due to stupidity on my part, but here goes... what's going on in this test program? It creates a little test image, converts it to a string form with tostring(), and creates a new image with Image.fromstring(), but the two images don't match. What am I missing? Do fromstring() and tostring() work in opposite directions vertically? import Image, ImageDraw, string # Create a blank 25x25 image im=Image.new ('L', (25,25), 0 ) # Fill in lines 10 through 20 draw=ImageDraw.ImageDraw(im) draw.setink(255) for i in range(10,21): draw.line( (0,i), (24,i) ) im.show() # Convert to string data=im.tostring() # Prints 125, 374 which is 5*25, 15*25-1. Shouldn't it be 10*25, or 250? print string.find(data, '\377'), string.rfind(data, '\377'), len(data) # This image should be identical to im, right? im2=Image.fromstring('L', (25,25), data) # It's not, as the following printout shows for i in range(0, 25): print i, im.getpixel( (0,i) ), im2.getpixel( (0,i) ) im2.show() The output of this script is: 125 374 625 << 5*25, 15*25-1, 25*25 0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 255 << Mismatch! 6 0 255 7 0 255 8 0 255 9 0 255 10 255 255 11 255 255 12 255 255 13 255 255 14 255 255 15 255 0 16 255 0 17 255 0 18 255 0 19 255 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 Andrew Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From piers@cs.su.oz.au Mon Jul 21 05:21:28 1997 From: piers@cs.su.oz.au (Piers Lauder) Date: Mon, 21 Jul 1997 14:21:28 +1000 Subject: [IMAGE-SIG] PIL 0.3a1 and xbm file formats Message-ID: I'm having trouble reading some images saved in "xbm" format. Most xbm format images can be opened ok, but there are a few with extra #define lines at the top, which PIL doesn't like. If I remove the extra #defines, the image loads: : s facemail ; python Python 1.4 (Jul 16 1997) [GCC 2.7.2.2] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Image >>> Image.open('/usr/local/lib/faces/au/oz/su/cs/gary/face.xbm') Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.4/local/Image.py", line 713, in open raise IOError, "cannot identify image file" IOError: cannot identify image file >>> Image.open('/tmp/face.xbm') >>> ^D : s facemail ; diff /tmp/face.xbm /usr/local/lib/faces/au/oz/su/cs/gary/face.xbm 2a3,4 > #define gary_x_hot -1 > #define gary_y_hot -1 : s facemail ; sed 10q /usr/local/lib/faces/au/oz/su/cs/gary/face.xbm #define gary_width 48 #define gary_height 48 #define gary_x_hot -1 #define gary_y_hot -1 static char gary_bits[] = { 0x00, 0xfc, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x80, 0xff, 0x7f, 0xc1, 0x7f, 0x00, 0xc0, 0xff, 0x8f, 0x2a, 0xfd, 0x00, 0xc0, 0xff, 0x13, 0x80, 0xfe, 0x01, 0xe0, 0xff, 0x40, 0x20, 0xf5, 0x01, 0xe0, 0x17, 0x04, 0x08, 0xfa, 0x03, 0xe0, 0x01, 0x00, 0x80, 0xfa, 0x03, 0xf0, 0x16, 0x00, 0x00, 0xf4, 0x03, I'm not sure if these are "standard" - but should the xbm loader ignore additional #defines? Otherwise I'll amend my code to remove them before passing them to PIL. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Tue Jul 22 14:05:34 1997 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 22 Jul 1997 15:05:34 +0200 Subject: [IMAGE-SIG] PIL 0.3a1 and xbm file formats Message-ID: <199707221303.JAA07174@python.org> This is a multi-part message in MIME format. ------=_NextPart_000_01BC96B0.B4628FE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit >Most xbm format images can be opened ok, but there are a few >with extra #define lines at the top, which PIL doesn't like. The driver was supposed to handle that; not sure what made me think ".*" would match multiple lines :-( I've attached a more tolerant version of the XBM parser. Should probably rewrite the parser from scratch, but I'll take that another day. Cheers /F (on vacation) ------=_NextPart_000_01BC96B0.B4628FE0 Content-Type: application/octet-stream; name="XbmImagePlugin.py" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="XbmImagePlugin.py" # # The Python Imaging Library. # $Id: XbmImagePlugin.py,v 1.3 1996/11/10 17:52:14 fredrik Exp $ # # XBM File handling # # History: # 95-09-08 fl Created # 96-11-01 fl Added save support # 97-07-07 fl Made header parser more tolerant # 97-07-22 fl Fixed yet another parser bug # # Copyright (c) Fredrik Lundh 1996-97. All rights reserved. # # See the README file for information on usage and redistribution. # __version__ = "0.3" import regex, string import Image, ImageFile # XBM header xbm_head = regex.compile( "#define[ \t]+[^_]*_width[ \t]+\([0-9]*\)[\r\n]+" "#define[ \t]+[^_]*_height[ \t]+\([0-9]*\)[\r\n]+" "[\000-\377]*_bits\[\]" ) def _accept(prefix): return prefix[:7] == "#define" class XbmImageFile(ImageFile.ImageFile): format = "XBM" format_description = "X11 Bitmap" def _open(self): s = xbm_head.match(self.fp.read(512)) if s > 0: xsize = string.atoi(xbm_head.group(1)) ysize = string.atoi(xbm_head.group(2)) self.mode = "1" self.size = xsize, ysize self.tile = [("xbm", (0, 0)+self.size, s, None)] def _save(im, fp, filename): if im.mode != "1": raise IOError, "cannot write mode %s as XBM" % im.mode fp.write("#define im_width %d\n" % im.size[0]) fp.write("#define im_height %d\n" % im.size[1]) fp.write("static char im_bits[] = {\n") ImageFile._save(im, fp, [("xbm", (0,0)+im.size, 0, None)]) fp.write("};\n") Image.register_open("XBM", XbmImageFile, _accept) Image.register_save("XBM", _save) Image.register_extension("XBM", ".xbm") Image.register_mime("XBM", "image/xbm") ------=_NextPart_000_01BC96B0.B4628FE0-- _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From dcs@lems.brown.edu Wed Jul 23 15:15:58 1997 From: dcs@lems.brown.edu (Daniel C. Sokoloff) Date: Wed, 23 Jul 1997 10:15:58 -0400 Subject: [IMAGE-SIG] Editing pixels Message-ID: <33D6121E.41C6@lems.brown.edu> Hello, I was wondering if there is an easy way to change the values of individual pixels in a PIL image. I know it's possible to use Image.point to change values, but I'm not sure how to change one pixel to a different value. Image.point forces me to make a mask of the points I want to change first, then can place them back in the image, and this also must be done band by band -- I could not get a lambda function to use a tuple as a variable in it's expression. The value of a given pixel can be found (img.im[0] etc.), but the color is a three tuple which is immutable. Does PIL support a single pixel changing operation, or are there just expressions to evaluate on an image? Thanks.. Dan _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Wed Jul 23 16:25:33 1997 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 23 Jul 1997 17:25:33 +0200 Subject: [IMAGE-SIG] Editing pixels Message-ID: <199707231522.LAA16440@python.org> >Does PIL support a single pixel changing operation, or are there just >expressions to evaluate on an image? the point method in the ImageDraw class allows you to draw individual pixels; it doesn't work on RGB images, though (that's fixed in 0.3b1). 0.3b1 will also provide 2D array syntax, including slicing for crop/paste operations (guess it's high time, now that 1.4 has been available in 9 months...). > The value of > a given pixel can be found (img.im[0] etc.), but the color is a three > tuple which is immutable. getpixel is the official way to do that; getdata if you wish to access the whole image as a 1D array. Cheers /F _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Fri Jul 25 18:30:07 1997 From: amk@magnet.com (Andrew Kuchling) Date: Fri, 25 Jul 1997 13:30:07 -0400 (EDT) Subject: [IMAGE-SIG] Turtle graphics module Message-ID: <199707251730.NAA26563@lemur.magnet.com> Sparked by Aaron Watters' comments in the 'Python-as-a-first-language' thread, here's a TurtleDraw module. It subclasses ImageDraw.ImageDraw and adds forward(), left(), etc... methods. First, a quick sample script: ==================== import Image, TurtleDraw, math im = Image.new('L', (256, 256) ) SIZE=200 turtle = TurtleDraw.TurtleDraw(im) turtle.right( 90 ) turtle.setxy( (128, 128) ) def square(turtle, distance): # Draw a square for j in range(0, 4): turtle.forward(distance) ; turtle.right(90) def grid(turtle, distance): distance=distance/2.0 square(turtle, distance) ; turtle.rt(90) square(turtle, distance) ; turtle.rt(90) square(turtle, distance) ; turtle.rt(90) square(turtle, distance) ; turtle.rt(90) grid(turtle, SIZE) ; turtle.right(45) ; grid(turtle, SIZE) im.show() ==================== There are lots of additional features that could be added, like colours, the ability to detect what the turtle's sitting on, etc. See http://el.www.media.mit.edu/groups/el/Projects/starlogo/documentation/quick.html for more ideas. Frederik, do you want to include this in PIL, or should I put it up on my "Unmaintained software" page? Andrew Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ # TurtleDraw module import ImageDraw, math deg2rad = math.pi/180.0 class TurtleDraw(ImageDraw.ImageDraw): def __init__(self, *args): apply(ImageDraw.ImageDraw.__init__, (self,)+args) self.__x, self.__y, self.__heading = 0.0, 0.0, 90.0 self.__pendown=1 def tell(self): "Return the turtle's X,Y position and heading" return (self.__x, self.__y, self.__heading) def right(self, amount): "Turn the turtle to the right" self.__heading=(self.__heading - amount) % 360.0 def left(self, amount): "Turn the turtle to the left" self.__heading=(self.__heading + amount) % 360.0 def back(self, distance): "Move the turtle backward, drawing a line if the pen is down" self.forward(-distance) def forward(self, distance): "Move the turtle forward, drawing a line if the pen is down" im_x, im_y = self.im.size sx, sy = self.__x, self.__y distance=float(distance) ex=sx+distance*math.cos(self.__heading*deg2rad) ey=sy-distance*math.sin(self.__heading*deg2rad) if self.__pendown: self.line( (sx,sy), (ex,ey) ) self.__x, self.__y = ex, ey if not (0<=ex Message-ID: <33D8F1C0.1998@parc.xerox.com> Andrew Kuchling wrote: > > Sparked by Aaron Watters' comments in the 'Python-as-a-first-language' > thread, here's a TurtleDraw module. Yes, i thought this was a good idea too. I think using Python with turtle graphics could be a great way for someone to learn about programming. I fiddled with a similar turtle-graphics module a while ago, except it would draw on a Tk canvas (using a similar mechanism to 'pywish' to achieve interactive response to commands). Don't know where it's gotten to. Might have died with my last hard drive crash. Wasn't very hard, though. Ping _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From c9603085@zeus.hud.ac.uk Tue Jul 29 11:07:15 1997 From: c9603085@zeus.hud.ac.uk (MISS. K.L.COLLIER) Date: Tue, 29 Jul 1997 11:07:15 +0100 Subject: [IMAGE-SIG] convolution Message-ID: <199707291007.LAA04249@artemis.csm> I would like to find the convolution of two images. I notice there is a convolve function but it is only 1D. There are 2D fft's but not an inverse 2d fft. How do I go about doing this? Karen Collier c9603085@zeus.hud.ac.uk _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Tue Jul 29 14:58:27 1997 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 29 Jul 1997 15:58:27 +0200 Subject: [IMAGE-SIG] convolution Message-ID: <199707291359.JAA02096@python.org> MISS. K.L.COLLIER wrote: >I would like to find the convolution of two images. >I notice there is a convolve function but it is only 1D. >There are 2D fft's but not an inverse 2d fft. How do I go about doing this? Guess you're talking about NumPy -- PIL supports 2D convolutions, but the current version only provides a number of predefined kernels (to be fixed some day). And are you sure there's no inverse FFT in NumPy? I'm 98% sure I've seen people using it... If noone here can answer this (David?), check with the folks on the matrix-sig. After all, that's where you find the NumPy experts. Cheers /F (image-sig organizer) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From JHuang@HITC.AtlantaGA.ncr.com Tue Jul 29 15:48:33 1997 From: JHuang@HITC.AtlantaGA.ncr.com (Huang, James) Date: Tue, 29 Jul 1997 10:48:33 -0400 Subject: [IMAGE-SIG] convolution Message-ID: I am not familiar with NumPy, but I know there are many program can calculate both FFT and inverse FFT with a control flag (1 or -1). You may look at the parameters required by the FFT function. Good luck! James ---------- From: Fredrik Lundh[SMTP:fredrik@pythonware.com] Sent: Tuesday, July 29, 1997 9:58 AM To: image-sig@python.org; MISS. K.L.COLLIER Subject: Re: [IMAGE-SIG] convolution MISS. K.L.COLLIER wrote: >I would like to find the convolution of two images. >I notice there is a convolve function but it is only 1D. >There are 2D fft's but not an inverse 2d fft. How do I go about doing this? Guess you're talking about NumPy -- PIL supports 2D convolutions, but the current version only provides a number of predefined kernels (to be fixed some day). And are you sure there's no inverse FFT in NumPy? I'm 98% sure I've seen people using it... If noone here can answer this (David?), check with the folks on the matrix-sig. After all, that's where you find the NumPy experts. Cheers /F (image-sig organizer) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From dcs@lems.brown.edu Thu Jul 31 16:25:32 1997 From: dcs@lems.brown.edu (Dan Sokoloff) Date: Thu, 31 Jul 1997 11:25:32 -0400 Subject: [IMAGE-SIG] Image processing and editing Message-ID: <33E0AE6C.41C6@lems.brown.edu> hello, I recently asked about changing pixel values in PIL images, and I have used the ImageDraw module for grayscale editing. This is good for small grayscale images, but the time it takes to change large images is incredible. Is there a color lookup table associated with PIL images? if it was possible to change the lookup values, the processing would be much faster. Currently I build a lookup table for each image that is opened. This is a slow process as well. The first part of this table is a dictionary whose key is the uid for a color rectangle on the screen (the color rectangles are an on-screen abstraction of all the colors in the image -- this program is meant to be a color-editor). The value is a list of pixels with that same color (the color of the rectangle). There is another list in the table of all the colors in the image converted to hex colors that tk(inter) likes. I use this list to assign the rectangles with their corresponding color. I realize that this is a bizzare process, and it's hard to see what it's doing, but after much time of attempting a color editor without 1) having a colormap for an image or 2)pointers to make all of this easier, it was all I could think of. Is there another library out there that has capabilities to do the color processing I have mentioned? (this of this program like the color editor in XV or Photoshop). If you are having trouble visualizing this program, I put up a small page with a screenshot and a short description at: http://www.lems.brown.edu/~dcs/cmap.html Thanks. Dan Sokoloff _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From amk@magnet.com Thu Jul 31 16:57:13 1997 From: amk@magnet.com (Andrew Kuchling) Date: Thu, 31 Jul 1997 11:57:13 -0400 (EDT) Subject: [IMAGE-SIG] Image processing and editing In-Reply-To: <33E0AE6C.41C6@lems.brown.edu> (message from Dan Sokoloff on Thu, 31 Jul 1997 11:25:32 -0400) Message-ID: <199707311557.LAA17683@lemur.magnet.com> A faster way to change colour values in an image is to use the point() method of an Image object, which takes a function (or a table) that's applied to every pixel and return a new image that's been modified. Let's say you want to change all pixels of value v1 to have value v2; other pixels should be left alone. Untested code to do that is: def func(value, old_value=v1, new_value=v2): if value == old_value: return new_value else: return value new_image = old_image.point(func) This function won't be called for every single pixel; rather, PIL will call it for all 256 possible values and construct a table, which will then be quickly applied to the image. For your application, you should probably keep the original image around unchanged and maintain a table, which gets modified by the user's requests; the resulting new image would be displayed. Presumably, if you change colour 1 to colour 2, and then change colour 2 to colour 3, you only want the second change to affect pixels that were colour 2 in the original image, right? Andrew Kuchling amk@magnet.com http://people.magnet.com/%7Eamk/ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From Daniel.Michelson@smhi.se Tue Jul 29 14:37:45 1997 From: Daniel.Michelson@smhi.se (Daniel Michelson) Date: Tue, 29 Jul 1997 15:37:45 +0200 Subject: [IMAGE-SIG] propaganda Message-ID: <33DDF229.52BF@smhi.se> Greetings! Python is already being used at NASA and we want it to get a foot in the door at EUMETSAT too! We're involved in a very large project designed to prototype the next generation methods and systems for processing meteorological satellite data for all EUMETSAT members. We're part of a consortium of European weather services of which we're the only ones with any knowledge of and experience with Python. = We're now faced with the task of convincing our partners that Python is worth using. So far, the attitude seems to be that Python is assumed "guilty" until proven "innocent"; the preferences among our collegues are ANSI C and Fortran 77 administered by sh or ksh... :-( There is a lot of good information at python.org but: = If anyone has written a page or two (or more) previously on the benefits of using Python when building a large distributed system, would you please share it with me? Please help! We don't want to be caught in a time warp and forced to use old, slow methods! best, -d +------------------+--------------------------------------------------+ | | Daniel B. Michelson | | /\ |\ /| | | | | Swedish Meteorological and Hydrological Institute| | \ | \/ | |__| | | S-601 76 Norrk=F6ping, Sweden |= | \ | | | | | | Telephone: +46 11 - 15 84 94 | | \/ | | | | | | Telefax: +46 11 - 17 02 07 | | | Internet: Daniel.Michelson@smhi.se | +------------------+--------------------------------------------------+ _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From arw@dante.mh.lucent.com Tue Jul 29 16:05:28 1997 From: arw@dante.mh.lucent.com (Aaron Watters) Date: Tue, 29 Jul 1997 11:05:28 -0400 Subject: [IMAGE-SIG] Re: [MATRIX-SIG] propaganda Message-ID: <199707291501.LAA08323@dante.mh.lucent.com> Is there any chance you can convince them that Python is just another C library with which to build tools? Maybe they'd be more receptive if it isn't a black and white situation. If you do, of course, I expect the other tools will be able to sit back and let Python do most of the work, however. I may send you some email addresses privately. The following come to mind: infoseek worldnet (att) industrial light and magic (ILM) ILU (xerox PARC) gstein@microsoft.com (this one I'll send publicly :) ). There is a "who uses python" page at http://www.python.org too. -- Aaron Watters ---------- From: Daniel Michelson To: guido@CNRI.Reston.Va.US Cc: matrix-sig@python.org; image-sig@python.org Subject: [MATRIX-SIG] propaganda Date: Tuesday, July 29, 1997 9:37 AM Greetings! Python is already being used at NASA and we want it to get a foot in the door at EUMETSAT too! We're involved in a very large project designed to prototype the next generation methods and systems for processing meteorological satellite data for all EUMETSAT members. We're part of a consortium of European weather services of which we're the only ones with any knowledge of and experience with Python. We're now faced with the task of convincing our partners that Python is worth using. So far, the attitude seems to be that Python is assumed "guilty" until proven "innocent"; the preferences among our collegues are ANSI C and Fortran 77 administered by sh or ksh... :-( There is a lot of good information at python.org but: If anyone has written a page or two (or more) previously on the benefits of using Python when building a large distributed system, would you please share it with me? Please help! We don't want to be caught in a time warp and forced to use old, slow methods! best, -d +------------------+--------------------------------------------------+ | | Daniel B. Michelson | | /\ |\ /| | | | | Swedish Meteorological and Hydrological Institute| | \ | \/ | |__| | | S-601 76 Norrköping, Sweden | | \ | | | | | | Telephone: +46 11 - 15 84 94 | | \/ | | | | | | Telefax: +46 11 - 17 02 07 | | | Internet: Daniel.Michelson@smhi.se | +------------------+--------------------------------------------------+ _______________ MATRIX-SIG - SIG on Matrix Math for Python send messages to: matrix-sig@python.org administrivia to: matrix-sig-request@python.org _______________ ---------- _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________