|
本帖最后由 vany5921 于 2020-3-23 16:37 编辑
[mw_shl_code=python,true]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)[/mw_shl_code]
2.重设图片大小
[mw_shl_code=python,true]
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)[/mw_shl_code]
3.中间值滤波
[mw_shl_code=python,true]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)[/mw_shl_code]
4.gamma矫正
[mw_shl_code=python,true]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)[/mw_shl_code]
5.腐蚀消除相近颜色线条
[mw_shl_code=python,true]
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)[/mw_shl_code]
6.消除亮度
[mw_shl_code=python,true]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)[/mw_shl_code]
7.拉普拉斯滤波锐化
[mw_shl_code=python,true]
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)[/mw_shl_code]
8.彩虹色阶
[mw_shl_code=python,true]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) [/mw_shl_code]
|
|