Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
d4b91b83
Commit
d4b91b83
authored
May 07, 2019
by
Gu Wang
Browse files
test bgr2hls
parent
a092de34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
tests/test_image.py
tests/test_image.py
+31
-0
No files found.
tests/test_image.py
View file @
d4b91b83
...
...
@@ -110,6 +110,37 @@ class TestImage(object):
computed_hsv
[
i
,
j
,
:]
=
[
h
,
s
,
v
]
assert_array_almost_equal
(
out_img
,
computed_hsv
,
decimal
=
2
)
def
test_bgr2hls
(
self
):
in_img
=
np
.
random
.
rand
(
10
,
10
,
3
).
astype
(
np
.
float32
)
out_img
=
mmcv
.
bgr2hls
(
in_img
)
argmax
=
in_img
.
argmax
(
axis
=
2
)
computed_hls
=
np
.
empty_like
(
in_img
,
dtype
=
in_img
.
dtype
)
for
i
in
range
(
in_img
.
shape
[
0
]):
for
j
in
range
(
in_img
.
shape
[
1
]):
b
=
in_img
[
i
,
j
,
0
]
g
=
in_img
[
i
,
j
,
1
]
r
=
in_img
[
i
,
j
,
2
]
maxc
=
max
(
r
,
g
,
b
)
minc
=
min
(
r
,
g
,
b
)
_l
=
(
minc
+
maxc
)
/
2.0
if
minc
==
maxc
:
h
=
0.0
s
=
0.0
if
_l
<=
0.5
:
s
=
(
maxc
-
minc
)
/
(
maxc
+
minc
)
else
:
s
=
(
maxc
-
minc
)
/
(
2.0
-
maxc
-
minc
)
if
argmax
[
i
,
j
]
==
2
:
h
=
60
*
(
g
-
b
)
/
(
maxc
-
minc
)
elif
argmax
[
i
,
j
]
==
1
:
h
=
60
*
(
2.0
+
(
b
-
r
)
/
(
maxc
-
minc
))
else
:
h
=
60
*
(
4.0
+
(
r
-
g
)
/
(
maxc
-
minc
))
if
h
<
0
:
h
+=
360
computed_hls
[
i
,
j
,
:]
=
[
h
,
_l
,
s
]
assert_array_almost_equal
(
out_img
,
computed_hls
,
decimal
=
2
)
def
test_imresize
(
self
):
resized_img
=
mmcv
.
imresize
(
self
.
img
,
(
1000
,
600
))
assert
resized_img
.
shape
==
(
600
,
1000
,
3
)
...
...
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