Commit b7693df1 authored by João Porto's avatar João Porto

correcao de erros na esxtracao de atributos

parent 53374536
opencv-python==3.4.5.20
python-dateutil==2.5.0
matplotlib==2.0.2
matplotlib
scipy
pandas
sympy
......
......@@ -258,20 +258,19 @@ class FeatureExtractor(object):
"""
arff = open(output_file, 'wb')
arff.write("%s %s\n\n" % ('@relation', relation))
arff.write(bytes(str("%s %s\n\n" % ('@relation', relation)), 'utf-8'))
for label, t in zip(labels, types):
arff.write("%s %s %s\n" % ('@attribute', label, t))
arff.write("%s %s {%s}\n\n" % ('@attribute', 'classe', ', '.join(classes)))
arff.write(bytes(str("%s %s %s\n" % ('@attribute', label, t)), 'utf-8'))
arff.write(bytes(str("%s %s {%s}\n\n" % ('@attribute', 'classe', ', '.join(classes))), 'utf-8'))
arff.write('@data\n\n')
arff.write(bytes(str('@data\n\n'), 'utf-8'))
for instance in data:
instance = map(str, instance)
line = ",".join(instance)
arff.write(line + "\n")
arff.write(bytes(str(line + "\n"), 'utf-8'))
arff.close()
......
......@@ -104,10 +104,9 @@ class HuMoments(Extractor):
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
values_hu= cv2.HuMoments(cv2.moments(image)).flatten()
values_hu= np.nan_to_num(values_hu)
values_hu = list(values_hu)
values_hu= np.nan_to_num(values_hu)
labels_hu = [m+n for m,n in zip(['Hu_'] * len(values_hu),map(str,range(0,len(values_hu))))]
labels = labels_hu
......
......@@ -1130,7 +1130,7 @@ class Act(object):
if(file.endswith('.jpeg') or file.endswith('.tif') or file.endswith('.jpg') or file.endswith('.png')):##(-f)
#leitura dos arquivos de imagem na pasta original
arquivo=os.path.join(pog, file)
imgog=cv2.imread(arquivo)
imgog=cv2.imread(arquivo,3)
self.tk.add_image(imgog, file)
LinhaOg,ColunaOg,_=imgog.shape
# Writer(path, width, height) para iniciar o geramento do xml
......@@ -1146,7 +1146,7 @@ class Act(object):
if (fileIO.startswith(file)): #verifica se eh o segmento desta imagem ou nao.
#leitura dos segmentos em seus diretorios
arquivo=os.path.join(pseg,fileIO)
imgseg=cv2.imread(arquivo)
imgseg=cv2.imread(arquivo,3)
LinhaSeg,ColunaSeg,_=imgseg.shape
l=0
#arraste do superpixel sobre a imagem original
......
......@@ -111,7 +111,7 @@ class Felzenszwalb(Segmenter, SkimageSegmenter):
"""
return self.get_list_segments_skimage()
def get_segment(self, px = 0, py = 0, idx_segment = None):
def get_segment(self, px = 0, py = 0, xml_file = None, name_segment = None, idx_segment = None):
"""Return a specified segment using a index or position in image.
Parameters
......@@ -120,6 +120,10 @@ class Felzenszwalb(Segmenter, SkimageSegmenter):
Segment point inside the image in x-axis.
py : integer, optional, default = 0
Segment point inside the image in y-axis.
xml_file : pascal_voc_writer file, optional, default = None
Variable used to create a .XML file for the current image.
name_segment : string, optional, default = None
Variable used to name the class of the selected segment for this image.
idx_segment : integer, optional, default = None
Index of segment returned by previous call of this method.
......@@ -129,12 +133,14 @@ class Felzenszwalb(Segmenter, SkimageSegmenter):
Rectangle encompassing the segment image.
size_segment : integer
Number of pixels of segment.
xml_file : pascal_voc_writer file
Finalized pascal_voc_writer file.
idx_segment : integer
Index of segment if found, -1 otherwise.
run_time : integer
Running time spent in milliseconds.
"""
return self.get_segment_skimage(px, py, idx_segment)
return self.get_segment_skimage(px, py, xml_file, name_segment, idx_segment)
def paint_segment(self, image, color, px = 0, py = 0, idx_segment = [], border = True, clear = False):
"""Paint a list of segments using a index or position in image.
......
......@@ -116,7 +116,7 @@ class Quickshift(Segmenter, SkimageSegmenter):
"""
return self.get_list_segments_skimage()
def get_segment(self, px = 0, py = 0, idx_segment = None):
def get_segment(self, px = 0, py = 0, xml_file = None, name_segment = None, idx_segment = None):
"""Return a specified segment using a index or position in image.
Parameters
......@@ -125,6 +125,10 @@ class Quickshift(Segmenter, SkimageSegmenter):
Segment point inside the image in x-axis.
py : integer, optional, default = 0
Segment point inside the image in y-axis.
xml_file : pascal_voc_writer file, optional, default = None
Variable used to create a .XML file for the current image.
name_segment : string, optional, default = None
Variable used to name the class of the selected segment for this image.
idx_segment : integer, optional, default = None
Index of segment returned by previous call of this method.
......@@ -134,12 +138,14 @@ class Quickshift(Segmenter, SkimageSegmenter):
Rectangle encompassing the segment image.
size_segment : integer
Number of pixels of segment.
xml_file : pascal_voc_writer file
Finalized pascal_voc_writer file.
idx_segment : integer
Index of segment if found, -1 otherwise.
run_time : integer
Running time spent in milliseconds.
"""
return self.get_segment_skimage(px, py, idx_segment)
return self.get_segment_skimage(px, py, xml_file, name_segment, idx_segment)
def paint_segment(self, image, color, px = 0, py = 0, idx_segment = [], border = True, clear = False):
"""Paint a list of segments using a index or position in image.
......
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