Image to csv file

I don’t know how to change my image as rgb csv file.
i done upto college the image. but i don’t know how to save.

hey @kannan ,
after you have created your collage image. use the below commands

import cv2
image = cv2.imread(" file path here ")
image = image.flatten()
print(image.shape) # check here you should something like ( 10000,3 ) not exactly this shape , but it should be 2 dimensional and having 3 at axis =1.
pd.DataFrame(image,columns=[ ‘r’,‘g’,‘b’ ]).to_csv( ‘file.csv’ ,index=False)

after trying the above code snippet , your csv will be created successfully.

I hope this would have resolved you doubt.
Thank You and Happy learning :slightly_smiling_face:.

1 Like