Gaussian blur with two pixel radius

1.2k views Asked by At
import time
import picamera
import picamera.array
import cv2


with picamera.PiCamera() as camera:
with picamera.array.PiRGBArray(camera) as stream:
    camera.resolution = (320,240)
    while True:
        camera.capture(stream,'bgr',use_video_port=True)
        cv2.imshow('video',stream.array)
        gray = cv2.cvtColor(stream.array,cv2.COLOR_BGR2GRAY)
        cv2.imshow('grayimage',gray)
        med1 = cv2.medianBlur(gray,3)#median filtering
        cv2.imshow('median',med1)
        gbl= cv2.GaussianBlur(med1,(5,5),0)
        cv2.imshow('guassian',gb1)            
        if cv2.waitKey(1) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break
        stream.seek(0)
        stream.truncate()

I have been trying to do Gaussian blur on video output. In many sites I saw that a kernel size of 5x5 gives the appropriate result. I want to perform a blurring with blur radius 2. How can I confirm what the radius is of a kernel of size 5x5? Or is there any way to form a kernel that gives an output of blur radius 2?

1

There are 1 answers

0
runDOSrun On BEST ANSWER

A 5x5 matrix has radius 2. (2 pixels in each direction from center pixel (2,2)).

An NxN matrix (N odd) has radius (N-1)/2