Commit 65892d88 authored by Diego André Sant'Ana's avatar Diego André Sant'Ana 🤞

Ajustado HuMoments

parent 70b464e4
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment