def lbp(im,pattern=LBP_CLASSIC):
    '''
    Conduct an LBP transformation on the image.
    '''
    im = pv.Image(im.asOpenCVBW()) #TODO: Use opencv for speed
    
    mat = im.asMatrix2D()
    lbp = np.zeros(mat.shape,dtype=np.uint8)

    w,h = mat.shape
    
    bit = 1
    for dx,dy in pattern:
        affine = pv.AffineTranslate(-dx,-dy,(w,h))
        mat2 = affine.transformImage(im).asMatrix2D()
                
        lbp += bit*(mat < mat2)
        
        bit = bit * 2
        
    return lbp
dataset/ETHPy150Open bolme/pyvision/src/pyvision/other/texture.py/lbp/original