使用“histogram.get_threhsold()”函数后怎么传给“ img.binary”
-
想使用OTSU算法,找到了“histogram.get_threhsold()”函数,但是在传参数的时候一直报错,希望大佬解救
-
如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片
-
import sensor, image, time,machine from pyb import LED sensor.reset() sensor.set_vflip(False) sensor.set_hmirror(False) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000. #sensor.set_windowing([0,20,80,40]) sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds clock = time.clock() # to process a frame sometimes. LED(1).on() LED(2).on() LED(3).on() while(True): clock.tick() img = sensor.snapshot().lens_corr(strength = 0.5, zoom = 1.0) #img=sensor.snapshot().save("lvbo_2.jpg") #获取图像 img.bilateral(3,color_sigma=0.1,space_sigma=0.1)#采用双边滤波 img.gaussian(3, unsharp=True,)#图像消除锐化 histogram = img.get_histogram() Thresholds = histogram.get_threshold() img.binary(threshold) print(Thresholds) #line = img.get_regression([(100,100,0,0,0,0)], robust = True) #if(line):img.draw_line(line.line(), color = 127) #print(clock.fps()
-
你可以试试这个:
Thresholds = histogram.get_threshold() l = Thresholds.l_value() a = Thresholds.a_value() b = Thresholds.b_value() print(Thresholds) img.binary([(0, l), (-128, a),(-128, b)])
-
@kidswong999 ok了!!! 完美的想哭, 我换成灰度图了