def pixelWatershedMap(biImage, crackEdges = 4, midCracks = False): """pixelWatershedMap(biImage, crackEdges = 4, midCracks = False) Performs a watershed segmentation on biImage and returns a subpixel-GeoMap containing the resulting contours. The type of watershed segmentation depends on the 'crackEdges' parameter: 0: 8-connected edges on 4-connected background (SRG alg.) 4: crack edges between 4-connected watershed regions (UF alg.) 8: crack edges between 8-connected watershed regions (UF alg.) If midCracks is True, the resulting edges consist of the connected midpoints of the cracks, not of the crack segments themselves (this parameter is ignored if crackEdges == 0).""" if crackEdges: print "- Union-Find watershed segmentation..." lab, count = getattr(vigra, 'watershedUnionFind' + str(crackEdges))(biImage) if not midCracks: return crackConvert.crackEdgeMap( lab, eightConnectedRegions = (crackEdges == 8)) return crackEdgeMap(lab, midCracks) print "- watershed segmentation..." lab, count = vigra.analysis.watershedSegmentation(biImage, vigra.KeepContours) print "- creating pixel-based GeoMap..." pixelMap = cellimage.GeoMap(lab, 0, cellimage.CellType.Vertex) print "- converting pixel-based GeoMap..." return pixelMap2subPixelMap( pixelMap, imageSize = (pixelMap.cellImage.size()-Size2D(4,4)))
def pixelWatershedMap(biImage, crackEdges=4, midCracks=False): """pixelWatershedMap(biImage, crackEdges = 4, midCracks = False) Performs a watershed segmentation on biImage and returns a subpixel-GeoMap containing the resulting contours. The type of watershed segmentation depends on the 'crackEdges' parameter: 0: 8-connected edges on 4-connected background (SRG alg.) 4: crack edges between 4-connected watershed regions (UF alg.) 8: crack edges between 8-connected watershed regions (UF alg.) If midCracks is True, the resulting edges consist of the connected midpoints of the cracks, not of the crack segments themselves (this parameter is ignored if crackEdges == 0).""" if crackEdges: print "- Union-Find watershed segmentation..." lab, count = getattr(vigra, 'watershedUnionFind' + str(crackEdges))(biImage) if not midCracks: return crackConvert.crackEdgeMap( lab, eightConnectedRegions=(crackEdges == 8)) return crackEdgeMap(lab, midCracks) print "- watershed segmentation..." lab, count = vigra.analysis.watershedSegmentation(biImage, vigra.KeepContours) print "- creating pixel-based GeoMap..." pixelMap = cellimage.GeoMap(lab, 0, cellimage.CellType.Vertex) print "- converting pixel-based GeoMap..." return pixelMap2subPixelMap(pixelMap, imageSize=(pixelMap.cellImage.size() - Size2D(4, 4)))
def simpleTest(): global a hasApp = QtGui.QApplication.instance() if not hasApp: import sys a = QtGui.QApplication(sys.argv) else: a = hasApp import vigra, crackConvert img = vigra.ScalarImage(5, 5) img.subImage((1, 1), (4, 4)).init(1) img[1, 1] = 3 cm = crackConvert.crackEdgeMap(img) mw = MapDisplay(cm, img) mw.show() return mw, a
def simpleTest(): global a hasApp = QtGui.QApplication.instance() if not hasApp: import sys a = QtGui.QApplication(sys.argv) else: a = hasApp import vigra, crackConvert img = vigra.ScalarImage(5, 5) img.subImage((1,1), (4,4)).init(1) img[1,1] = 3 cm = crackConvert.crackEdgeMap(img) mw = MapDisplay(cm, img) mw.show() return mw, a
def midCrackPoints(img): spmap = crackConvert.crackEdgeMap(img) return extractMapPoints(spmap, False)