M5StickV参考示例3-Arduino中文社区 - Powered by Discuz! Archiver

vany5921 发表于 2020-3-23 16:05

M5StickV参考示例3

本帖最后由 vany5921 于 2020-3-23 16:37 编辑

1.获取补色图像
lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:

    img = sensor.snapshot()
#颜色反转
    img.negate()

    lcd.display(img)


2.重设图片大小

import lcd
import sensor

lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    resized_img = img.resize(lcd.width(), lcd.height())
    lcd.display(resized_img)

3.中间值滤波
import lcd
import sensor
lcd.init()
lcd.direction(lcd.YX_LRUD)

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    img.midpoint(1, bias = 1.0)
    lcd.display(img)


4.gamma矫正
import lcd
import sensor

lcd.init()
lcd.direction(lcd.YX_LRUD)

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    img.gamma_corr(gamma = 1.5, contrast = 1.0, brightness = 0.0)
    lcd.display(img)

5.腐蚀消除相近颜色线条

import lcd
import sensor
lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    img.erode(1)
    lcd.display(img)


6.消除亮度
import lcd
import sensor

lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    img.illuminvar()
    lcd.display(img)


7.拉普拉斯滤波锐化

import lcd
import sensor
lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img = sensor.snapshot()
    img.laplacian(1)
    lcd.display(img)

8.彩虹色阶
import lcd
import sensor
lcd.init()
lcd.direction(lcd.YX_LRUD)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
while True:
    img = sensor.snapshot()
    img.to_rainbow()
    lcd.display(img)
页: [1]
查看完整版本: M5StickV参考示例3