Estimate segmentation using MaxFlow algorithm */
| 507 | Estimate segmentation using MaxFlow algorithm |
| 508 | */ |
| 509 | static void estimateSegmentation( GCGraph<double>& graph, Mat& mask ) |
| 510 | { |
| 511 | graph.maxFlow(); |
| 512 | Point p; |
| 513 | for( p.y = 0; p.y < mask.rows; p.y++ ) |
| 514 | { |
| 515 | for( p.x = 0; p.x < mask.cols; p.x++ ) |
| 516 | { |
| 517 | if( mask.at<uchar>(p) == GC_PR_BGD || mask.at<uchar>(p) == GC_PR_FGD ) |
| 518 | { |
| 519 | if( graph.inSourceSegment( p.y*mask.cols+p.x /*vertex index*/ ) ) |
| 520 | mask.at<uchar>(p) = GC_PR_FGD; |
| 521 | else |
| 522 | mask.at<uchar>(p) = GC_PR_BGD; |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | void cv::grabCut( InputArray _img, InputOutputArray _mask, Rect rect, |
| 529 | InputOutputArray _bgdModel, InputOutputArray _fgdModel, |
no test coverage detected