Search code examples
pythonimagenumpydata-structuresfeature-extraction

How to create a N-dimentional feature vector in python


I have 20 pixel values for an image, and i would like to store them in a 20D feature vector, not a 20 length feature vector. I'm new to Python, so i don't know if in Python a regular array is considered a n-dimentional vector, or i need to vectorize a single array somehow. These are the pixels value:

[245, 247, 199, 199, 210, 213, 216, 196, 225, 
    199, 189, 189, 195, 221, 225, 201, 221, 201, 216, 222]

I wish to turn them into a 20d dimentional vector, how would i proceed to do that?


Solution

  • If I understand you correctly, the shape of your solution array should be (20,1). To do this, np.reshape is the quickest and easiest way. The code to do this below:

    np.reshape(your_array,(20,1))