Example: 02-Image-Processing/01-Image-Filters/erode_and_dilate.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 腐蚀和膨胀示例
#
# 此示例展示了腐蚀和膨胀功能的应用,您可以在
# 二值图像上运行这些功能以去除噪声。此示例最初是一个测试,但它
# 对于展示这些功能的工作原理非常有用。

import sensor

sensor.reset()
sensor.set_framesize(sensor.QVGA)

grayscale_thres = (170, 255)
rgb565_thres = (70, 100, -128, 127, -128, 127)

while True:
    sensor.set_pixformat(sensor.GRAYSCALE)
    for i in range(20):
        img = sensor.snapshot()
        img.binary([grayscale_thres])
        img.erode(2)
    for i in range(20):
        img = sensor.snapshot()
        img.binary([grayscale_thres])
        img.dilate(2)

    sensor.set_pixformat(sensor.RGB565)
    for i in range(20):
        img = sensor.snapshot()
        img.binary([rgb565_thres])
        img.erode(2)
    for i in range(20):
        img = sensor.snapshot()
        img.binary([rgb565_thres])
        img.dilate(2)

results matching ""

    No results matching ""