ialprBinarize

Data: 16/04/2013

Módulo

1 import cv2
2 import numpy as np
3 
4 def niblack(image, k=0.3, c=0, w=15):
5     mean = cv2.boxFilter(image, -1, (w,w))
6     stdd = np.sqrt(cv2.boxFilter(image*image, -1, (w,w)) - mean*mean)
7     niblack = mean + k*stdd - c
8     return image > niblack

Teste simples

1 from ialprBinarize import niblack
2 f = array([arange(25)]).reshape((5,5)).astype(uint8)
3 print f
4 print niblack(f).astype(int)
[[ 0  1  2  3  4]
 [ 5  6  7  8  9]
 [10 11 12 13 14]
 [15 16 17 18 19]
 [20 21 22 23 24]]
[[0 0 0 0 0]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [0 0 1 1 1]
 [1 1 1 1 1]]

Teste com placa de carro

1 import iaLPR
2 f,g = iaLPR.lprGetPhoto(1001)
3 adshow(f)
4 g = niblack(f)
5 adshow(g)
/usr/local/lib/python2.6/dist-packages/scikits.learn-0.8.1-py2.6-linux-x86_64.egg/scikits/learn/neighbors.py:11: RuntimeWarning: numpy.flatiter size changed, may indicate binary incompatibility
  from .ball_tree import BallTree

Testes

gravando arquivo: /home/rubens/www/media/Attachments/iaLPR/ialprBinarize/testperf.pkl

Autor Funcao 300-310   400-410   1000-1010  
rubens niblack 0.3 4640.013 ms 2 4506.946 ms 5 4610.099 ms 4