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
33043267
Commit
33043267
authored
Nov 11, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added function for division in cells.
parent
d74e6733
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
src/LBP.py
src/LBP.py
+20
-13
No files found.
src/LBP.py
View file @
33043267
#!/usr/bin/python
#!/usr/bin/python
import
Image
import
Image
from
numpy
import
array
,
zeros
,
byte
from
numpy
import
array
,
zeros
,
byte
from
matplotlib.pyplot
import
imshow
,
show
,
axis
from
matplotlib.pyplot
import
imshow
,
subplot
,
show
,
axis
CELL_SIZE
=
16
def
domainIterator
(
shape
):
"""Iterate over the pixels of an image."""
for
y
in
xrange
(
shape
[
0
]):
for
x
in
xrange
(
shape
[
1
]):
yield
y
,
x
# Divide the examined window to cells (e.g. 16x16 pixels for each cell).
# Divide the examined window to cells (e.g. 16x16 pixels for each cell).
...
@@ -28,13 +20,21 @@ def domainIterator(shape):
...
@@ -28,13 +20,21 @@ def domainIterator(shape):
# 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.
# cells. This gives the feature vector for the window.
image
=
array
(
Image
.
open
(
"../images/test.png"
).
convert
(
'L'
))
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
):
def
in_image
(
y
,
x
,
F
):
"""Check if given pixel coordinates are within the bounds of image 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
]
return
0
<=
y
<
F
.
shape
[
0
]
and
0
<=
x
<
F
.
shape
[
1
]
def
compare
(
image
):
def
features
(
image
):
"""Compare each pixel to each of its eight neigheach pixel to each of its
"""Compare each pixel to each of its eight neigheach pixel to each of its
eight neighbours."""
eight neighbours."""
features
=
zeros
(
image
.
shape
,
dtype
=
byte
)
features
=
zeros
(
image
.
shape
,
dtype
=
byte
)
...
@@ -42,7 +42,7 @@ def compare(image):
...
@@ -42,7 +42,7 @@ def compare(image):
def
cmp_pixels
(
y
,
x
,
p
):
def
cmp_pixels
(
y
,
x
,
p
):
return
in_image
(
y
,
x
,
image
)
and
image
[
y
,
x
]
>
p
return
in_image
(
y
,
x
,
image
)
and
image
[
y
,
x
]
>
p
for
y
,
x
in
domain
I
terator
(
features
.
shape
):
for
y
,
x
in
domain
_i
terator
(
features
.
shape
):
p
=
image
[
y
,
x
]
p
=
image
[
y
,
x
]
# Walk around the pixel in counter-clokwise order, shifting 1 but less
# Walk around the pixel in counter-clokwise order, shifting 1 but less
...
@@ -59,7 +59,14 @@ def compare(image):
...
@@ -59,7 +59,14 @@ def compare(image):
return
features
return
features
#print compare(image)
def
feature_vectors
(
image
):
"""Create cell histograms of an image"""
F
=
features
(
image
)
V
=
feature_vectors
(
image
)
subplot
(
121
)
imshow
(
image
,
cmap
=
'gray'
)
imshow
(
image
,
cmap
=
'gray'
)
subplot
(
122
)
imshow
(
V
,
cmap
=
'gray'
)
axis
(
'off'
)
axis
(
'off'
)
show
()
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