Assign GMMs components for each pixel. */
| 399 | Assign GMMs components for each pixel. |
| 400 | */ |
| 401 | static void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, Mat& compIdxs ) |
| 402 | { |
| 403 | Point p; |
| 404 | for( p.y = 0; p.y < img.rows; p.y++ ) |
| 405 | { |
| 406 | for( p.x = 0; p.x < img.cols; p.x++ ) |
| 407 | { |
| 408 | Vec3d color = img.at<Vec3b>(p); |
| 409 | compIdxs.at<int>(p) = mask.at<uchar>(p) == GC_BGD || mask.at<uchar>(p) == GC_PR_BGD ? |
| 410 | bgdGMM.whichComponent(color) : fgdGMM.whichComponent(color); |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /* |
| 416 | Learn GMMs parameters. |