'Converts the image into binary based on a threshold. here it is 180'

def __convertImage2binary(self, image, threshold=180):

    image = ImageOps.grayscale(image)
    image.convert('L')
    (width, height) = image.size
    for x in xrange(width):
        for y in xrange(height):
            if (image.getpixel((x, y)) < 180):
                image.putpixel((x, y), 0)
            else:
                image.putpixel((x, y), 255)
    return image
