[SciPy-user] PIL and gaussian_filter?

Anne Archibald peridot.faceted@gmail....
Wed May 21 16:15:31 CDT 2008


2008/5/21 Stéfan van der Walt <stefan@sun.ac.za>:

> 2008/5/21 Johannes Strömberg <johannes.stromberg@gmail.com>:
>> Thanks a lot, it works like a charm.
>>
>> Does anyone know of an efficient way of implementing a threshold
>> filter, i.e. where the resulting value is either the difference
>> between the current value and the threshold (if the value is above the
>> threshold) or otherwise 0?
>
> Unless you have really large data-sets, you can do:
>
> mask = x > threshold
> x[~mask] = 0
> x[mask] -= threshold

Or if you want it inplace:
np.subtract(x,threshold,x)
np.maximum(x,0,x)

Anne


More information about the SciPy-user mailing list