コード例 #1
0
ファイル: extractor.py プロジェクト: jamiehenson/SeePlay
def morph():
    mf = MorphologyFeatureExtractor() 
    mf.setThresholdOperation(myBinaryFunc)
    a = np.array(mf.extract(watchman.imgbank[0])) 

    if len(watchman.imgbank) > 1:
        b = np.array(mf.extract(watchman.imgbank[1])) 
    else:
        b = np.array(mf.extract(watchman.imgbank[0])) 

    AandB = np.sum(np.square(a-b)) 
    return AandB
コード例 #2
0
def morph():
    mf = MorphologyFeatureExtractor()
    mf.setThresholdOperation(myBinaryFunc)
    a = np.array(mf.extract(watchman.imgbank[0]))

    if len(watchman.imgbank) > 1:
        b = np.array(mf.extract(watchman.imgbank[1]))
    else:
        b = np.array(mf.extract(watchman.imgbank[0]))

    AandB = np.sum(np.square(a - b))
    return AandB
コード例 #3
0
def feature_extractor():

    #Abrir arquivo que vai receber as features dos arquivos de imagens
    file = "image_features_train_20_10_1_Novo4.arff"
    text_file = open(file, "a")
    trainPath = "C:/Python27/ARP/Dataset/train5"
    dirList = os.listdir(trainPath)
    edge = EdgeHistogramFeatureExtractor(20)
    for dirName in dirList:
        fileList = os.listdir(trainPath + '/' + dirName)
        maxsize = len(fileList)
        for i in range(0, maxsize):
            #print fileList[i]
            filePATH = (trainPath + '/' + dirName + '/' + fileList[i])
            img = Image(filePATH)
            #Feature - Edge histogram
            edge_vecs = edge.extract(img)
            edge_fields = edge.getFieldNames()
            for y in range(0, edge.getNumFields()):
                #print edge_fields[y], '=', edge_vecs[y]
                text_file.write(str(edge_vecs[y]) + ",")
            #Feature - Hue
            hue = HueHistogramFeatureExtractor(10)
            hue_vecs = hue.extract(img)
            hue_fields = hue.getFieldNames()
            for i in range(0, hue.getNumFields()):
                #		#print hue_fields[i], '=', hue_vecs[i]
                text_file.write(str(hue_vecs[i]) + ",")
            Morph1 = MorphologyFeatureExtractor()
            Morph2 = Morph1.extract(img)
            text_file.write(str(Morph2) + ",")
            text_file.write(dirName + "\n")
    text_file.close()
コード例 #4
0
			for i in range(0, hue.getNumFields()):
				print hue_fields[i], '=', hue_vecs[i]
				text_file.write(str(hue_vecs[i]) + ",")
    #Feature - Haar
    #haar = HaarLikeFeatureExtractor(fname='haar.txt')
    #haar_vecs = haar.extract(img)
    #haar_fields = haar.getFieldNames()
    #for i in range(0, len(haar_fields)):
    #    print haar_fields[i], '=', haar_vecs[i]
    #    text_file.write(str(haar_vecs[i]) + ",")
    text_file.write("revolver")
    text_file.close()
"""
#Criando o header do arquivo ARFF de features	
#var1 = gerador_Header()

#Gerando e gravando as features no arquivo ARFF
#var2 = feature_extractor()

"""	
#classes = ['pistola_gray','revolver_gray',]
"""
img = Image('revolver.jpg')
feature = MorphologyFeatureExtractor()
array = feature.extract(img)
print (array)


	
#text_file.write("revolver")
#text_file.close()