[SciPy-user] PIL and gaussian_filter?

Stéfan van der Walt stefan@sun.ac...
Thu May 22 16:26:52 CDT 2008


2008/5/22 Johannes Strömberg <johannes.stromberg@gmail.com>:
> Thank you everyone,
>
> Unfortunately I was wrong about the calculations I actually need to
> perform. I have got a working set of operations for what I need (see
> below), but it is awfully slow. Anybody got any idea on how to make it
> faster?
>
> # in = array
> # gaussian = array
> # threshold = int
> # percent = int
>
> diff = in - gaussian
> diff = numpy.where(diff > threshold,diff,0)
>
> out = imdata + diff*(float(percent)/100)

You can save a couple of temporaries by doing

diff /= percent / 100.
diff += imdata
return diff

Cheers
Stéfan


More information about the SciPy-user mailing list