[Image-SIG] manipulating image for counting microbial cells

Dan Halbert halbert at halwitz.org
Fri Sep 25 00:06:55 CEST 2009


Chuck Pepe-Ranney wrote:
> Hello,
> I am wondering if I can use PIL to manipulate some fluorescent 
> microscopy images.  Specifically, I will have two images of the same 
> field but each will be taken under different emission filters.  What I 
> need to do is loop through the pixels in the first image multiply each 
> pixel's intensity by a factor then divide it by the intensity of the 
> spatially corresponding pixel in the second image.  There are more 
> steps to follow but they are seemingly routine image manipulation 
> tasks.  The images will be in tiff format.  Would PIL be a suitable 
> solution to this problem?
I don't claim to be an expert, but here are some suggestions. You can do 
simple manipulation in PIL. See for instance the ImageChops, ImageMath, 
etc. modules. Also take note of the "pixel access object", new in PIL 
1.1.6, described under "load" in 
http://www.pythonware.com/library/pil/handbook/image.htm.

Another alternative is to do the image manipulation in numpy/scipy. Also 
new in PIL 1.1.6 are operations to convert PIL images to and from numpy 
arrays. See asarray() and fromarray() here: 
http://effbot.org/zone/pil-changes-116.htm.

Yet another alternative for sophisticated image manipulation is OpenCV, 
a C/C++ library with several python interfaces. OpenCV 1.0 is 
well-documented in an O'Reilly book. OpenCV 2.0 just came out in beta 
(the beta is called 1.2, for some reason), and has an improved python 
interface which I have not looked at yet.

Dan


More information about the Image-SIG mailing list