def allPairsOfShortestPath(graph, weights): pathFinder = vigra.graphs.ShortestPathPathDijkstra(graph) distances = numpy.zeros([graph.nodeNum] * 2) for ni, node in enumerate(graph.nodeIter()): pathFinder.run(weights**1, node) d = pathFinder.distances()**1 distances[ni, :] = d[:] ggf = graph.projectNodeFeaturesToGridGraph(d) ggf = vigra.taggedView(ggf, 'xy') if ni < 1: vigra.imshow(ggf) vigra.show() print distances.min(), distances.max() return distances
# load image and convert to LAB img = vigra.impex.readImage(filepath) # get super-pixels with slic on LAB image imgLab = vigra.colors.transform_RGB2Lab(img) labels, nseg = vigra.analysis.slicSuperpixels(imgLab, slicWeight, superpixelDiameter) labels = vigra.analysis.labelImage(labels) # compute gradient imgLabBig = vigra.resize(imgLab, [imgLab.shape[0]*2-1, imgLab.shape[1]*2-1]) gradMag = vigra.filters.gaussianGradientMagnitude(imgLab, sigmaGradMag) gradMagBig = vigra.filters.gaussianGradientMagnitude(imgLabBig, sigmaGradMag*2.0) vigra.imshow(gradMagBig) vigra.show() # get 2D grid graph and edgeMap for grid graph # from gradMag of interpolated image gridGraph = graphs.gridGraph(img.shape[0:2]) gridGraphEdgeIndicator = graphs.edgeFeaturesFromInterpolatedImage(gridGraph, gradMagBig) # get region adjacency graph from super-pixel labels rag = graphs.regionAdjacencyGraph(gridGraph, labels) # accumulate edge and ndie weights from gradient magnitude ragEdgeWeights = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) ragNodeWeights = rag.accumulateNodeFeatures(gradMag)
for i in range(nImages): gtImg = numpy.zeros(shape) gtImg[0:shape[0] / 2, :] = 1 gtImg[shape[0] / 4:3 * shape[0] / 4, shape[0] / 4:3 * shape[0] / 4] = 2 ra = numpy.random.randint(180) #print ra gtImg = vigra.sampling.rotateImageDegree(gtImg.astype(numpy.float32), int(ra), splineOrder=0) if i < 2: vigra.imshow(gtImg) vigra.show() img = gtImg + numpy.random.random(shape) * float(noise) if i < 2: vigra.imshow(img) vigra.show() imgs.append(img.astype('float32')) gts.append(gtImg) def getSelf(img): return img
patchSize = [50, 50] extractor = Extractor(raw=raw, seg=seg, gt=gt, patchSize=patchSize) sys.exit(0) seg = numpy.array(seg, dtype='uint32') #vigra.segShow(raw,seg) #vigra.show() tGrid = ncgp.TopologicalGrid2D(seg) numberOfCells = tGrid.numberOfCells fGrid = ncgp.FilledTopologicalGrid2D(tGrid) cell1Mask = numpy.clip(fGrid.cellMask([1, 1, 0]), 0, 1) vigra.imshow(cell1Mask) vigra.show() cells0Bounds = numpy.array(cellBounds[0]) cells1Bounds = numpy.array(cellBounds[1]) cells0Geo = cellGeometry[0] cells1Geo = cellGeometry[1] cells2Geo = cellGeometry[2] # loop over all 1-cells (boundaries) for cell1Index in range(numberOfCells[1]): #print(cells1Bounds[cell1Index,:])
# accumulate edge weights from gradient magnitude edgeWeights = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) # accumulate node features from grid graph node map # which is just a plain image (with channels) nodeFeatures = rag.accumulateNodeFeatures(imgLab) # do agglomerativeClustering labels = graphs.agglomerativeClustering(graph=rag, edgeWeights=edgeWeights, beta=beta, nodeFeatures=nodeFeatures, nodeNumStop=nodeNumStop) # show result f = pylab.figure() ax1 = f.add_subplot(2, 2, 1) vigra.imshow(gradMag,show=False) ax1.set_title("Input Image") pylab.axis('off') ax2 = f.add_subplot(2, 2, 2) rag.show(img) ax2.set_title("Over-Segmentation") pylab.axis('off') ax3 = f.add_subplot(2, 2, 3) rag.show(img, labels) ax3.set_title("Result-Segmentation") pylab.axis('off') ax4 = f.add_subplot(2, 2, 4) rag.showNested(img, labels)
# accumulate node features from grid graph node map # which is just a plain image (with channels) nodeFeatures = rag.accumulateNodeFeatures(imgLab) # do agglomerativeClustering labels = graphs.agglomerativeClustering(graph=rag, edgeWeights=edgeWeights, beta=beta, nodeFeatures=nodeFeatures, nodeNumStop=nodeNumStop) # show result f = pylab.figure() ax1 = f.add_subplot(2, 2, 1) vigra.imshow(gradMag, show=False) ax1.set_title("Input Image") pylab.axis('off') ax2 = f.add_subplot(2, 2, 2) rag.show(img) ax2.set_title("Over-Segmentation") pylab.axis('off') ax3 = f.add_subplot(2, 2, 3) rag.show(img, labels) ax3.set_title("Result-Segmentation") pylab.axis('off') ax4 = f.add_subplot(2, 2, 4) rag.showNested(img, labels)
gradMag = vigra.filters.gaussianGradientMagnitude(imgLabBig, sigmaGradMag) # get 2D grid graph and edgeMap for grid graph # from gradMag of interpolated image gridGraph = graphs.gridGraph(img.shape[0:2]) gridGraphEdgeIndicator = graphs.edgeFeaturesFromInterpolatedImage( gridGraph, gradMag) # get region adjacency graph from super-pixel labels rag = graphs.regionAdjacencyGraph(gridGraph, labels) # accumulate edge weights from gradient magnitude edgeIndicator = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) # accumulate node features from grid graph node map # which is just a plain image (with channels) nodeFeatures = rag.accumulateNodeFeatures(imgLab) resultFeatures = graphs.recursiveGraphSmoothing(rag, nodeFeatures, edgeIndicator, gamma=gamma, edgeThreshold=edgeThreshold, scale=scale, iterations=iterations) resultImgLab = rag.projectNodeFeaturesToGridGraph(resultFeatures) resultImgLab = vigra.taggedView(resultImgLab, "xyc") vigra.imshow(vigra.colors.transform_Lab2RGB(resultImgLab)) vigra.show()
gts = [] pbar = getPbar(len(imgFiles), 'Load Image') pbar.start() for i,path in enumerate(imgFiles): gtPath = gtBasePath + os.path.basename(path) rgbImg = vigra.impex.readImage(path) gtImg = vigra.impex.readImage(gtPath).astype('uint32')[::takeNth,::takeNth] gtImg[gtImg<125] = 0 gtImg[gtImg>=125] = 1 cEdgeImg = vigra.analysis.regionImageToCrackEdgeImage(gtImg+1) cEdgeImg[cEdgeImg>0] = 1 cEdgeImg = vigra.filters.discErosion(cEdgeImg.astype('uint8'),2) gtImg = cEdgeImg.astype(numpy.uint64) if i ==0: vigra.imshow(cEdgeImg) vigra.show() rgbImg = vigra.resize(rgbImg, [gtImg.shape[0],gtImg.shape[1]]) imgs.append(rgbImg) gts.append(gtImg) pbar.update(i) pbar.finish() def getSelf(img): return img def labHessianOfGaussian(img, sigma): l = vigra.colors.transform_RGB2Lab(img)[:,:,0] l = vigra.taggedView(l,'xy') return vigra.filters.hessianOfGaussianEigenvalues(l, sigma)
labels = rag.labels else: imPath = ("/media/tbeier/data/datasets/hhess/data_sub.h5", 'data') volume = vigra.impex.readHDF5(*imPath).astype('float32') volume = volume[0:1000, 0:1000, 0:40] volume = vigra.taggedView(volume, 'xyz') if False: print "hessianEv2" ev = hessianEv2(volume, 2.5) print ev.shape, ev.dtype ev = vigra.filters.gaussianSmoothing(ev, 2.5) vigra.imshow(ev[:, :, 0]) vigra.show() print "watershedsNew" labels, nseg = vigra.analysis.watershedsNew(ev) vigra.segShow(volume[:, :, 0], labels[:, :, 0]) vigra.show() print "gridGraph" gridGraph = graphs.gridGraph(labels.shape) rag = graphs.regionAdjacencyGraph(gridGraph, labels) rag.writeHDF5("ragb.h5", 'data') else: rag = vigra.graphs.loadGridRagHDF5("ragb.h5", 'data') labels = rag.labels print labels.shape, volume.shape
import vigra from vigra import graphs filepath = '12003.jpg' img = vigra.impex.readImage(filepath).astype('float32') imgM = img.copy() sigmaS = 1.0 sigmaB = 5.0 with vigra.Timer("ransk"): for c in range(3): print c imgC = img[:, :, c].squeeze() imgM[:, :, c] = vigra.histogram.gaussianRankOrder(imgC, sigmas=(sigmaS, sigmaS, sigmaB), ranks=(0.5, ), bins=255).squeeze() vigra.imshow(vigra.taggedView(imgM, 'xyc')) vigra.show()
img = vigra.impex.readImage(filepath) # get super-pixels with slic on LAB image imgLab = vigra.colors.transform_RGB2Lab(img) labels, nseg = vigra.analysis.slicSuperpixels(imgLab, slicWeight, superpixelDiameter) labels = vigra.analysis.labelImage(labels) # compute gradient imgLabBig = vigra.resize(imgLab, [imgLab.shape[0] * 2 - 1, imgLab.shape[1] * 2 - 1]) gradMag = vigra.filters.gaussianGradientMagnitude(imgLab, sigmaGradMag) gradMagBig = vigra.filters.gaussianGradientMagnitude(imgLabBig, sigmaGradMag * 2.0) vigra.imshow(gradMagBig) vigra.show() # get 2D grid graph and edgeMap for grid graph # from gradMag of interpolated image gridGraph = graphs.gridGraph(img.shape[0:2]) gridGraphEdgeIndicator = graphs.edgeFeaturesFromInterpolatedImage( gridGraph, gradMagBig) # get region adjacency graph from super-pixel labels rag = graphs.regionAdjacencyGraph(gridGraph, labels) # accumulate edge and ndie weights from gradient magnitude ragEdgeWeights = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) ragNodeWeights = rag.accumulateNodeFeatures(gradMag)
for i in range(nImages): gtImg = numpy.zeros(shape) gtImg[0:shape[0]/2,:] = 1 gtImg[shape[0]/4: 3*shape[0]/4, shape[0]/4: 3*shape[0]/4] = 2 ra = numpy.random.randint(180) #print ra gtImg = vigra.sampling.rotateImageDegree(gtImg.astype(numpy.float32),int(ra),splineOrder=0) if i<2 : vigra.imshow(gtImg) vigra.show() img = gtImg + numpy.random.random(shape)*float(noise) if i<2 : vigra.imshow(img) vigra.show() imgs.append(img.astype('float32')) gts.append(gtImg)
import vigra import numpy import time import sys fname = "135069.jpg" img = vigra.readImage(fname) img = numpy.sum(img,axis=2) img = vigra.resize(img,[s/1 for s in img.shape]) noise = numpy.random.random(img.size).reshape(img.shape)*255 print noise.shape img += noise img -= img.min() img /= img.max() print "shape", img.shape vigra.imshow(img) #vigra.show() threshold = 0.24 labelsNaive = img > threshold vigra.imshow(labelsNaive) #vigra.show() nVar = img.size nLabelsPerVar = 2 variableSpace = numpy.ones(nVar)*nLabelsPerVar gm = opengm.gm(variableSpace) t0 = time.time() # add unaries
pbar = getPbar(len(imgFiles), 'Load Image') pbar.start() for i, path in enumerate(imgFiles): gtPath = gtBasePath + os.path.basename(path) rgbImg = vigra.impex.readImage(path) gtImg = vigra.impex.readImage(gtPath).astype( 'uint32')[::takeNth, ::takeNth] gtImg[gtImg < 125] = 0 gtImg[gtImg >= 125] = 1 cEdgeImg = vigra.analysis.regionImageToCrackEdgeImage(gtImg + 1) cEdgeImg[cEdgeImg > 0] = 1 cEdgeImg = vigra.filters.discErosion(cEdgeImg.astype('uint8'), 2) gtImg = cEdgeImg.astype(numpy.uint64) if i == 0: vigra.imshow(cEdgeImg) vigra.show() rgbImg = vigra.resize(rgbImg, [gtImg.shape[0], gtImg.shape[1]]) imgs.append(rgbImg) gts.append(gtImg) pbar.update(i) pbar.finish() def getSelf(img): return img def labHessianOfGaussian(img, sigma): l = vigra.colors.transform_RGB2Lab(img)[:, :, 0] l = vigra.taggedView(l, 'xy')
import vigra from vigra import graphs filepath = '12003.jpg' img = vigra.impex.readImage(filepath).astype('float32') imgM = img.copy() sigmaS = 1.0 sigmaB = 5.0 with vigra.Timer("compute rank"): for c in range(3): print "channel",c imgC = img[:, :, c].squeeze() imgM[:,:,c] = vigra.histogram.gaussianRankOrder(imgC,sigmas=(sigmaS, sigmaS, sigmaB), ranks=(0.5,), bins=100).squeeze() vigra.imshow(vigra.taggedView(imgM,'xyc')) vigra.show()
show = False verbose = 1 img = vigra.readImage('12074.jpg')[120:300, 0:100, :] shape = img.shape[0:2] graph, liftedGraph = agraph.liftedGridGraph(shape=shape) # get primitive edge indicator localWeightsImage = vigra.filters.structureTensorEigenvalues( img, 0.5, 1.0)[:, :, 0] * -1.0 localWeightsImage -= localWeightsImage.min() localWeightsImage /= localWeightsImage.max() localWeightsImage -= 0.7 if show: vigra.imshow(localWeightsImage) localWeights = agraph.imageToLocalWeights(graph, liftedGraph, localWeightsImage) if verbose: print "localWeightsImage min max", localWeightsImage.min( ), localWeightsImage.max() print "localWeights min max", localWeights.min(), localWeights.max() # run lifted fusion moves result = agraph.liftedMcFusionMoves(graph=graph, liftedGraph=liftedGraph, weights=localWeights, maxNumberOfIterations=2, maxNumberOfIterationsWithoutImprovement=10, nodeLimit=40,
import vigra from vigra import numpy from matplotlib import pylab from time import time import multiprocessing path = "12003.jpg" data = vigra.impex.readImage(path).astype(numpy.float32) data = vigra.taggedView(100*numpy.random.rand(*data.shape),'xyc').astype('float32') + data data /= 2.0 vigra.imshow(data) vigra.show() cpus = multiprocessing.cpu_count() policy = vigra.filters.NormPolicy(sigma=10.0, meanDist=300.7, varRatio=0.9) res = vigra.filters.nonLocalMean2d(data,policy=policy,searchRadius=8,patchRadius=2,nThreads=cpus+1,stepSize=1,verbose=True,sigmaMean=1.0) res = vigra.taggedView(res,'xyc') vigra.imshow(res) vigra.show()
# accumulate edge weights from gradient magnitude edgeWeights = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) # accumulate node features from grid graph node map # which is just a plain image (with channels) nodeFeatures = rag.accumulateNodeFeatures(imgLab) # do agglomerativeClustering labels = graphs.agglomerativeClustering(graph=rag, edgeWeights=edgeWeights, beta=beta, nodeFeatures=nodeFeatures, nodeNumStop=nodeNumStop) # show result f = pylab.figure() ax1 = f.add_subplot(2, 2, 1) vigra.imshow(img,show=False) ax1.set_title("Input Image") pylab.axis('off') ax2 = f.add_subplot(2, 2, 2) rag.show(img) ax2.set_title("Over-Segmentation") pylab.axis('off') ax3 = f.add_subplot(2, 2, 3) rag.show(img, labels) ax3.set_title("Result-Segmentation") pylab.axis('off') ax4 = f.add_subplot(2, 2, 4) rag.showNested(img, labels)
import vigra import numpy import time import sys fname = "135069.jpg" img = vigra.readImage(fname) img = numpy.sum(img, axis=2) img = vigra.resize(img, [s / 1 for s in img.shape]) noise = numpy.random.random(img.size).reshape(img.shape) * 255 print noise.shape img += noise img -= img.min() img /= img.max() print "shape", img.shape vigra.imshow(img) #vigra.show() threshold = 0.24 labelsNaive = img > threshold vigra.imshow(labelsNaive) #vigra.show() nVar = img.size nLabelsPerVar = 2 variableSpace = numpy.ones(nVar) * nLabelsPerVar gm = opengm.gm(variableSpace) t0 = time.time() # add unaries for y in range(img.shape[1]):
import vigra import numpy import cmaps f = "figure_1.png" # cmaps.print_possible_cmaps() img = numpy.squeeze(vigra.readImage(f)) img_heat = cmaps.apply_cmap(img, "gist_heat") # vigra.impex.writeImage(img_heat, "figure_1_heat.png") vigra.imshow(numpy.swapaxes(img_heat, 1, 0)) vigra.show()
labels=rag.labels else : imPath = ("/media/tbeier/data/datasets/hhess/data_sub.h5",'data') volume = vigra.impex.readHDF5(*imPath).astype('float32') volume = volume[0:1000,0:1000,0:40] volume = vigra.taggedView(volume,'xyz') if False: print "hessianEv2" ev = hessianEv2(volume, 2.5) print ev.shape, ev.dtype ev = vigra.filters.gaussianSmoothing(ev, 2.5) vigra.imshow(ev[:,:,0]) vigra.show() print "watershedsNew" labels, nseg = vigra.analysis.watershedsNew(ev) vigra.segShow(volume[:,:,0], labels[:,:,0]) vigra.show() print "gridGraph" gridGraph = graphs.gridGraph(labels.shape) rag = graphs.regionAdjacencyGraph(gridGraph, labels) rag.writeHDF5("ragb.h5",'data') else: rag = vigra.graphs.loadGridRagHDF5("ragb.h5",'data') labels=rag.labels print labels.shape, volume.shape
for i in range(nImages): gtImg = numpy.zeros(shape) gtImg[0:shape[0] / 2, :] = 1 gtImg[shape[0] / 4:3 * shape[0] / 4, shape[0] / 4:3 * shape[0] / 4] = 2 ra = numpy.random.randint(180) #print ra gtImg = vigra.sampling.rotateImageDegree(gtImg.astype(numpy.float32), int(ra), splineOrder=0) if i < 1: vigra.imshow(gtImg) vigra.show() img = gtImg + numpy.random.random(shape) * float(noise) if i < 1: vigra.imshow(img) vigra.show() sp, nSeg = vigra.analysis.slicSuperpixels(gtImg, intensityScaling=0.2, seedDistance=5) sp = vigra.analysis.labelImage(sp) - 1 if i < 1: vigra.segShow(img, sp + 1, edgeColor=(1, 0, 0)) vigra.show()
def __init__(self, raw, seg, gt=None, patchSize=[100, 100], **kwargs): #raw input data self.raw = numpy.squeeze(raw) self.seg = numpy.squeeze(seg) self.gt = numpy.squeeze(gt) # shorthands self.shape = self.raw.shape # settings self.patchSize = patchSize # apply paddings ps = self.patchSize padding = ((ps[0], ps[0]), (ps[1], ps[1])) pad = partial(numpy.pad, pad_width=padding) self.paddingMask = pad(numpy.zeros(self.shape), mode='constant', constant_values=1) self.paddedRaw = pad(self.raw, mode='reflect') self.paddedSeg = vigra.analysis.labelImage( pad(self.seg, mode='reflect')).squeeze() self.paddedGt = None if self.gt is not None: self.paddedGt = vigra.analysis.labelImage( pad(self.gt, mode='reflect')).squeeze() #self.paddedGt = pad(self.gt + 1, mode='constant', constant_values=0) # compute cgp self.tGrid = ncgp.TopologicalGrid2D(self.paddedSeg) self.tShape = self.tGrid.topologicalGridShape self.numberOfCells = self.tGrid.numberOfCells self.fGrid = ncgp.FilledTopologicalGrid2D(self.tGrid) self.cellGrids = [ self.fGrid.cellMask([1, 0, 0]), self.fGrid.cellMask([0, 1, 0]), None ] self.cellGrids[0][ self.cellGrids[0] != 0] -= self.fGrid.cellTypeOffset[0] self.cellGrids[1][ self.cellGrids[1] != 0] -= self.fGrid.cellTypeOffset[1] self.cellMasks = [numpy.clip(x, 0, 1) for x in self.cellGrids[0:2]] + [None] rawT = vigra.sampling.resize(self.paddedRaw, self.tShape) #rawT[self.cellMasks[1]!=0] = 0 self.cellsBounds = self.tGrid.extractCellsBounds() self.cellsGeometry = self.tGrid.extractCellsGeometry(fill=True) self.cells1Bounds = self.cellsBounds[1] self.cells1Geometry = self.cellsGeometry[1] # center of mass self.cell1CentersOfMass = self.cells1Geometry.centersOfMass() print(self.cell1CentersOfMass) # compute gt ol = Overlap(self.numberOfCells[2], self.paddedSeg, self.paddedGt) cell1Probs = ol.differentOverlaps(numpy.array(self.cells1Bounds)) with nifty.Timer("makeCellImage"): probImg = ncgp.makeCellImage(rawT, self.cellGrids[1], cell1Probs * 255.0) vigra.imshow(probImg.astype('uint8'), cmap='gist_heat') vigra.show() if False: vigra.imshow(self.paddingMask) vigra.show() vigra.imshow(self.paddedRaw) vigra.show() vigra.segShow(self.paddedRaw, self.paddedSeg) vigra.show() vigra.segShow(self.paddedRaw, self.paddedGt) vigra.show()
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()
shape = [s / 2 for s in shape] timg = vigra.sampling.resize(img, shape) # get orientation tensor = vigra.filters.structureTensor(timg, 1.0, 2.0) eigenrep = vigra.filters.tensorEigenRepresentation2D(tensor) # print get oriented repulsive edges edgePmap = eigenrep[:, :, 0].copy() edgePmap -= edgePmap.min() edgePmap /= edgePmap.max() graph = agraph.gridGraph(shape) model = agraph.liftedMcModel(graph) with vigra.Timer("add long range edges"): agraph.addLongRangeEdges(model, edgePmap, 0.5, 2, 5) settings = agraph.settingsParallelLiftedMc(model) solver = agraph.parallelLiftedMc(model, settings) out = solver.run() nodeLabels = model.edgeLabelsToNodeLabels(out) nodeLabels = nodeLabels.reshape(shape) vigra.imshow(nodeLabels) vigra.show()
#~ 89,105,44,62 #~ roi = [91,105,14,33 ] # roi rectangle mybox = np.array([[roi[0], roi[0], roi[1], roi[1], roi[0]], [roi[2], roi[3], roi[3], roi[2], roi[2]]]) if 0: coordsToImage.plot_coords(coords) # plot roi as rectangle plt.plot(mybox[0, ...], mybox[1, ...], '0.3') else: scaling_factor = 8 im = coordsToImage.coordsShow(coords, 128, 128, scaling_factor) v.imshow(im) # rescale roi rectangle mybox = scaling_factor * mybox # plot roi as rectangle plt.plot(mybox[0, ...], mybox[1, ...], '0.3') plt.axis([0, 1024, 0, 1024]) plt.clim(0, 4000) plt.colorbar() myrobreg_measure = [] myrobreg_resids = [] for f in files: print "processing file " + f plt.figure() plt.title("Data: " + f)
# compute gradient on interpolated image imgLabBig = vigra.resize(imgLab, [imgLab.shape[0]*2-1, imgLab.shape[1]*2-1]) gradMag = vigra.filters.gaussianGradientMagnitude(imgLabBig, sigmaGradMag) # get 2D grid graph and edgeMap for grid graph # from gradMag of interpolated image gridGraph = graphs.gridGraph(img.shape[0:2]) gridGraphEdgeIndicator = graphs.edgeFeaturesFromInterpolatedImage(gridGraph, gradMag) # get region adjacency graph from super-pixel labels rag = graphs.regionAdjacencyGraph(gridGraph, labels) # accumulate edge weights from gradient magnitude edgeIndicator = rag.accumulateEdgeFeatures(gridGraphEdgeIndicator) # accumulate node features from grid graph node map # which is just a plain image (with channels) nodeFeatures = rag.accumulateNodeFeatures(imgLab) resultFeatures = graphs.recursiveGraphSmoothing(rag, nodeFeatures, edgeIndicator,gamma=gamma, edgeThreshold=edgeThreshold, scale=scale, iterations=iterations) resultImgLab = rag.projectNodeFeaturesToGridGraph(resultFeatures) resultImgLab = vigra.taggedView(resultImgLab, "xyc") vigra.imshow(vigra.colors.transform_Lab2RGB(resultImgLab)) vigra.show()