Exemple #1
0

if __name__ == '__main__':
    from cv2 import imwrite
    from os.path import join as pjoin
    from os.path import basename as pbase
    from docopt import docopt

    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
Exemple #2
0

if __name__ == '__main__':
    from cv2 import imwrite
    from os.path import join as pjoin
    from os.path import basename as pbase
    from docopt import docopt

    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)
Exemple #3
0
    return imgf, model, w, h, nn, display, save


if __name__ == '__main__':
    from cv2 import imwrite
    from docopt import docopt
    from os.path import join as pjoin
    from os.path import basename as pbase
    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()
Exemple #4
0
    return imgf, model, w, h, nn, display, save


if __name__ == '__main__':
    from cv2 import imwrite
    from docopt import docopt
    from os.path import join as pjoin
    from os.path import basename as pbase
    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()