I am having a numpy array which is the image read by open cv and saving it as a string. So I have converted the np array to string and stored the same. Now I wanted to retrieve the value(which is a string) and convert to original numpy array dimension. Could you all please help me in how to do that?
My code is as below:
img = cv2.imread('9d98.jpeg',0)
img.shape # --> (149,115)
img_str=np.array2string(img,precision=2,separator=',') # to string length 197? which I dont know how
img_numpy=np.fromstring(img_str,dtype=np.uint8) # shape (197,) since this is returning only 1D array
Please help me in resolving the same
img_str?img_str. See all the ellipsis (...). That's controlled by thethreshholdparameter. This is the same sort of condensation we get from a simpleprint(img). It also includes all the nested [] of a normal print. It's not a good format for saving.csvformat produced bysavetxt, and loaded byloadtxt.np.fromstring(img.tostring(),int)round trip, though that looses shape information. And the non stringnp.save/np.loadoption.