Skip to content

Instantly share code, notes, and snippets.

@sight-machine
Created April 17, 2013 18:31
Show Gist options
  • Save sight-machine/5406598 to your computer and use it in GitHub Desktop.
Save sight-machine/5406598 to your computer and use it in GitHub Desktop.
A simple Canny edge detector demo using SimpleCV.
# 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')
# create an edge image using the Canny edge detector
# set the first threshold to 160
output = img.edges(t1=160)
# generate the side by side image.
result = halfsies(img,output)
# show the results.
result.show()
# save the output images.
result.save('juniperedges.png')
@denmark219
Copy link

Trying to get this running. Can anyone give me a watered down install process? I tried installing pillow, but I'm still getting the error "NameError: name 'Image' is not defined. Thanks!

@denmark219
Copy link

ran a complete clean install on a new pc and the Python shell says it doesn't recognize simplecv. Any ideas anyone? Thanks!!

@funshockindia
Copy link

not simplecv but SimpleCV
code shall be
from SimpleCV import Image
Try this

@denmark219
Copy link

Thank you for the help funshockindia! Now I'm getting:

Traceback (most recent call last):
File "", line 1, in
NameError: name 'edges' is not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment