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進行運算
結果: