Avoid unnecessary conversions in Image.bitmap to make it faster.

This commit is contained in:
Andrey Golovizin 2014-08-25 16:43:53 +02:00
parent 00508d1919
commit e55b66ddd6

View file

@ -19,7 +19,6 @@ from io import BytesIO
import numpy as np
from skimage.io import imread, imsave
from skimage.color import rgb2gray
from .utils import cached_property, pairwise
@ -156,9 +155,7 @@ class Image(object):
0 = white (blank) pixel
1 = black (glyph) pixel
"""
grayscale = rgb2gray(self.data)
return (grayscale < 1).astype('b')
return (self.data != 255).any(axis=2)
@cached_property
def isspace(self):