Reputation: 33223
So I have data in shape (100,100,5000).
Basically, it is a 100 by 100 pixel image which each (x,y) pixel having some spectrum vector.. So, the data is format
[ [ [ 0, 0.2.....],[0.1,0.3.....].. and so on]]
When we do d[0][0][0] corresponds to (0,0) pixel in image and the spectrum value is 0
Now, i want to run kmeans algorithm in it.. Thats the background.
To run kmeans, I want to convert it into feature vector.. as
[0,0,0]
[0,0,0.2]
and so on..
Is there a "python" way to do this conversion. I am guessing there should be some numpy reshape method which can easily achieve this, rather than writing the three for loops which I am trying to avoid.
Upvotes: 1
Views: 767
Reputation: 29307
Use numpy reshape http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html e.g.
a.reshape((m,n))
where m
and n
are the desired coordinates of your array a
Upvotes: 2