logo

有没有能获取图像的各rgb分量图像的函数

2022-11-23 19:09
6
cptb

达到类似于这样的功能

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor, image, time

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
         
img = sensor.snapshot()         # Take a picture and return the image.
img.save("hah.bmp")

for j in range(120):
    for i in range(160):
        (r,g,b) = img.get_pixel(i,j)
        img.set_pixel(i,j,(0,0,b))
        
sensor.flush()                                              
time.sleep_ms(100)
438aea78-1975-4fad-a7ea-0417ac9067fe.jpg
2022-11-24 19:24
I
网红小智智 星瞳科技

img.to_grayscale(rgb_channel=2)

这样新的灰度图就是蓝色分量。