By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

how to shrink a numarray array?

P: n/a
To draw a large array of data on a small panel, I need to shrink it to a
given size. e.g:

To draw numarray.arange(10000) on a panel of width of 100, I only need
to draw the points of (0, 100, 200, 300, ...) instead of (0, 1, 2, ...).
So I need a method to shrink it to an 100-item array.

x[::len(x)/panel_width] will not work. If the panel's width is 60, that
expression will return an array of 61 elements.

I believe there is an existing function in numarray to do this, however
English is not my mother tongue and math is not my speciality, I can't
find it in the document full of math terms...

--
Qiangning Hong

______________________________________________
( Michael: )
( )
( Hi. I'm Michael Jackson, from The Jacksons. )
( )
( Homer: I'm Homer Simpson, from the Simpsons. )
( )
( Stark Raving Dad )
----------------------------------------------
o
o \
\ /\
( )
.( o ).
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Qiangning Hong wrote:
To draw a large array of data on a small panel, I need to shrink it to a
given size. e.g:

To draw numarray.arange(10000) on a panel of width of 100, I only need
to draw the points of (0, 100, 200, 300, ...) instead of (0, 1, 2, ...).
So I need a method to shrink it to an 100-item array.

x[::len(x)/panel_width] will not work. If the panel's width is 60, that
expression will return an array of 61 elements.

I believe there is an existing function in numarray to do this, however
English is not my mother tongue and math is not my speciality, I can't
find it in the document full of math terms...


You can do that with bresenham's algortithm. But that's been sooo long
since I did that the last time... The basic idea is that you us the
larger of the values (your columncount) as a threshold. The you do
msomething like this:

columncount = 600
image_width = 60
v = 0
cols_to_pick = [0]
for i in xrange(columncount):
if v >= columncount:
v -= columncount
cols_to_pick.append(i)
v += image_width

Maybe a better idea is to try and find image scaling algorithms -they
might even do filtering for you.

Diez
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.