[SciPy-user] PIL and gaussian_filter?

Stéfan van der Walt stefan at sun.ac.za
Thu May 22 17:26:52 EDT 2008


2008/5/22 Johannes Strömberg <johannes.stromberg at 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