Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
licenseplates
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
licenseplates
Commits
7a002df7
Commit
7a002df7
authored
Nov 17, 2011
by
Tessmore
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:taddeus/licenseplates
parents
08a0d5d8
33043267
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
9 deletions
+65
-9
images/test.png
images/test.png
+0
-0
src/LBP.py
src/LBP.py
+65
-9
No files found.
images/test.png
View replaced file @
08a0d5d8
View file @
7a002df7
4.63 KB
|
W:
|
H:
5.41 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/LBP.py
100644 → 100755
View file @
7a002df7
#!/usr/bin/python
import
Image
from
numpy
import
array
,
zeros
,
byte
from
matplotlib.pyplot
import
imshow
,
subplot
,
show
,
axis
# Divide the examined window to cells (e.g. 16x16 pixels for each cell).
# For each pixel in a cell, compare the pixel to each of its 8 neighbors
# (on its left-top, left-middle, left-bottom, right-top, etc.). Follow the
# For each pixel in a cell, compare the pixel to each of its 8 neighbors
# (on its left-top, left-middle, left-bottom, right-top, etc.). Follow the
# pixels along a circle, i.e. clockwise or counter-clockwise.
# Where the center pixel's value is greater than the neighbor, write "1".
# Otherwise, write "0". This gives an 8-digit binary number (which is usually
# Where the center pixel's value is greater than the neighbor, write "1".
# Otherwise, write "0". This gives an 8-digit binary number (which is usually
# converted to decimal for convenience).
# Compute the histogram, over the cell, of the frequency of each "number"
# occurring (i.e., each combination of which pixels are smaller and which are
# Compute the histogram, over the cell, of the frequency of each "number"
# occurring (i.e., each combination of which pixels are smaller and which are
# greater than the center).
# Optionally normalize the histogram. Concatenate normalized histograms of all
# Optionally normalize the histogram. Concatenate normalized histograms of all
# cells. This gives the feature vector for the window.
CELL_SIZE
=
16
def
domain_iterator
(
shape
):
"""Iterate over the pixels of an image."""
for
y
in
xrange
(
shape
[
0
]):
for
x
in
xrange
(
shape
[
1
]):
yield
y
,
x
image
=
array
(
Image
.
open
(
'../images/test.png'
).
convert
(
'L'
))
def
in_image
(
y
,
x
,
F
):
"""Check if given pixel coordinates are within the bounds of image F."""
return
0
<=
y
<
F
.
shape
[
0
]
and
0
<=
x
<
F
.
shape
[
1
]
def
features
(
image
):
"""Compare each pixel to each of its eight neigheach pixel to each of its
eight neighbours."""
features
=
zeros
(
image
.
shape
,
dtype
=
byte
)
def
cmp_pixels
(
y
,
x
,
p
):
return
in_image
(
y
,
x
,
image
)
and
image
[
y
,
x
]
>
p
for
y
,
x
in
domain_iterator
(
features
.
shape
):
p
=
image
[
y
,
x
]
# Walk around the pixel in counter-clokwise order, shifting 1 but less
# at each neighbour starting at 7 in the top-left corner. This gives a
# 8-bitmap
features
[
y
,
x
]
=
byte
(
cmp_pixels
(
y
-
1
,
x
-
1
,
p
))
<<
7
\
|
byte
(
cmp_pixels
(
y
-
1
,
x
,
p
))
<<
6
\
|
byte
(
cmp_pixels
(
y
-
1
,
x
+
1
,
p
))
<<
5
\
|
byte
(
cmp_pixels
(
y
,
x
+
1
,
p
))
<<
4
\
|
byte
(
cmp_pixels
(
y
+
1
,
x
+
1
,
p
))
<<
3
\
|
byte
(
cmp_pixels
(
y
+
1
,
x
,
p
))
<<
2
\
|
byte
(
cmp_pixels
(
y
+
1
,
x
-
1
,
p
))
<<
1
\
|
byte
(
cmp_pixels
(
y
,
x
-
1
,
p
))
return
features
def
feature_vectors
(
image
):
"""Create cell histograms of an image"""
F
=
features
(
image
)
V
=
feature_vectors
(
image
)
subplot
(
121
)
imshow
(
image
,
cmap
=
'gray'
)
subplot
(
122
)
imshow
(
V
,
cmap
=
'gray'
)
axis
(
'off'
)
show
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment