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
51bf48ba
Commit
51bf48ba
authored
Dec 02, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some whitespace issues.
parent
e1d45d10
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
26 deletions
+28
-26
src/GaussianFilter.py
src/GaussianFilter.py
+5
-4
src/GrayscaleImage.py
src/GrayscaleImage.py
+2
-2
src/Histogram.py
src/Histogram.py
+5
-4
src/LicensePlate.py
src/LicensePlate.py
+8
-8
src/NormalizedCharacterImage.py
src/NormalizedCharacterImage.py
+4
-4
src/Rectangle.py
src/Rectangle.py
+4
-4
No files found.
src/GaussianFilter.py
View file @
51bf48ba
...
...
@@ -8,11 +8,12 @@ class GaussianFilter:
self
.
scale
=
scale
def
gaussian
(
self
,
x
):
'''Return the value of a 1D Gaussian function for a given x and scale'''
return
exp
(
-
(
x
**
2
/
(
2
*
self
.
scale
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
self
.
scale
)
"""Return the value of a 1D Gaussian function for a given x."""
return
exp
(
-
(
x
**
2
/
(
2
*
self
.
scale
**
2
)))
\
/
(
sqrt
(
2
*
pi
)
*
self
.
scale
)
def
get_1d_gaussian_kernel
(
self
):
'''Sample a one-dimensional Gaussian function of scale s'''
"""Sample a one-dimensional Gaussian function of scale s."""
radius
=
int
(
ceil
(
3
*
self
.
scale
))
size
=
2
*
radius
+
1
...
...
@@ -25,7 +26,7 @@ class GaussianFilter:
return
result
def
get_filtered_copy
(
self
,
image
):
'''Apply a gaussian blur to an image, to suppress noise.'''
"""Apply a gaussian blur to an image, to suppress noise."""
kernel
=
self
.
get_1d_gaussian_kernel
()
image
=
convolve1d
(
image
.
data
,
kernel
,
axis
=
0
,
mode
=
'nearest'
)
return
GrayscaleImage
(
None
,
convolve1d
(
image
,
kernel
,
axis
=
1
,
mode
=
'nearest'
))
...
...
src/GrayscaleImage.py
View file @
51bf48ba
...
...
@@ -8,7 +8,7 @@ class GrayscaleImage:
if
image_path
!=
None
:
self
.
data
=
imread
(
image_path
)
extension
=
image_path
.
split
(
'.'
,
3
)[
-
1
]
extension
=
image_path
.
split
(
'.'
,
3
)[
-
1
]
if
extension
==
"jpg"
:
self
.
data
=
self
.
data
[::
-
1
]
...
...
@@ -50,7 +50,7 @@ class GrayscaleImage:
def
make_histogram
(
self
):
return
hist
(
self
.
data
)
def
resize
(
self
,
size
):
# size is of type float
def
resize
(
self
,
size
):
# size is of type float
self
.
data
=
imresize
(
self
.
data
,
size
)
def
get_shape
(
self
):
...
...
src/Histogram.py
View file @
51bf48ba
...
...
@@ -4,14 +4,15 @@ class Histogram:
self
.
bins
=
[
0
]
*
bins
self
.
min
=
min
self
.
max
=
max
def
add
(
self
,
number
):
bin_index
=
self
.
get_bin_index
(
number
)
self
.
bins
[
bin_index
]
+=
1
def
remove
(
self
,
number
):
bin_index
=
self
.
get_bin_index
(
number
)
self
.
bins
[
bin_index
]
-=
1
def
get_bin_index
(
self
,
number
):
return
(
number
-
self
.
min
)
/
((
self
.
max
-
self
.
min
)
/
len
(
self
.
bins
))
\ No newline at end of file
return
(
number
-
self
.
min
)
/
((
self
.
max
-
self
.
min
)
/
len
(
self
.
bins
))
src/LicensePlate.py
View file @
51bf48ba
...
...
@@ -36,14 +36,14 @@ class LicensePlate:
N
=
max
(
y0
,
y1
,
y2
,
y3
)
-
min
(
y0
,
y1
,
y2
,
y3
)
matrix
=
array
([
[
x0
,
y0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
x0
,
y0
,
1
,
0
,
0
,
0
],
[
x1
,
y1
,
1
,
0
,
0
,
0
,
-
M
*
x0
,
-
M
*
y1
,
-
M
],
[
0
,
0
,
0
,
x1
,
y1
,
1
,
0
,
0
,
0
],
[
x2
,
y2
,
1
,
0
,
0
,
0
,
-
M
*
x2
,
-
M
*
y2
,
-
M
],
[
0
,
0
,
0
,
x2
,
y2
,
1
,
-
N
*
x2
,
-
N
*
y2
,
-
N
],
[
x3
,
y3
,
1
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
x3
,
y3
,
1
,
-
N
*
x3
,
-
N
*
y3
,
-
N
]
[
x0
,
y0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
x0
,
y0
,
1
,
0
,
0
,
0
],
[
x1
,
y1
,
1
,
0
,
0
,
0
,
-
M
*
x0
,
-
M
*
y1
,
-
M
],
[
0
,
0
,
0
,
x1
,
y1
,
1
,
0
,
0
,
0
],
[
x2
,
y2
,
1
,
0
,
0
,
0
,
-
M
*
x2
,
-
M
*
y2
,
-
M
],
[
0
,
0
,
0
,
x2
,
y2
,
1
,
-
N
*
x2
,
-
N
*
y2
,
-
N
],
[
x3
,
y3
,
1
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
x3
,
y3
,
1
,
-
N
*
x3
,
-
N
*
y3
,
-
N
]
])
P
=
inv
(
self
.
get_transformation_matrix
(
matrix
))
...
...
src/NormalizedCharacterImage.py
View file @
51bf48ba
...
...
@@ -4,7 +4,7 @@ from LetterCropper import LetterCropper
from
GaussianFilter
import
GaussianFilter
class
NormalizedCharacterImage
(
GrayscaleImage
):
def
__init__
(
self
,
image
=
None
,
data
=
None
,
size
=
(
60
,
40
),
blur
=
1.1
,
crop_threshold
=
0.9
):
if
image
!=
None
:
GrayscaleImage
.
__init__
(
self
,
data
=
deepcopy
(
image
.
data
))
...
...
@@ -22,13 +22,13 @@ class NormalizedCharacterImage(GrayscaleImage):
self
.
data
-=
self
.
data
.
min
()
self
.
data
/=
self
.
data
.
max
()
def
gausse_filter
(
self
):
def
gausse_filter
(
self
):
filter
=
GaussianFilter
(
1.1
)
filter
.
filter
(
self
)
def
crop_to_letter
(
self
):
cropper
=
LetterCropper
(
0.9
)
cropper
.
crop_to_letter
(
self
)
def
resize
(
self
):
GrayscaleImage
.
resize
(
self
,
self
.
size
)
\ No newline at end of file
GrayscaleImage
.
resize
(
self
,
self
.
size
)
src/Rectangle.py
View file @
51bf48ba
class
Rectangle
:
def
__init__
(
self
,
x
,
y
,
width
,
height
):
self
.
x
=
x
;
self
.
y
=
y
;
self
.
width
=
width
;
self
.
height
=
height
;
self
.
x
=
x
self
.
y
=
y
self
.
width
=
width
self
.
height
=
height
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