我使用的是python3.7.4,我试图给一个图像添加一个白色的圆圈,但是我无法添加白色。 这是我到目前为止的代码:(我已经做了一个特定的图像)
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def ima(n,m):
what=Image.new(mode='L', size=(n,n), color=m)
mat=what.load()
for x in range(n):
for y in range(n):
mat[x,y]=x%256
return what
image=surprise(200,255) #my random image
from PIL import Image, ImageDraw
image=ima(200,255)
draw=ImageDraw.Draw(image)
draw.ellipse([(50,50),(190,245)],fill='white',outline='white') #i want the fill to be white,i tried writing None, it did not give me a white circle.(a circle of a differnet color)
plt.show(block=image)
imageplot=plt.imshow(image)
此版本适用于:
当您使用matplotlib的
imshow
时,您可以指定colormap(cmap
)参数,如果您不这样做,matplotlib将使用默认的colormap,这可能不是您所期望的。通过使用plt.colorbar()
,您可以看到正在使用什么颜色映射。请参阅我修订的代码中的一些示例。另见matplotlib colormap documentation。你知道吗相关问题 更多 >
编程相关推荐