473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to shrink a numarray array?

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
1 1941
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marco Bubke | last post by:
Hi Ok, I get a reproduceable seqmentation fault. Ok, fist the code: cdef NumArray array_to_double(NumArray array): # maybe here is memoty leak! cdef NumArray flat_array_obj flat_array_obj...
6
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array...
5
by: Bill Mill | last post by:
Hello all, I've pickled a numarray array object using cPickle like so: pickle = cPickle.Pickler(fout, -1) pickle.dump((myarray, list1, list2)) and this seems to work fine, until I try to...
4
by: Ben Champion | last post by:
I have installed python 2.3.3 on my windows machine have have ran several programs succesfully. I have also installed numarray 1.1 for my version of python and am now trying to create arrays using...
1
by: Chris P. | last post by:
Hi. I have a very simple task to perform and I'm having a hard time doing it. Given an array called 'x' (created using the numarray library), is there a single command that rounds each of its...
2
by: Edward C. Jones | last post by:
#! /usr/bin/env python """Should this program take 4.3 seconds to run? I have a Linux PC with an AMD Athlon XP 2000+ chip (1.7Gh). I use Python 2.4.1 and numarray 1.2.3, both compliled from...
0
by: andrewfelch | last post by:
Below is the code to/from Boolean arrays and Unsigned integers. On my Pentium 4, functions such as "bitwise_and" are 32 times faster when run on 32-bit integers instead of the...
1
by: Ivan Vinogradov | last post by:
Hello All, this seems like a trivial problem, but I just can't find an elegant solution neither by myself, nor with google's help. I'd like to be able to keep an array representing coordinates...
2
by: avharut | last post by:
hello everyone! sorry to disturb you with this, but i really cant find anything suitable about the topic in the numarray documentation. how can i find in an efficient way the index of the last...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.