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
82af5f4e
Commit
82af5f4e
authored
Dec 21, 2011
by
Jayke Meijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments to code.
parent
557bcdb2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
23 deletions
+10
-23
src/Character.py
src/Character.py
+3
-0
src/Classifier.py
src/Classifier.py
+0
-1
src/GrayscaleImage.py
src/GrayscaleImage.py
+0
-14
src/Histogram.py
src/Histogram.py
+0
-4
src/NormalizedCharacterImage.py
src/NormalizedCharacterImage.py
+6
-4
src/create_characters.py
src/create_characters.py
+1
-0
No files found.
src/Character.py
View file @
82af5f4e
...
...
@@ -8,6 +8,8 @@ class Character:
self
.
filename
=
filename
def
get_single_cell_feature_vector
(
self
,
neighbours
=
5
):
"""Get the histogram of Local Binary Patterns over this entire
image."""
if
hasattr
(
self
,
'feature'
):
return
...
...
@@ -15,6 +17,7 @@ class Character:
self
.
feature
=
pattern
.
single_cell_features_vector
()
def
get_feature_vector
(
self
,
cell_size
=
None
):
"""Get the concatenated histograms of Local Binary Patterns. """
pattern
=
LBP
(
self
.
image
)
if
cell_size
==
None
\
else
LBP
(
self
.
image
,
cell_size
)
...
...
src/Classifier.py
View file @
82af5f4e
from
svmutil
import
svm_train
,
svm_problem
,
svm_parameter
,
svm_predict
,
\
svm_save_model
,
svm_load_model
,
RBF
class
Classifier
:
def
__init__
(
self
,
c
=
None
,
gamma
=
None
,
filename
=
None
,
neighbours
=
3
,
\
verbose
=
0
):
...
...
src/GrayscaleImage.py
View file @
82af5f4e
...
...
@@ -22,20 +22,6 @@ class GrayscaleImage:
for
x
in
xrange
(
self
.
data
.
shape
[
1
]):
yield
y
,
x
,
self
.
data
[
y
,
x
]
#self.__i_x = -1
#self.__i_y = 0
#return self
#def next(self):
# self.__i_x += 1
# if self.__i_x == self.width:
# self.__i_x = 0
# self.__i_y += 1
# if self.__i_y == self.height:
# raise StopIteration
# return self.__i_y, self.__i_x, self[self.__i_y, self.__i_x]
def
__getitem__
(
self
,
position
):
return
self
.
data
[
position
]
...
...
src/Histogram.py
View file @
82af5f4e
...
...
@@ -6,13 +6,9 @@ class Histogram:
self
.
max
=
max
def
add
(
self
,
number
):
#bin_index = self.get_bin_index(number)
#self.bins[bin_index] += 1
self
.
bins
[
number
]
+=
1
def
remove
(
self
,
number
):
#bin_index = self.get_bin_index(number)
#self.bins[bin_index] -= 1
self
.
bins
[
number
]
-=
1
def
get_bin_index
(
self
,
number
):
...
...
src/NormalizedCharacterImage.py
View file @
82af5f4e
...
...
@@ -13,14 +13,16 @@ class NormalizedCharacterImage(GrayscaleImage):
self
.
blur
=
blur
self
.
gaussian_filter
()
self
.
increase_contrast
()
#
self.increase_contrast()
self
.
height
=
height
self
.
resize
()
def
increase_contrast
(
self
):
self
.
data
-=
self
.
data
.
min
()
self
.
data
=
self
.
data
.
astype
(
float
)
/
self
.
data
.
max
()
# def increase_contrast(self):
# """Increase the contrast by performing a grayscale mapping from the
# current maximum and minimum to a range between 0 and 1."""
# self.data -= self.data.min()
# self.data = self.data.astype(float) / self.data.max()
def
gaussian_filter
(
self
):
GaussianFilter
(
self
.
blur
).
filter
(
self
)
...
...
src/create_characters.py
View file @
82af5f4e
...
...
@@ -80,6 +80,7 @@ def load_test_set(neighbours, blur_scale, verbose=0):
def
generate_sets
(
neighbours
,
blur_scale
,
verbose
=
0
):
"""Split the entire dataset into a trainingset and a testset."""
suffix
=
'_%s_%s'
%
(
blur_scale
,
neighbours
)
learning_set_file
=
'learning_set%s.dat'
%
suffix
test_set_file
=
'test_set%s.dat'
%
suffix
...
...
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