[Numpy-discussion] dedicated function for resize with averaging or rebin 2d arrays?
Tue Nov 15 11:14:47 CST 2011
On 11/14/11 2:02 PM, Andrea Zonca wrote:
> On Mon, Nov 14, 2011 at 09:24, Chris.Barker<Chris.Barker@noaa.gov> wrote:
>> On 11/11/11 8:28 PM, Craig Yoshioka wrote:
>>> I once wrote a generic n-dimensional binning routine in C that I
>>> could find if anyone is interested in integrating it into numpy... it
>>> didn't do size increases though... and I think I implemented it so
>>> that binning by a non-divisible factor trimmed the extras. It was
>>> very-very fast though.
>> And I've got one written in Cython. I'd been thinking of contributing it
>> to ndimage, but never got around to it -- but I'd be glad to share. Let
>> me know if you want it.
> Chris, I think this would be useful, can you make it available publicly?
hmm -- I thought I had a more generic version, but can't find it at the
moment. So here is a cython file with a couple utilities in it -- only
useful for one thing now, but it could be used as a starting point for a
more general purpose function.
Note that the trick to top performance with Cython is to specify the
types of your inputs -- in this case np.uint8 for an RGB image. You
could write it totally generic, but wouldn't get the big speed up you
Maybe write a generic version, and special case a couple types for the
common case -- or do a templating thing like the bottleneck project.
This code is in the public domain -- do with it whatever you want.
>>>> I think the usefulness of the rebin function is to be simple and fast,
>>>> and the best would be to implement it in the core numpy, as a simple
>>>> method for smoothing and reshaping,
>> Does it have common use=-cases outside image processing? If not, then
>> no, it shouldn't be in numpy.
> actually the most common use is outside of image processing, we typically
> use it when we have data that come from a detector scanning the sky in
> circles, so you have a row for each scan.
> It is nice to apply a quick and dirt decimation of the dataset by binning it.
> It is such a simple function that would make more sense, to me, to
> have in numpy.
> In image processing I imagine you typically want to apply window functions,
> so for that ndimage is more appropriate.
> NumPy-Discussion mailing list
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the NumPy-Discussion