File: blocking.py

package info (click to toggle)
libvigraimpex 1.11.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,356 kB
  • sloc: cpp: 57,785; python: 8,603; ansic: 1,798; makefile: 97; javascript: 65; sh: 50
file content (34 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from __future__ import print_function

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)))