OpenCV distance transform outputting an image that looks exactly like the input image

前端 未结 4 2392
情话喂你
情话喂你 2021-02-20 09:58

I am doing some detection work using OpenCV, and I need to use the distance transform. Except the distance transform function in opencv gives me an image that is exactly the sam

4条回答
  •  情书的邮戳
    2021-02-20 10:13

    Mat formats

    • Input: CV_8U
    • Dist: CV_32F
    • Normalized: CV_8U

    normalize(Mat_dist, Mat_norm, 0, 255, NORM_MINMAX, CV_8U);

    If you want to visualize the result, you need to scale the normalization to 0 ... 255 and not to 0 ... 1 or everything will seem black. Using imshow(); on a scaled to 0 ... 1 image will work but may cause problmes in the next processing steps. Al least it did in my case.

提交回复
热议问题