例程讲解-04-mean_filter均值滤波

本例程为04-image-Filters-mean_filter.py
本例程的目的是对图像进行均值滤波,使图像达到模糊的效果,均值滤波是最快的滤波。

# Mean Filter Example
#
# This example shows off mean filtering. Mean filtering is your standard average
# filter in a NxN neighborhood. Mean filtering removes noise in the image by
# bluring everything. But, it's the fastest kernel filter operation.

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(10) # 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.

    # The only argument is the kernel size. N coresponds to a ((N*2)+1)^2
    # kernel size. E.g. 1 == 3x3 kernel, 2 == 5x5 kernel, etc. Note: You
    # shouldn't ever need to use a value bigger than 2.
    img.mean(1)
    #image.mean(size),size为核的大小,size=1则是3x3的核,size=2则是5x5的核

    print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
    # connected to your computer. The FPS should increase once disconnected.

原图:

均值滤波后:

星瞳科技OpenMV官方中文文档函数讲解:

results matching ""

    No results matching ""