Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pil image colors not requested

Hi

Ubuntu 18.04 SageMath 9.1 Jupyter notebook

does anyone know why the colors are not the ones i asked for? :

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from matplotlib.pyplot import figure
figS=2
figure(num=None, figsize=(figS, 1*figS), dpi=150, facecolor='w', edgecolor='k')
from PIL import Image, ImageColor
imSize=(10,10) #  Image size= 10x10 pixels
imageModeL=["L", "LA", "P", "PA"]
iMmode=imageModeL[0]
im = Image.new(iMmode, imSize)  

for i in range(imSize[0]) :
    for j in range(imSize[1]) :
        im.putpixel((i,j), ImageColor.getcolor("white",iMmode)) 
im.putpixel((0,0), ImageColor.getcolor('red',iMmode)) 
im.putpixel((1,0), ImageColor.getcolor('blue', iMmode)) 
im.putpixel((3,3), ImageColor.getcolor('pink', iMmode)) 
im.putpixel( (2, 2), ImageColor.getcolor('green', iMmode))
imgPath="/home/ortollj/Downloads/SageMath/IPYNB/"
im.save(imgPath+'tenXtenPixels.png') 
img = mpimg.imread(imgPath+"tenXtenPixels.png")
imgplot = plt.imshow(img)

image description