erode_and_dilate.py

# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2023 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 収縮・膨張の例
#
# この例では、二値画像のノイズ除去に使える収縮(erode)・膨張(dilate)関数を
# 示します。この例は元々テスト用でしたが、これらの関数がどう動作するかを
# 示すのに役立ちます。

import csi

csi0 = csi.CSI()
csi0.reset()
csi0.framesize(csi.QVGA)

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

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

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

results matching ""

    No results matching ""