void BorderMattingHandler::constructTrimap(){
    Point p;
    double w = 6.0;
    pixelidx.clear();
    pixelidx.resize(contours.size());
    
    //traversal all pixel.
    cout<<"constructing trimap."<<endl;
    for (p.y = 0; p.y < _img.rows; p.y++) {
        for (p.x = 0; p.x < _img.cols; p.x++) {
            int id = minestDistanceContourIndex(p);
            if (contours[id].dist(p) < w) {
                pixelidx[id].push_back(p);
                trimap.at<uchar>(p) = BM_U;
            }
        }
    }
    cout<<"finished."<<endl;
    imshow("trimap", trimap);
    //watchpixelidx();
    setupGauss();
    initSolve();
    solveEnergyFunction();
    computeAlpha();
    rejectOutlier();
    imshow("alpha", alphamap);
}
示例#2
0
bool Solver::solveOneStep(BaseField &field)
{
    _field = &field;
    return initSolve(true, false);
}
示例#3
0
void Solver::solve(BaseField &field, bool noGuess)
{
    _field = &field;
    initSolve(false, noGuess);
}