Ejemplo n.º 1
0
def augmentGaussian(data, lAdd, gAdd, gMult):
    """
        lAdd : sigma of local additive gaussian noise
        gAdd : sigma of global additive gaussian noise
        gMult : sigma of global multiplicative guasian noise
    """
    data = vigra.taggedView(data, 'xyz')
    shape = data.shape

    # local and global additive and multiplicative
    # gaussian noise
    toAdd = normalVol(shape, 0.0, lAdd) + numpy.random.normal(0.0, gAdd)
    augmentedData = data.copy()
    augmentedData += toAdd
    augmentedData *= numpy.abs(numpy.random.normal(1.0, gMult))
    augmentedData = numpy.clip(augmentedData, 0, 255)

    return augmentedData
Ejemplo n.º 2
0
from vigra import blockwise as bw




numpy.random.seed(42)

# input
shape = (500, 500, 500)

data = numpy.random.rand(*shape).astype('float32')

print "make options object"
options = bw.BlockwiseConvolutionOptions3D()
print type(options)

sigma = 1.0
options.stdDev = (sigma, )*3
options.blockShape = (128, )*3

print "stddev",options.stdDev
print "call blockwise filter"

with vigra.Timer("AllThread"):
	res = bw.gaussianSmooth(data, options)
with vigra.Timer("1thread"):
	resRef = vigra.gaussianSmoothing(data, sigma)


print numpy.sum(numpy.abs(res-resRef))
Ejemplo n.º 3
0
import vigra
from vigra import graphs
from vigra import numpy
from vigra import Timer
from vigra import blockwise as bw

numpy.random.seed(42)

# input
shape = (500, 500, 500)

data = numpy.random.rand(*shape).astype('float32')

print "make options object"
options = bw.BlockwiseConvolutionOptions3D()
print type(options)

sigma = 1.0
options.stdDev = (sigma, ) * 3
options.blockShape = (128, ) * 3

print "stddev", options.stdDev
print "call blockwise filter"

with vigra.Timer("AllThread"):
    res = bw.gaussianSmooth(data, options)
with vigra.Timer("1thread"):
    resRef = vigra.gaussianSmoothing(data, sigma)

print numpy.sum(numpy.abs(res - resRef))
Ejemplo n.º 4
0
Archivo: test3.py Proyecto: jfhci/vigra
def checkAboutSame(i1,i2):
    assert(i1.shape==i2.shape)
    difference=np.sum(np.abs(i1-i2))/float(np.size(i1))
    assert(difference<5)
Ejemplo n.º 5
0
def checkAboutSame(i1,i2):
    checkShape(i1.shape, i2.shape)
    difference=np.sum(np.abs(i1-i2))/float(np.size(i1))
    assert(difference<5)