例程讲解-04-median_filter中点滤波
# 中点滤波例程
#
# 这个例子显示了中点过滤。中点滤波用NxN邻域的最小和最大像素值的平均值代替每个像
# 素。
import sensor, image, time
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
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.
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
# size 是内核的大小。取1 (3x3 内核)、2 (5x5 内核)或更高值。
# bias 控制图像混合的最小/最大程度。0只适用于最小滤波,1仅用于最大滤波。您可以
# 通过对图像进行最小/最大化过滤。
img.midpoint(1, bias=0.5)
print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
# connected to your computer. The FPS should increase once disconnected.