Hi, 2008/9/16 Hans-Peter Jansen <[EMAIL PROTECTED]>: > Now, I try to detect these folds. My 'solution' misses any sophisticated > image processing algorithm, I simply compare one pixel with the one below, > convert it to HSV (with ranges: 0..255, 0..100, 0..100), combine h and v > deviations into a value, and try to find horizontal runs of patterns with a > high enough value.
You can make this a lot quicker if you use image processing operations rather than looping yourself for each pixel. I don't actually know the PIL ones very well :-( but try something like: * go to a signed monochrome image You need to be able to handle negative values, and I don't think PIL can do RGB int. Anyway, colour won't be much help here. * subtract every pixel from the one below You can do this with a convolution. Just use a mask like 1 -1 And each pixel will become the difference between itself and the pixel below. Most of these values will be rather small, but if one of your folds is present, you'll see sudden large spikes. * take the absolute value Now you don't need negatives! * find the average value for each row You'd normally do this with a projection operator (sum every row and every column), I'm not sure if PIL has one of these. Shrinking the image to a single column should do the same job. * find peaks over a threshold Now loop down the image and look for values over a certain threshold, perhaps 50? John _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig