logo       

RE: rebin: msg#00071

python.numeric.general

Subject: RE: rebin

For the most general form of binning I use a convolution (by a 2D mask)
followed by a subsmapling.

For example for a 3x3 binning:
mask = ones((3,3))
binned = convolve2d(data,mask,'same')[1::3,1::3]

Nadav.
-----Original Message-----
From: Russell E. Owen [mailto:owen@xxxxxxxxxxxxxxxxxxxx]
Sent: Sat 28-Aug-04 03:34
To: numpy-discussion@xxxxxxxxxxxxxxxxxxxxx
Cc:
Subject: [Numpy-discussion] rebin
Any suggestions on an efficient means to bin a 2-d array? REBIN is the IDL
function I'm trying to mimic. Binning allows one to combine sets of pixels from
one array to form a new array that is smaller by a given factor along each
dimension.

To nxm bin a 2-dimensional array, one averages (or sums or ?) each nxm block of
entries from the input image to form the corresponding entry of the output
image.

For example, to 2x2 bin a two-dimensional image, one would:
average (0,0), (0,1), (1,0), (1,1) to form (0,0)
average (0,2), (0,3), (1,2), (1,3) to form (0,1)
...

In case it helps, in my immediate case I'm binning a boolean array (a mask) and
thus can live with almost any kind of combination.

-- Russell


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/numpy-discussion





-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id808&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise