天天看点

【语义分割】——分割结果可视化

segmentation

核心代码

#pragma omp parallel for
            for (size_t i = 0; i < outputDim.d[1]; i++) {       // h
                for (size_t j = 0; j < outputDim.d[2]; j++) {   // w
                    int idx = i * outputDim.d[2] + j;
                    uint8_t classLable = (uint8_t) arg_max[idx];
                    cv::Vec3b color = colorMap[classLable];
                    cv::Vec3b tmp   = ori.at<cv::Vec3b>(i, j);
                    color = 0.5 * tmp + 0.5 * color;

                    showRgb->at<cv::Vec3b>(i, j) = color;
                }
            }
           

核心就是:可视化 = 0.5 * 原图 + 0.5 × 类的颜色,直接用opencv的cv::Vec3b进行运算

结果:

【语义分割】——分割结果可视化