Exemplo n.º 1
0
 def img_classify(self, img):
     kernel = np.ones((5, 5), np.uint8)
     thresh = l32.peakPick(img)
     img_bin = abs(l32.threshold(img, 127) -
                   1)  # Given this set of data we need to flip the values
     img_props = np.array([l42.getproperties(img_bin)], dtype=np.float32)
     prediction = self.svm.predict(img_props)
     return prediction
Exemplo n.º 2
0
 def addTrainSamples(self, folder):
     kernel = np.ones((5, 5), np.uint8)
     class_key = 0
     for c in self.classes:
         for i in range(1, c[1] + 1):
             filename = folder + '/' + c[0] + str(i) + '.jpg'
             print(filename)
             img = l25.loadImage(filename, 0)
             thresh = l32.peakPick(img)
             img_bin = abs(
                 l32.threshold(img, 127) -
                 1)  # Given this set of data we need to flip the values
             # 				plt.imshow(img_bin, cmap='hot', interpolation='nearest')
             # 				plt.show()
             img_props = np.array([l42.getproperties(img_bin)],
                                  dtype=np.float32)
             if self.samples.size == 0:
                 self.samples = img_props
             else:
                 self.samples = np.append(self.samples, img_props, axis=0)
             self.samples_labels = np.append(
                 self.samples_labels, np.array([class_key], dtype=np.int))
         class_key += 1
     return