例程讲解-03-grayscale_bilateral_filter灰度图双边滤波
# 灰度滤波例程
# 此示例显示如何从图像中删除明亮的灯光。
# 您可以使用带有“zero =”参数的binary()方法执行此操作。
# 从图像中删除明亮的光线允许您在图像上使用histeq(),
# 而不会使图像的过饱和部分的异常值破坏算法...
import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.RGB565
sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.
clock = time.clock() # Tracks FPS.
thresholds = (220, 255)
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot().binary([thresholds], invert=False, zero=True)
print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
# connected to your computer. The FPS should increase once disconnected.
原图:
运行效果图: