Home > Net >  Why is Local Binary Pattern affected by scaling?
Why is Local Binary Pattern affected by scaling?

Time:08-14

I found that the local binary pattern in scikit-image is affected by re-scaling the image, but I was not expecting this. Since the LBP just involves greater/less than comparisons between nearby pixels, I thought a linear transformation would not affect things.

import numpy as np
import skimage
from skimage.feature import local_binary_pattern

im = skimage.data.cell()

out_im = local_binary_pattern(im, 16, 2, method='uniform')
out_im = out_im[20:-20, 20:-20] # remove edges
counts,bins = np.histogram(out_im)
print('counts=',counts)
print('bins=',bins)

This gives me

counts= [   896   2743   9555  14928 108466  94041  28682  14703   8728  33458]
bins= [ 0.   1.7  3.4  5.1  6.8  8.5 10.2 11.9 13.6 15.3 17. ]

But if I normalize the image:

im = (im-im.min())/(im.max()-im.min())

Then I get:

counts= [   937   2716   9504  16263 109302  92114  27753  14248   8667  34696]
bins= [ 0.   1.7  3.4  5.1  6.8  8.5 10.2 11.9 13.6 15.3 17. ]

Can someone explain why? The original image has values between 0 and 255.

CodePudding user response:

I found that there is no difference when there are only 4 points in the kernel, which correspond to up/down/left/right. This suggests that the difference arises due to the floating point interpolation when the points are located at non-integer coordinates. I'm guessing that the floating point calculations occasionally mess up the greater/equal comparisons, leading to slightly different histograms.

  • Related