1

I'm ussing the function imread from matplotlib, but when i execute it, i found this error:

import matplotlib.pyplot as plt
data = plt.imread("s_img.jpg")

"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in 
 position 2-3: truncated \UXXXXXXXX escape"

Then i tried in the opening this way:

import matplotlib.pyplot as plt
data = plt.imread(r"s_img.jpg")

this works, but when i tried to modified the image data structure, shows me an error:

 data[:,:, 1] = 0 

ValueError: assignment destination is read-only

I dont know how to deal with this. My goal is to modify the colors of the images and any other structure, and then use it to build a image classificator.

Juan David
  • 361
  • 1
  • 4
  • 15
  • 1
    Possible duplicate of [np arrays being immutable - "assignment destination is read-only"](https://stackoverflow.com/questions/39554660/np-arrays-being-immutable-assignment-destination-is-read-only) – Sheldore Jan 02 '19 at 16:52
  • The solution works, but why cant i read the data with data = plt.imread("s_img.jpg") ? – Juan David Jan 02 '19 at 19:46
  • The image properties have it read only perhaps – Sheldore Jan 02 '19 at 19:51

0 Answers0