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

前端 未结 4 2416
情话喂你
情话喂你 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:02

    I just figured this one out. The OpenCV distanceTransform

    Calculates the distance to the closest zero pixel for each pixel of the source image.

    and so it expects your edges image to be negative.

    All you need to do is to negate your edges image:

    edges = 255 - edges;
    

提交回复
热议问题