Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
inovisao
pynovisao
Commits
65892d88
Commit
65892d88
authored
Aug 21, 2018
by
Diego André Sant'Ana
🤞
Browse files
Ajustado HuMoments
parent
70b464e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
src/extraction/image_moments.py
src/extraction/image_moments.py
+21
-4
No files found.
src/extraction/image_moments.py
View file @
65892d88
...
...
@@ -8,10 +8,14 @@
Name: image_moments.py
Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
Alter method HuMoments
"""
from
skimage
import
measure
import
cv2
from
util.utils
import
ImageUtils
from
skimage.measure
import
regionprops
,
moments
,
moments_central
from
skimage.morphology
import
label
from
extractor
import
Extractor
...
...
@@ -37,6 +41,9 @@ class RawCentralMoments(Extractor):
features : tuple
Returns a tuple containing a list of labels, type and values for each feature extracted.
"""
#raw_moments = moments(image)
image_binary
=
ImageUtils
.
image_binary
(
image
,
bgr
=
True
)
m
=
measure
.
moments
(
image_binary
)
...
...
@@ -79,7 +86,8 @@ class HuMoments(Extractor):
features : tuple
Returns a tuple containing a list of labels, type and values for each feature extracted.
"""
image_binary
=
ImageUtils
.
image_binary
(
image
,
bgr
=
True
)
"""image_binary = ImageUtils.image_binary(image, bgr = True)
m = measure.moments(image_binary)
...
...
@@ -91,12 +99,21 @@ class HuMoments(Extractor):
nu = measure.moments_normalized(mu)
hu = measure.moments_hu(nu)
values_hu
=
list
(
hu
)
values_hu = list(hu)"""
image
=
cv2
.
cvtColor
(
image
,
cv2
.
COLOR_BGR2GRAY
)
values_hu
=
cv2
.
HuMoments
(
cv2
.
moments
(
image
)).
flatten
()
labels_hu
=
[
m
+
n
for
m
,
n
in
zip
([
'Hu_'
]
*
len
(
values_hu
),
map
(
str
,
range
(
0
,
len
(
values_hu
))))]
labels
=
labels_hu
types
=
[
Extractor
.
NUMERIC
]
*
len
(
labels
)
values
=
values_hu
return
labels
,
types
,
values
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