how can i convert image into a panda dataframe?
How to convert image into dataframe
What kind of DataFrame do you want to make from the image (i.e. the shape)?
Do you want the df of the shape: (width, height) or a linear one with the RGB values as columns?
I want a linear one with RGB values as col
This snippet should do the job:
colourImg = Image.open("test.png")
colourArray = np.array(colourImg.getdata())
df = pd.DataFrame(colourArray, columns=["red","green","blue"])
it says np does not have any attribute getdata()
from
PIL
import
Image
Use this Image class for the Image.open() method.
I already imported and modified the img…
If the image is already in a numpy array, then you can also do this:
pd.DataFrame(img.reshape(-1, 3), columns=["red","green","blue"])
Ensure channels are the last dimension.
all the values of the dataframe are zero
I don’t have any clue why
pls help me
Hey @stutijain578
I need to look at the code to further investigate the issue. Request you to share it through Google Drive or the Coding Blocks IDE.
Hey Stuti.
The file is not visible. Please make it public.
I have made it public
Hi Stuti, you are mistaken. All rows are not zero. To confirm this, you can use any of these functions:
df.sum()
df.max()
df.std()
df[30000:30500]
ok
thanks
btw my collage is bit different from that of sample even though I followed the instructions for the mentioned dimensions…
Have you tried it submitting it? What is the score you received? Also try verifying the dimensions and see if they match.
it is not getting uploaded, says can’t upload
accuracy is only 19%, please mention the dimensions of center image
The dimensions of the center image are (100, 100) without the borders. Try to make a submission after this correction.