0
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?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Aswathy
  • 37
  • 2
  • 3
  • 10
  • 1
    "blur radius 2" has no precise meaning. Maybe you want a Gaussian filter with parameter sigma=2 ? If true, a 5x5 neighborhood is not sufficient, you'll need 9x9 or 11x11. –  Dec 10 '14 at 11:23

1 Answers1

0

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

runDOSrun
  • 10,359
  • 7
  • 47
  • 57