[SciPy-user] PIL and gaussian_filter?

Robert Kern robert.kern@gmail....
Fri May 23 22:39:23 CDT 2008


On Fri, May 23, 2008 at 9:06 PM, Anne Archibald
<peridot.faceted@gmail.com> wrote:
> 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)
>
> It might help a little to write:
> diff[diff>threshold] = 0
>
> Otherwise there's not too much fat in there.

As I think I've mentioned in another thread, these masked operations
are inherently slow. We use iterators to do them, and this interferes
with the ability of the compiler to use optimized instructions. It is
exactly this operation that was the bottleneck in one of our programs,
so we wrote a C function using SSE2 instructions to do this wicked
fast.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the SciPy-user mailing list