import numpy as np
from matplotlib import cm
from matplotlib import pyplot as plt
import Image
from scipy import ndimage
import Image, ImageDraw
import PIL
import cv
import cv2
from scipy.ndimage import measurements, morphology
from PIL import Image
from numpy import *
from scipy.ndimage import filters
import pylab
import mahotas
from mamba import*
import mambaDraw
from PIL import Image, ImageDraw
img = np.asarray(Image.open('test.tif').convert('L'))
img = 1 * (img < 127)
draw = ImageDraw.Draw(img)
draw.line((100,200, 150,300), fill=128)
plt.imshow(img, cmap=cm.Greys_r)
plt.show()
我想在图像上放置一些网格线,但出现以下错误:
Traceback (most recent call last):
File "C:\Documents and Settings\All Users.WINDOWS\Документыline 24, in <module>
draw = ImageDraw.Draw(img)
File "C:\Python27\lib\site-packages\PIL\ImageDraw.py", line 296, in Draw
return ImageDraw(im, mode)
File "C:\Python27\lib\site-packages\PIL\ImageDraw.py", line 61, in __init__
im.load()
AttributeError: 'numpy.ndarray' object has no attribute 'load'
这段代码有什么问题?如何在图像上放置 100x100 网格?