File: graph_smoothing.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 (20 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import vigra
from vigra import graphs

# parameter:
filepath = '12003.jpg'   # input image path
sigmaGradMag = 2.0       # sigma Gaussian gradient
superpixelDiameter = 10  # super-pixel size
slicWeight = 10.0        # SLIC color - spatial weight
gamma = 0.15             # exp(-gamma * edgeIndicator)
edgeThreshold = 2.5      # values higher are considered as edges
scale = 1.0              # how much smoothing
iterations = 10          # how man smoothing iterations

# load image and convert to LAB
img = vigra.impex.readImage(filepath)

res = vigra.filters.nonlinearDiffusion(img, 1.9, 20.0)

vigra.imshow(res)
vigra.show()