图像不同的降采样方式(模糊处理)

模糊处理在边沿检测和去噪声方面有较为广泛的应用。OpenCV中提供了4种模糊算法,列举如下:

  • average
  • median
  • gaussian
  • bilateral

 

而scipy中同样有几种方式,其本质上是没区别的。

我们先来看模糊算法的实现:

 

1.average

    import numpy
    import argparse
    import cv2

    image = cv2.imread('1.jpg')
    cv2.imshow("Original", image)

    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    cv2.imshow("Gray", gray)


    #[x,y] is the kernel for bluring
    #the large kernel becomes, the more blurred imag will appear
    #hstack is able to stack multiple images together
    #using simple mean to average
    blurred = numpy.hstack([
    cv2.blur(gray, (3,3)),
    cv2.blur(gray, (5,5)),
    cv2.blur(gray, (7,7))])

    #display two images in a figure
    cv2.imshow("Blurring by average", blurred)

    cv2.imwrite("1_blur_by_aver

你可能感兴趣的:(图像处理,OpenCV)