我的代码非常简单-我先对图像进行阈值处理,然后尝试对其应用DistanceTransform
:
var source = new Mat(path, ImreadModes.AnyDepth | ImreadModes.AnyColor);
var bgr = new Mat[3];
var thresh = new Mat();
var dist = new Mat();
Cv2.Split(source, out bgr);
Cv2.AdaptiveThreshold(bgr[2], thresh, 255, AdaptiveThresholdTypes.MeanC, ThresholdTypes.Binary, 13, 2);
Cv2.ImShow("thresh", thresh);
Cv2.DistanceTransform(thresh, dist, DistanceTypes.L2, DistanceMaskSize.Mask5);
Cv2.ImShow("dist", dist);
但是好像根本没有应用过滤器:
答案 0 :(得分:1)
事实证明,这是将Normalize
的图像从32位降到8位的失败(如this answer所述)。
添加以下行后,图像将达到预期效果:
Cv2.Normalize(dist, dist, 0, 1, NormTypes.MinMax);