例程讲解-03-color_bilateral_filter彩图双边滤波
# 双边滤波例程
# 此示例显示了在彩色图像上使用双边滤波。
import sensor, image, time
sensor.reset() # 初始化sensor
sensor.set_pixformat(sensor.RGB565) # 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
# color_sigma控制彩色明智像素之间必须有多近的距离才能模糊。
# blured togheter. A smaller value means they have to be closer.
# 更小的值意味着它们必须更接近。
# A larger value is less strict.
# 较大的值不那么严格。
# space_sigma controls how close space wise pixels have to be to each other to be
# space_sigma控制空间智慧像素彼此之间必须有多近才能模糊
# blured togheter. A smaller value means they have to be closer.
# 更小的值意味着它们必须更接近。
# A larger value is less strict.
# 较大的值不那么严格。
# 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会变成一半的速度。当不连接电脑,帧率会增加。