I am trying to understand the basics for image processing an image of a corridor. I have have used PIL to convert find the edges in an image, then I have converted it to a 1 bit image. I know what I want to be able to extract - the longest horizontal and diagonal lines tha开发者_StackOverflowt can be found in the image. Any ideas?
from PIL import *
import Image, ImageFilter
im = im.open("c:\Python26\Lib\site-packages\PIL\corridor.jpg")
imageInfo=list(im.getdata())
im.putdata(imageInfo)
print pic.size
for i in imageInfo2[180:220]:
if i==0:
print "This is a BLACK pixel"
elif i==255:
print "This is a WHITE pixel"
else:
print "ERROR"
First don't call them 1 bit images - that normally refers to images (like icons) where each pixel is 1bit and so 8pixels can be packed into a single byte.
Images with only two levels are normally called 'binary' in image processing.
Now you only have to learn the science of image processing !
A good place to start is opencv a free image processing library that also works with python and interfaces reasonably well with PIL.
You shoudl also read their book - or one of the other good books on image processing
精彩评论