Samuel Schmidt commited on
Commit
a10ade2
·
1 Parent(s): 287f384

Fix: Intendation

Browse files
Files changed (1) hide show
  1. src/LBP.py +18 -16
src/LBP.py CHANGED
@@ -2,21 +2,23 @@ from skimage import feature
2
  import numpy as np
3
  from PIL import Image
4
 
 
5
  class LBPImageEncoder:
6
- def __init__(self, numPoints, radius):
7
- # store the number of points and radius
8
- self.numPoints = numPoints
9
- self.radius = radius
10
-
11
- def describe(self, image, eps=1e-7):
12
- # compute the Local Binary Pattern representation
13
- # of the image, and then use the LBP representation
14
- # to build the histogram of patterns
15
- gray_img = imgage.convert('L')
16
- lbp = feature.local_binary_pattern(image, self.numPoints, self.radius, method="uniform")
17
  (hist, _) = np.histogram(lbp.ravel(), bins=np.arange(0, self.numPoints + 3), range=(0, self.numPoints + 2))
18
- # normalize the histogram
19
- hist = hist.astype("float")
20
- hist /= (hist.sum() + eps)
21
- # return the histogram of Local Binary Patterns
22
- return hist
 
 
2
  import numpy as np
3
  from PIL import Image
4
 
5
+
6
  class LBPImageEncoder:
7
+ def __init__(self, numPoints, radius):
8
+ # store the number of points and radius
9
+ self.numPoints = numPoints
10
+ self.radius = radius
11
+
12
+ def describe(self, image, eps=1e-7):
13
+ # compute the Local Binary Pattern representation
14
+ # of the image, and then use the LBP representation
15
+ # to build the histogram of patterns
16
+ gray_img = image.convert('L')
17
+ lbp = feature.local_binary_pattern(gray_img, self.numPoints, self.radius, method="uniform")
18
  (hist, _) = np.histogram(lbp.ravel(), bins=np.arange(0, self.numPoints + 3), range=(0, self.numPoints + 2))
19
+ # normalize the histogram
20
+ hist = hist.astype("float")
21
+ hist /= (hist.sum() + eps)
22
+ print(hist)
23
+ # return the histogram of Local Binary Patterns
24
+ return hist