3

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]]
Calvin Jones
  • 357
  • 6
  • 18
  • I'm not sure, but the issue might have something to do with the transposing (too many times or doing it in the wrong place). – Andrew Clark Feb 21 '13 at 18:59

1 Answers1

4

JPEG saved by PIL is always lossy.

mmgp
  • 17,443
  • 2
  • 46
  • 74
  • wow that actually works i cant believe it was that simple my goodness thank you so much god bless you for everything – Calvin Jones Feb 21 '13 at 19:11
  • 1
    +1. The whole point of JPEG is that it can throw away data in a way that the human eye won't notice the difference (but obviously a computer looking at the exact pixel values will). – abarnert Feb 21 '13 at 19:23