简体   繁体   中英

Incorrect red pixel values of saved picture Python

I have a multidimensional array of the red pixels in the picture. And I'm adjusting it to make a new picture using the new red pixels that I have changed. I'm still keeping the blue and green and I'm not changing those. When I print out the red pixels to see if their correct before I saved the new picture everything is right Until I actually check the new picture by opening and displaying the red values thats when the values are wrong. Heres the code:

 from PIL import Image
import numpy as np

picture = Image.open('flower.jpg')
red, green, blue = np.array(picture).T
print red
picture.save('output.jpg')

The output of the first print statement the red pixels of picture:

[[112 114  111 ..., 12 13  7]
 [111 112  112 ..., 13 15 11]
 [111 110  110 ..., 12 17 17]
  ...,
 [181 180  180 ..., 25  17 11]
 [180 181  182 ..., 18  14  9]
 [179 179  179 ..., 13  14 15]]

PIL保存的JPEG总是有损的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM