From e55b66ddd6ce10b007ba308ff9c831583f14a452 Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Mon, 25 Aug 2014 16:43:53 +0200 Subject: [PATCH] Avoid unnecessary conversions in Image.bitmap to make it faster. --- pixelocr/image.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pixelocr/image.py b/pixelocr/image.py index efe94ba..83f554e 100644 --- a/pixelocr/image.py +++ b/pixelocr/image.py @@ -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):