Example: 02-Image-Processing/01-Image-Filters/erode_and_dilate.py
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)