コード例 #1
0
ファイル: rbv_docseg.py プロジェクト: fpeder/mscr
    from mscr.util import load_gray, imshow, AddSuffix, MyKNN
    from mscr.bovw import BoVW
    from mscr.blocks import RandBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img
    from mscr.grid import Grid, GridClassifier

    imfile, model, nblock, nneigh, display, save = parse_args()
    img = load_gray(imfile)

    print '#------------------'
    print imfile

    # random block voting
    bvw = BoVW()
    bvw.load(model)
    rbv = BlockVote(
        Vote(bvw), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    votes = rbv.run(img)

    if display:
        rbv.show()

    # corase segmentation
    coarse = Votes2Img(img.shape[:2]).run(votes)

    # final segmentation
    grid = GridClassifier(MyKNN(labels, nn=nneigh), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
コード例 #2
0
ファイル: ubv_docseg.py プロジェクト: apacha/mscr
    from mscr.util import load_gray, MyKNN, imshow, AddSuffix
    from mscr.bovw import BoVW
    from mscr.blocks import TrivialBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img
    from mscr.grid import Grid, GridClassifier

    imgf, model, w, h, nn, display, save = parse_args()
    img = load_gray(imgf)

    print '#-----------------------'
    print imgf

    bvw = BoVW()
    bvw.load(model)

    ubv = BlockVote(Vote(bvw), TrivialBlockIter(w, h))
    votes = ubv.run(img)

    coarse = Votes2Img(img.shape[:2]).run(votes)

    grid = GridClassifier(MyKNN(labels, nn=nn), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imgf)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))
コード例 #3
0
    from mscr.util import load_gray, imshow, AddSuffix, MyKNN
    from mscr.bovw import BoVW
    from mscr.blocks import RandBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img
    from mscr.grid import Grid, GridClassifier

    imfile, model, nblock, nneigh, display, save = parse_args()
    img = load_gray(imfile)

    print '#------------------'
    print imfile

    # random block voting
    bvw = BoVW()
    bvw.load(model)
    rbv = BlockVote(Vote(bvw), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    votes = rbv.run(img)

    if display:
        rbv.show()

    # corase segmentation
    coarse = Votes2Img(img.shape[:2]).run(votes)

    # final segmentation
    grid = GridClassifier(MyKNN(labels, nn=nneigh), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
コード例 #4
0
    from docopt import docopt
    from os.path import basename as pbase
    from os.path import join as pjoin
    from mscr.util import load_gray, AddSuffix
    from mscr.bovw import BoVW
    from mscr.blocks import RandBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img

    imfile, nblock, model, display, save = parse_args()
    print '#----------------------------'
    print imfile

    img = load_gray(imfile)
    bbb = BoVW()
    bbb.load(model)

    rbv = BlockVote(Vote(bbb), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    asd = rbv.run(img)

    if display:
        rbv.show()

    vimg = Votes2Img(img.shape[:2])
    vimg.run(asd)
    vimg.get_bounding_box()

    if save:
        base = pbase(imfile)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        vimg.save_bb(outfile)
コード例 #5
0
ファイル: rbv_coarse_docseg.py プロジェクト: fpeder/mscr
    from os.path import basename as pbase
    from os.path import join as pjoin
    from mscr.util import load_gray, AddSuffix
    from mscr.bovw import BoVW
    from mscr.blocks import RandBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img

    imfile, nblock, model, display, save = parse_args()
    print '#----------------------------'
    print imfile

    img = load_gray(imfile)
    bbb = BoVW()
    bbb.load(model)

    rbv = BlockVote(
        Vote(bbb), RandBlockIter(nblock, pdiv, sdiv, md, Md))
    asd = rbv.run(img)

    if display:
        rbv.show()

    vimg = Votes2Img(img.shape[:2])
    vimg.run(asd)
    vimg.get_bounding_box()

    if save:
        base = pbase(imfile)
        outfile = pjoin(save, AddSuffix('out', 'pck').run(base))
        vimg.save_bb(outfile)
コード例 #6
0
ファイル: ubv_docseg.py プロジェクト: fpeder/mscr
    from mscr.util import load_gray, MyKNN, imshow, AddSuffix
    from mscr.bovw import BoVW
    from mscr.blocks import TrivialBlockIter
    from mscr.blockVote import Vote, BlockVote, Votes2Img
    from mscr.grid import Grid, GridClassifier

    imgf, model, w, h, nn, display, save = parse_args()
    img = load_gray(imgf)

    print '#-----------------------'
    print imgf

    bvw = BoVW()
    bvw.load(model)

    ubv = BlockVote(Vote(bvw), TrivialBlockIter(w, h))
    votes = ubv.run(img)

    coarse = Votes2Img(img.shape[:2]).run(votes)

    grid = GridClassifier(MyKNN(labels, nn=nn), Grid(microsize))
    grid.run(img, coarse)
    grid.finalize()
    res = grid.show()

    if display:
        imshow(res)

    if save:
        base = pbase(imgf)
        outfile = pjoin(save, AddSuffix('out', 'jpg').run(base))