[IMAGE-SIG] Spatial histograms

Andrew Kuchling amk@magnet.com
Mon, 14 Jul 1997 12:58:05 -0400 (EDT)


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
_______________