Example explanation-03-grayscale_bilateral_filter grayscale bilateral filtering

# 双边滤波例程
# 此示例显示了在灰度图像上使用双边滤波。

import sensor, image, time

sensor.reset() # 初始化sensor

sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.RGB565
#设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种

sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
#设置图像像素大小

sensor.skip_frames(time = 2000) # 让新的设置生效
clock = time.clock() # 跟踪FPS帧率

while(True):
    clock.tick() # 追踪两个snapshots()之间经过的毫秒数.
    img = sensor.snapshot() # 拍一张照片,返回图像

    # color_sigma controls how close color wise pixels have to be to each other to be
    # blured togheter. A smaller value means they have to be closer.
    # A larger value is less strict.
    # color_sigma控制颜色明智的像素之间必须有多近的距离才能模糊
    # 更小的值意味着它们必须更接近。
    # 较大的值不那么严格。

    # space_sigma controls how close space wise pixels have to be to each other to be
    # blured togheter. A smaller value means they have to be closer.
    # A larger value is less strict.
    # space_sigma控制将空间明智的像素彼此模糊的距离。
    # 更小的值意味着它们必须更接近。
    # 较大的值不那么严格。

    # Run the kernel on every pixel of the image.
    # 在图像的每个像素上运行核
    img.bilateral(3, color_sigma=0.1, space_sigma=1)

    # Note that the bilateral filter can introduce image defects if you set
    # color_sigma/space_sigma to aggresively. Increase the sigma values until
    # the defects go away if you see them.
    # 请注意,如果将color_sigma/space_sigma设置为聚合,双边过滤器可能会引入图像缺陷。
    # 如果你看到缺陷,增加sigma值直到缺陷消失。

    print(clock.fps()) # 注意: 当连接电脑后,OpenMV会变成一半的速度。当不连接电脑,帧率会增加。

Singtown Technology OpenMV official Chinese document function explanation:

results matching ""

    No results matching ""