Python SimpleCV教程名称错误:全局名称';pil';没有定义

Python SimpleCV教程名称错误:全局名称';pil';没有定义,python,binary,simplecv,Python,Binary,Simplecv,我尝试使用SimpleCV示例的代码(),它显示SimpleCV阈值函数,阈值方法根据图像的亮度将图像中的每个像素设置为黑色或白色 但它不起作用 错误如下: from SimpleCV import Image, Color, Display # Make a function that does a half and half image. def halfsies(left,right): result = left # crop the right image to b

我尝试使用SimpleCV示例的代码(),它显示SimpleCV阈值函数,阈值方法根据图像的亮度将图像中的每个像素设置为黑色或白色

但它不起作用

错误如下:

from SimpleCV import Image, Color, Display

# Make a function that does a half and half image.
def halfsies(left,right): 
    result = left
    # crop the right image to be just the right side.
    crop   = right.crop(right.width/2.0,0,right.width/2.0,right.height)
    # now paste the crop on the left image.
    result = result.blit(crop,(left.width/2,0))
    # return the results.
    return result
# Load an image from imgur.
img = Image('http://i.imgur.com/lfAeZ4n.png')
# binarize the image using a threshold of 90 
# and invert the results.
output = img.binarize(90).invert()
# create the side by side image.
result = halfsies(img,output)
# show the resulting image.
result.show()
# save the results to a file. 
result.save('juniperbinary.png')
错误:

回溯(最近一次呼叫最后一次):

文件“Camera_1.py”,第37行,在

img=Image('http://i.imgur.com/lfAeZ4n.png)

文件“c:\Python27\lib\site packages\SimpleCV\ImageClass.py”,第686行,在

it\uuu

`source = pil.open(im).convert("RGB")`
name错误:未定义全局名称“pil”

代码如下:

from SimpleCV import Image, Color, Display

# Make a function that does a half and half image.
def halfsies(left,right): 
    result = left
    # crop the right image to be just the right side.
    crop   = right.crop(right.width/2.0,0,right.width/2.0,right.height)
    # now paste the crop on the left image.
    result = result.blit(crop,(left.width/2,0))
    # return the results.
    return result
# Load an image from imgur.
img = Image('http://i.imgur.com/lfAeZ4n.png')
# binarize the image using a threshold of 90 
# and invert the results.
output = img.binarize(90).invert()
# create the side by side image.
result = halfsies(img,output)
# show the resulting image.
result.show()
# save the results to a file. 
result.save('juniperbinary.png')

您需要安装Python映像库(PIL),它是一个第三方模块。我认为SimpleCV应该作为整个安装过程的一部分安装PIL,但PIL是其中一个更奇怪的程序

尝试从命令行键入以下内容:

pip install pil
或者,您可以使用安装

如果仍然不起作用,请尝试安装,这是一种更友好且积极开发的PIL分支:

pip install pillow