Ask Your Question

Revision history [back]

How to edit pixel values of color image in SageMath?

I would like to change pixel values in a color image with Sagemath. I can do the same in python, but my program contains some parts which can not be done with python. Here are the codes for SageMath:

MWE:

from PIL import Image
img=Image.open('image.pgm')
pxl=img.load()
#pxls=img.getdata()
print pxl[0,0]

When I compile thse codes with sage, error occurs :

"  File "smmm.sage.py", line 8, in <module>
    print pxl[_sage_const_0 ,_sage_const_0 ]
TypeError: an integer is required
"

How can I fix this?