利用拉普拉斯算子进行图像的锐化

基于OpenMV平台进行开发

程序结构的主要特点:

1.利用卷积运算

图像锐化的结果:

利用拉普拉斯算子进行图像的锐化_第1张图片

程序代码:

import sensor, image, time
 
  
kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
kernel = [-1, -1, -1,\
          -1, +9, -1,\
          -1, -1, -1]
# This is a sharpen filter kernel.
 
  
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(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.
    # Run the kernel on every pixel of the image.
    img.morph(kernel_size, kernel)
 
  

你可能感兴趣的:(OpenMV)