Esempio n. 1
0
# --------------------------------------------------------------------

spmap = maputils.subpixelWatershedMapFromData(
    maxima, flowlines, img.size(),
    wsStatsSpline = img.gm.siv,
    minima = img.spws.minima())

maputils.removeCruft(spmap, 7)
assert checkSaddles(spmap, img.spws.saddles(), flowlines)
checkPassValues(spmap, img.gm.siv)

# --------------------------------------------------------------------

import pixelmap
lab, count = labelImage4(spmap.labelImage())
cm = pixelmap.crackEdgeMap(lab)
assert cm.faceCount == count + 1

# --------------------------------------------------------------------

map = GeoMap(maxima1, [], Size2D(256, 256))
maputils.addFlowLinesToMap(flowlines1, map)
maputils.connectBorderNodes(map, 0.1)
map.sortEdgesEventually(stepDist = 0.2, minDist = 0.05)
map.initializeMap()
assert map.checkConsistency(), "map inconsistent"
assert maputils.checkLabelConsistency(map), "map.labelImage() inconsistent"

# showMapStats(map)
# bg = readImage("../../../Testimages/blox.gif")
# d = MapDisplay(bg, map)
Esempio n. 2
0
        return result

if __name__ == "__main__":
    dsl = DigitalStraightLine(0, 1, 0)
    dsl.addPoint( 1,  0)
    dsl.addPoint(-1,  0)
    dsl.addPoint(-2, -1)

    from vigra import GrayImage, norm, meshIter

    gimg = GrayImage(50, 50)
    for p in meshIter(gimg.size()):
        gimg[p] = norm(p - Point2D(25, 25)) < 20 and 255 or 0

    import pixelmap
    cem = pixelmap.crackEdgeMap(gimg, False)
    crackPoly = cem.edge(2)
    fc = freeman(crackPoly)

    import Gnuplot
    def gpLine(points, with_ = "lines", **kwargs):
        return Gnuplot.Data(points, with_ = with_, **kwargs)

    g = Gnuplot.Gnuplot()
    g("set size ratio -1")

    ep = [p + offset(fc, i) for i, p in enumerate(list(crackPoly)[:-1])]
    ep.append(ep[0])
    ep2 = [p + offset2(fc, i) for i, p in enumerate(list(crackPoly)[:-1])]
    ep2.append(ep2[0])
    g.plot(gpLine(crackPoly), gpLine(ep), gpLine(ep2))
Esempio n. 3
0
spmap = maputils.subpixelWatershedMapFromData(maxima,
                                              flowlines,
                                              img.size(),
                                              wsStatsSpline=img.gm.siv,
                                              minima=img.spws.minima())

maputils.removeCruft(spmap, 7)
assert checkSaddles(spmap, img.spws.saddles(), flowlines)
checkPassValues(spmap, img.gm.siv)

# --------------------------------------------------------------------

import pixelmap
lab, count = labelImage4(spmap.labelImage())
cm = pixelmap.crackEdgeMap(lab)
assert cm.faceCount == count + 1

# --------------------------------------------------------------------

map = GeoMap(maxima1, [], Size2D(256, 256))
maputils.addFlowLinesToMap(flowlines1, map)
maputils.connectBorderNodes(map, 0.1)
map.sortEdgesEventually(stepDist=0.2, minDist=0.05)
map.initializeMap()
assert map.checkConsistency(), "map inconsistent"
assert maputils.checkLabelConsistency(map), "map.labelImage() inconsistent"

# showMapStats(map)
# bg = readImage("../../../Testimages/blox.gif")
# d = MapDisplay(bg, map)