Hello,

I know that there must be a fast way of solving this problem, but I  
don't know
what it is.

I have three arrays, with dimensions:

A[np]
L[np]
S[np]

where L and S indicate the line, smp co-ordinates for each of the  
"np" rows.
I want to reconstruct the contents of [A] as a 2-dimensional matrix.

The brain-dead version of what I want is:

results = numpy.zeros(some_size, some_other_size)
for idata in xrange(0,np):
    results[L[idata], S[idata]] = A[idata]

but I'm dealing with large arrays and this is very slow.  How
do I speed it up?  The array A is the result of performing kmeans
clustering on a large 2-d image, presented as a 1-d vector and I
want the result as a 2-d image.

In the real application, I won't have data for each point in the 2-d
image, so np will be less than the full image size.

Catherine

_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to