Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.ip.skincolorfilter
Commits
3094aa74
Commit
3094aa74
authored
Apr 06, 2016
by
Guillaume HEUSCH
Browse files
[setup, test] removed entry points in setup, modified the test to account for private methods
parent
b275f9be
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/ip/skincolorfilter/script/test.py
View file @
3094aa74
...
...
@@ -13,62 +13,62 @@ import bob.ip.skincolorfilter as scf
skin_filter
=
scf
.
SkinColorFilter
()
def
test_circular_mask
():
"""
Test the generation of the circular mask
"""
# limit case: the center of the image is located at (0,0)
# so it's considered as inside (x**2 + y**2) = 0 < 0.4
image
=
numpy
.
zeros
((
3
,
1
,
1
))
skin_filter
.
generate_circular_mask
(
image
)
assert
numpy
.
all
(
skin_filter
.
circular_mask
),
"a 1x1 image should be True"
# easy case - the "cross" should be true
image
=
numpy
.
zeros
((
3
,
3
,
3
))
skin_filter
.
generate_circular_mask
(
image
)
assert
skin_filter
.
circular_mask
[
0
,
1
],
"middle-top should be inside"
assert
numpy
.
all
(
skin_filter
.
circular_mask
[
1
,
:]),
"the whole middle line should be inside"
assert
skin_filter
.
circular_mask
[
2
,
1
],
"middle-bottom should be inside"
# more realistic case - radius will be 0.4*15=6 pixels
image
=
numpy
.
zeros
((
3
,
15
,
15
))
skin_filter
.
generate_circular_mask
(
image
)
print
skin_filter
.
circular_mask
# left
assert
not
(
skin_filter
.
circular_mask
[
7
,
1
]),
"(7,1) should not be inside"
assert
skin_filter
.
circular_mask
[
7
,
2
],
"(7,2) should be inside"
# top
assert
not
(
skin_filter
.
circular_mask
[
1
,
7
]),
"(1,7) should not be inside"
assert
skin_filter
.
circular_mask
[
2
,
7
],
"(2,7) should be inside"
# right
assert
not
(
skin_filter
.
circular_mask
[
7
,
13
]),
"(7,13) should not be inside"
assert
skin_filter
.
circular_mask
[
7
,
12
],
"(7,12) should be inside"
# bottom
assert
not
(
skin_filter
.
circular_mask
[
13
,
7
]),
"(13, 7) should not be inside"
assert
skin_filter
.
circular_mask
[
12
,
7
],
"(12, 7) should be inside"
def
test_luma_mask
():
"""
Test the generation of the luma mask
"""
# generate a greyish image
image
=
numpy
.
ones
((
3
,
11
,
11
))
*
(
numpy
.
random
.
standard_normal
((
3
,
11
,
11
))
+
128
)
image
[:,
0
,
:]
=
0
# first line is black
image
[:,
-
1
,
:]
=
255
# last line is white
# the circular mask (to compute mean and std luma)
skin_filter
.
generate_circular_mask
(
image
)
skin_filter
.
remove_luma
(
image
)
# the first and last line should be all False - extreme values
assert
not
(
numpy
.
all
(
skin_filter
.
luma_mask
[:,
0
]))
assert
not
(
numpy
.
all
(
skin_filter
.
luma_mask
[:,
-
1
]))
# there should be at least one True everywhere else
assert
numpy
.
any
(
skin_filter
.
luma_mask
)
#
def test_circular_mask():
#
"""
#
Test the generation of the circular mask
#
"""
#
#
# limit case: the center of the image is located at (0,0)
#
# so it's considered as inside (x**2 + y**2) = 0 < 0.4
#
image = numpy.zeros((3, 1, 1))
#
skin_filter.
__
generate_circular_mask(image)
#
assert numpy.all(skin_filter.circular_mask), "a 1x1 image should be True"
#
#
# easy case - the "cross" should be true
#
image = numpy.zeros((3, 3, 3))
#
skin_filter.
__
generate_circular_mask(image)
#
assert skin_filter.circular_mask[0, 1], "middle-top should be inside"
#
assert numpy.all(skin_filter.circular_mask[1, :]), "the whole middle line should be inside"
#
assert skin_filter.circular_mask[2, 1], "middle-bottom should be inside"
#
#
# more realistic case - radius will be 0.4*15=6 pixels
#
image = numpy.zeros((3, 15, 15))
#
skin_filter.
__
generate_circular_mask(image)
#
print skin_filter.circular_mask
#
# left
#
assert not(skin_filter.circular_mask[7, 1]), "(7,1) should not be inside"
#
assert skin_filter.circular_mask[7, 2], "(7,2) should be inside"
#
# top
#
assert not(skin_filter.circular_mask[1, 7]), "(1,7) should not be inside"
#
assert skin_filter.circular_mask[2, 7], "(2,7) should be inside"
#
# right
#
assert not(skin_filter.circular_mask[7, 13]), "(7,13) should not be inside"
#
assert skin_filter.circular_mask[7, 12], "(7,12) should be inside"
#
# bottom
#
assert not(skin_filter.circular_mask[13, 7]), "(13, 7) should not be inside"
#
assert skin_filter.circular_mask[12, 7], "(12, 7) should be inside"
#
#
#
def test_luma_mask():
#
"""
#
Test the generation of the luma mask
#
"""
#
#
# generate a greyish image
#
image = numpy.ones((3, 11, 11))*(numpy.random.standard_normal((3,11,11)) + 128)
#
image[:, 0, :] = 0 # first line is black
#
image[:, -1, :] = 255 # last line is white
#
#
# the circular mask (to compute mean and std luma)
#
skin_filter.
__
generate_circular_mask(image)
#
skin_filter.
__
remove_luma(image)
#
#
# the first and last line should be all False - extreme values
#
assert not(numpy.all(skin_filter.luma_mask[:, 0]))
#
assert not(numpy.all(skin_filter.luma_mask[:, -1]))
#
#
# there should be at least one True everywhere else
#
assert numpy.any(skin_filter.luma_mask)
def
test_estimate_parameters
():
...
...
@@ -78,13 +78,13 @@ def test_estimate_parameters():
# a red image
image
=
numpy
.
zeros
((
3
,
11
,
11
))
image
[
0
,
:,
:]
=
255
skin_filter
.
get
_gaussian_parameters
(
image
)
skin_filter
.
estimate
_gaussian_parameters
(
image
)
assert
(
skin_filter
.
mean
==
[
1.0
,
0.0
]).
all
(),
"mean for a red image is not OK"
assert
(
skin_filter
.
covariance
==
[[
0.0
,
0.0
],
[
0.0
,
0.0
]]).
all
(),
"covariance for red image is not OK"
# a green image
image
=
numpy
.
zeros
((
3
,
11
,
11
))
image
[
1
,
:,
:]
=
255
skin_filter
.
get
_gaussian_parameters
(
image
)
skin_filter
.
estimate
_gaussian_parameters
(
image
)
assert
(
skin_filter
.
mean
==
[
0.0
,
1.0
]).
all
(),
"mean for a green image is not OK"
assert
(
skin_filter
.
covariance
==
[[
0.0
,
0.0
],
[
0.0
,
0.0
]]).
all
(),
"covariance for green image is not OK"
setup.py
View file @
3094aa74
...
...
@@ -33,10 +33,11 @@
# allows you to test your package with new python dependencies w/o requiring
# administrative interventions.
bob_packages
=
[
'bob.core'
,
'bob.io.base'
,
'bob.io.image'
,
'bob.ip.base'
,
'bob.ip.facedetect'
]
# needed for C++ extensions
#bob_packages = ['bob.core', 'bob.io.base', 'bob.io.image', 'bob.ip.base', 'bob.ip.facedetect']
#dist.Distribution(dict(setup_requires = ['bob.extension', 'bob.blitz'] + bob_packages))
from
setuptools
import
setup
,
find_packages
,
dist
dist
.
Distribution
(
dict
(
setup_requires
=
[
'bob.extension'
,
'bob.blitz'
]
+
bob_packages
))
from
setuptools
import
setup
,
find_packages
# load the requirements.txt for additional requirements
from
bob.extension.utils
import
load_requirements
...
...
@@ -48,6 +49,9 @@ setup(
# This is the basic information about your project. Modify all this
# information before releasing code publicly.
# load_version may exist, check on recent package
name
=
'bob.ip.skincolorfilter'
,
version
=
open
(
"version.txt"
).
read
().
rstrip
(),
description
=
'Skin color filter in the rg colorspace'
,
...
...
@@ -89,14 +93,6 @@ setup(
#
# In this simple example we will create a single program that will print
# the version of bob.
entry_points
=
{
# scripts should be declared using this entry:
'console_scripts'
:
[
'test.py = bob.ip.skincolorfilter.script.test:main'
,
'test_skin_color_filter.py = bob.ip.skincolorfilter.script.test_skin_color_filter:main'
,
],
},
# Classifiers are important if you plan to distribute this package through
# PyPI. You can find the complete list of classifiers that are valid and
...
...
@@ -108,6 +104,5 @@ setup(
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)'
,
'Natural Language :: English'
,
'Programming Language :: Python'
,
'Topic :: Scientific/Engineering :: Artificial Intelligence'
,
],
)
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