コード例 #1
0
def gaussianBlur(image, filterSize=43, sigma=opencvFilt2sigma(43)):
    """Blur an image with a particular strength filter.
    Default is 43, 139 gives a very strong blur, but takes a while
    """

    # Carry out the filter operation
    cv.cvSmooth(image, image, cv.CV_GAUSSIAN, filterSize, 0, sigma)
    return image
コード例 #2
0
ファイル: blur_opencv.py プロジェクト: Foued70/pycam
def gaussianBlur(image, filterSize=43, sigma=opencvFilt2sigma(43)):
    """Blur an image with a particular strength filter.
    Default is 43, 139 gives a very strong blur, but takes a while
    """
    
    # Carry out the filter operation
    cv.cvSmooth(image, image, cv.CV_GAUSSIAN, filterSize, 0, sigma)
    return image
コード例 #3
0
def mlGaussianBlur(image):
    """Method using code from Sturla on the [email protected]"""
    img = array(image)
    sigma = opencvFilt2sigma(43.0)
    gain = gaussian2D(np.ones(image.shape[0:2]), sigma)  # corrects edges

    for i in range(3):
        img[:, :, i] = gaussian2D(img[:, :, i], sigma) / gain
    return img
コード例 #4
0
ファイル: blur_scipy.py プロジェクト: Foued70/pycam
def mlGaussianBlur(image):
    """Method using code from Sturla on the [email protected]"""
    img = array(image)
    sigma = opencvFilt2sigma(43.0)
    gain = gaussian2D(np.ones(image.shape[0:2]), sigma) # corrects edges
    
    for i in range(3):
       img[:,:,i] = gaussian2D(img[:,:,i], sigma) / gain
    return img
コード例 #5
0
ファイル: blur_scipy.py プロジェクト: Foued70/pycam
def gaussianBlur3Way(np_image, sigma=opencvFilt2sigma(43.0)):
    """Blur an image with scipy using 3 seperate gaussian filters
    This is exactly equivalent to the above function"""
    
    r = ndimage.filters.gaussian_filter(np_image[:,:,0], sigma=(sigma, sigma))
    g = ndimage.filters.gaussian_filter(np_image[:,:,1], sigma=(sigma, sigma))
    b = ndimage.filters.gaussian_filter(np_image[:,:,2], sigma=(sigma, sigma))

    return array([r,g,b]).transpose((1,2,0))
コード例 #6
0
def gaussianBlur3Way(np_image, sigma=opencvFilt2sigma(43.0)):
    """Blur an image with scipy using 3 seperate gaussian filters
    This is exactly equivalent to the above function"""

    r = ndimage.filters.gaussian_filter(np_image[:, :, 0],
                                        sigma=(sigma, sigma))
    g = ndimage.filters.gaussian_filter(np_image[:, :, 1],
                                        sigma=(sigma, sigma))
    b = ndimage.filters.gaussian_filter(np_image[:, :, 2],
                                        sigma=(sigma, sigma))

    return array([r, g, b]).transpose((1, 2, 0))
コード例 #7
0
@scipyFromOpenCV
def mlGaussianBlur(image):
    """Method using code from Sturla on the [email protected]"""
    img = array(image)
    sigma = opencvFilt2sigma(43.0)
    gain = gaussian2D(np.ones(image.shape[0:2]), sigma)  # corrects edges

    for i in range(3):
        img[:, :, i] = gaussian2D(img[:, :, i], sigma) / gain
    return img


########

sigma = opencvFilt2sigma(43.0)


@scipyFromOpenCV
def gaussianBlur(np_image):
    """Blur an image with scipy"""

    result = ndimage.filters.gaussian_filter(np_image,
                                             sigma=(sigma, sigma, 0),
                                             order=0,
                                             mode='reflect')
    return result


def testGaussianBlur():
    """Test that the guassian blur function gives the exact same output
コード例 #8
0
ファイル: blur_scipy.py プロジェクト: Foued70/pycam
   return tmp[:n,:m]
   

@scipyFromOpenCV
def mlGaussianBlur(image):
    """Method using code from Sturla on the [email protected]"""
    img = array(image)
    sigma = opencvFilt2sigma(43.0)
    gain = gaussian2D(np.ones(image.shape[0:2]), sigma) # corrects edges
    
    for i in range(3):
       img[:,:,i] = gaussian2D(img[:,:,i], sigma) / gain
    return img
########

sigma = opencvFilt2sigma(43.0)

@scipyFromOpenCV
def gaussianBlur(np_image):
    """Blur an image with scipy"""
    
    
    result = ndimage.filters.gaussian_filter(np_image, 
                            sigma=(sigma, sigma, 0),
                            order=0,
                            mode='reflect'
                            )
    return result

def testGaussianBlur():
    """Test that the guassian blur function gives the exact same output