例程讲解-04-mode_adaptive_threshold_filter众数自适应阈值滤波

# 众数自适应阈值滤波示例。

# 此示例显示了使用自适应阈值处理的众数滤波。 当mode(threshold=True) 时,
# mode()方法通过比较像素周围的像素的众数减去偏移量来自适应阈值图像。
import sensor, image, time

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.RGB565
sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.
clock = time.clock() # Tracks FPS.

while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot() # Take a picture and return the image.

    # 众数过滤器的参数是内核大小,对于1x1,3x3或5x5内核,它可以分别为0,1或2。
    img.mode(1, threshold=True, offset=5, invert=True)

    print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
    # connected to your computer. The FPS should increase once disconnected.

原图:

运行效果图:

星瞳科技OpenMV官方中文文档函数讲解:

results matching ""

    No results matching ""