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
accab14c
Commit
accab14c
authored
Dec 02, 2011
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:taddeus/licenseplates
parents
c1140af0
56fc1ca9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
29 deletions
+48
-29
src/FilterNoise.py
src/FilterNoise.py
+0
-29
src/GaussianFilter.py
src/GaussianFilter.py
+39
-0
src/GaussianFilterTest.py
src/GaussianFilterTest.py
+9
-0
No files found.
src/FilterNoise.py
deleted
100644 → 0
View file @
c1140af0
from
scipy.ndimage
import
convolve1d
from
pylab
import
ceil
,
zeros
,
pi
,
e
,
exp
,
sqrt
,
array
def
f
(
x
,
s
):
"""Return the value of a 1D Gaussian function for a given x and scale."""
return
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
s
)
def
gauss1
(
s
,
order
=
0
):
"""Sample a one-dimensional Gaussian function of scale s."""
s
=
float
(
s
)
r
=
int
(
ceil
(
3
*
s
))
size
=
2
*
r
+
1
W
=
zeros
(
size
)
# Sample the Gaussian function
W
=
array
([
f
(
x
-
r
,
s
)
for
x
in
xrange
(
size
)])
if
not
order
:
# Make sure that the sum of all kernel values is equal to one
W
/=
W
.
sum
()
return
W
def
filterNoise
(
image
,
s
):
'''Apply a gaussian blur to an image, to suppress noise.'''
filt
=
gauss1
(
s
)
image
=
convolve1d
(
image
.
data
,
filt
,
axis
=
0
,
mode
=
'nearest'
)
return
convolve1d
(
image
,
filt
,
axis
=
1
,
mode
=
'nearest'
)
src/GaussianFilter.py
0 → 100644
View file @
accab14c
from
GrayscaleImage
import
GrayscaleImage
from
scipy.ndimage
import
convolve1d
from
pylab
import
ceil
,
zeros
,
pi
,
e
,
exp
,
sqrt
,
array
class
GaussianFilter
:
def
__init__
(
self
,
scale
):
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
)
def
get_1d_gaussian_kernel
(
self
):
'''Sample a one-dimensional Gaussian function of scale s'''
radius
=
int
(
ceil
(
3
*
self
.
scale
))
size
=
2
*
radius
+
1
result
=
zeros
(
size
)
# Sample the Gaussian function
result
=
array
([
self
.
gaussian
(
x
-
radius
)
for
x
in
xrange
(
size
)])
# The sum of all kernel values is equal to one
result
/=
result
.
sum
()
return
result
def
get_filtered_copy
(
self
,
image
):
'''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'
))
def
get_scale
(
self
):
return
self
.
scale
def
set_scale
(
self
,
scale
):
self
.
scale
=
float
(
scale
)
scale
=
property
(
get_scale
,
set_scale
)
\ No newline at end of file
src/
FilterNoise
Test.py
→
src/
GaussianFilter
Test.py
View file @
accab14c
from
FilterNoise
import
filterNoise
from
FilterNoise
import
GaussianFilter
from
GrayscaleImage
import
GrayscaleImage
# Get the image
image
=
GrayscaleImage
(
'../images/plate.png'
)
output_image
=
filterNoise
(
image
,
1.4
)
filter
=
GaussianFilter
(
1.4
)
output_image
=
filter
.
get_filtered_copy
(
image
)
# Show the licenseplate
output_image
=
GrayscaleImage
(
None
,
output_image
)
output_image
.
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