【问题标题】:Creat a mask from specific value of a Mat (in EMGU)从 Mat 的特定值创建掩码(在 EMGU 中)
【发布时间】:2021-10-13 08:16:39
【问题描述】:

在 OpenCv C++ 中你可以这样做:

int nbrLabel = connectedComponentsWithStats(img, labelsMat, stats, centroids);
int selectedLabel = 4;
Mat mask = (labelsMat == selectedLabel);

mask 将是img 的大小,并存储每个像素是否等于selectedLabel

Emgu 没有用于 Mat 的 == 运算符。
最好的解决方案是什么?

【问题讨论】:

    标签: c# opencv emgucv


    【解决方案1】:

    我发现的唯一解决方案是使用 Image<> 类中的 InRange 并具有相同的 lowerhigher 值:

    int nbrLabel = CvInvoke.ConnectedComponentsWithStats(img, labelsMat, stats, centroids);
    Image<Gray, byte> labelsImg = labelsMat.ToImage<Gray, byte>();
    int selectedLabel = 4;
    Mat mask = labelsImg.InRange(new Gray(selectedLabel), new Gray(selectedLabel)).Mat
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-22
      • 2015-08-30
      • 2015-05-10
      • 1970-01-01
      • 2013-10-09
      • 2013-10-23
      • 1970-01-01
      • 2010-09-21
      相关资源
      最近更新 更多