def processData(self, data): s = self.stateGroup.state() if s['direction'] == 'rising': d = 1 else: d = -1 return functions.threshold(data, s['threshold'], d)
def f3(self): if self.ld1: sav(imgtmp,functions.threshold(imgtmp)) self.ids.imgt.reload() self.set_stat("Listo") else: self.set_stat(upsall)
def slider_image_change(self, event): # wxGlade: main.<event_handler> id = self.slider_imagens.GetValue() path = globs[id] for child in self.panel_original.GetChildren(): child.Destroy() wx.StaticBitmap( self.panel_original, wx.ID_ANY, functions.genImage(path, *self.sizer_original.GetSize())) for child in self.panel_threshold.GetChildren(): child.Destroy() conf = [ self.slider_h.GetValue(), self.slider_s.GetValue(), self.slider_v.GetValue(), self.slider_h1.GetValue(), self.slider_s1.GetValue(), self.slider_v1.GetValue() ] wx.StaticBitmap( self.panel_threshold, wx.ID_ANY, functions.threshold(path, size=self.sizer_threshold.GetSize(), hsv=conf))
def set_function(self, func): if func.value == "threshold": try: t = int(func.sub_param_list[0].value) except KeyError: print "Failed to load threshold value!" f = functions.threshold(t) elif func.value == "indicator": try: t = int(func.sub_param_list[0].value) except KeyError: print "Failed to load threshold value!" f = functions.indicator(t) elif func.value == "biThreshold": try: kup = int(func.sub_param_list[0].value) kdown = int(func.sub_param_list[1].value) except KeyError: print "Failed to load threshold value!" f = functions.biThreshold(kup, kdown) elif func.value == "inverseThreshold": try: t = int(func.sub_param_list[0].value) except KeyError: print "Failed to load threshold value!" f = functions.inverseThreshold(t) elif func.value == "dynBiThreshold": try: D01up = int(func.sub_param_list[0].value) D10up = int(func.sub_param_list[1].value) D01down = int(func.sub_param_list[2].value) D10down = int(func.sub_param_list[3].value) except KeyError: print "Failed to load threshold value!" f = functions.dynBiThreshold(D01up, D10up, D01down, D10down) elif func.value == "wolfram": try: r = int(func.sub_param_list[0].value) except KeyError: print "Failed to load rule number!" f = functions.wolfram(r) elif func.value == "parity": f = functions.parity elif func.value == "majority": f = functions.majority elif func.value == "nor": f = functions.nor elif func.value == "nand": f = functions.nand else: raise Exception( """Error: Unknown function type! Available options: <threshold, indicator, biThreshold, inverseThreshold, dynBiThreshold, wolfram, parity, majority, nor, nand>""" ) return f
def maxima(img): height, width = img.shape img_auxiliar = np.copy(img) for j in range(0, height): for i in range(0, width): if img_auxiliar[j, i] > 0: img_auxiliar[j, i] = img_auxiliar[j, i] - 1 img_auxiliar = geodesic_dilation(img, img_auxiliar) img = img - img_auxiliar img = f.threshold(img, 1) return img
def remove_noise(image): image = fs.threshold(image) # 이미지 이진화 mask = np.zeros(image.shape, np.uint8) # 보표 영역만 추출하기 위해 마스크 생성 cnt, labels, stats, centroids = cv2.connectedComponentsWithStats( image) # 레이블링 for i in range(1, cnt): x, y, w, h, area = stats[i] if w > image.shape[1] * 0.5: # 보표 영역에만 cv2.rectangle(mask, (x, y, w, h), (255, 0, 0), -1) # 사각형 그리기 masked_image = cv2.bitwise_and(image, mask) # 보표 영역 추출 return masked_image