gpt4 book ai didi

c# - 使用emgu 3.0,MorphologyEx,C#打开和关闭图像处理

转载 作者:行者123 更新时间:2023-12-02 17:12:13 25 4
gpt4 key购买 nike

如何使用新的emgu版本打开和关闭图像处理?

我发现了这个:
www.stackoverflow.com/questions/11567350/opening-and-closing-using-opencv/

但是我不能再使用“StructuringElementEx”,新的“image.MorphologyEx()”方法需要更多的值。

我也用.dilate和.erode尝试过,但这只有在3x3矩形下才有可能,但效果并不理想。

一个“更新”的例子将是伟大的!

最佳答案

使用Emgu CV 3.0的MorphologyEx时也会遇到相同的问题
我在Github中找到了此测试代码。
希望有帮助!

[Test]
public void TestMorphEx()
{
Mat kernel1 = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Cross, new Size(3, 3), new Point(1, 1));
Matrix<byte> kernel2 = new Matrix<byte>(new Byte[3, 3] { { 0, 1, 0 }, { 1, 0, 1 }, { 0, 1, 0 } });
//StructuringElementEx element2 = new StructuringElementEx(new int[3, 3] { { 0, 1, 0 }, { 1, 0, 1 }, { 0, 1, 0 } }, 1, 1);
Image<Bgr, Byte> tmp = new Image<Bgr, byte>(100, 100);
Image<Bgr, Byte> tmp2 = tmp.MorphologyEx(Emgu.CV.CvEnum.MorphOp.Gradient, kernel1, new Point(-1, -1), 1, CvEnum.BorderType.Default, new MCvScalar());
Image<Bgr, Byte> tmp3 = tmp.MorphologyEx(Emgu.CV.CvEnum.MorphOp.Gradient, kernel2, new Point(-1, -1), 1, CvEnum.BorderType.Default, new MCvScalar());
//Image<Bgr, Byte> tmp2 = tmp.MorphologyEx(element1, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_GRADIENT, 1);
//Image<Bgr, Byte> tmp3 = tmp.MorphologyEx(element2, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_BLACKHAT, 1);
}

关于c# - 使用emgu 3.0,MorphologyEx,C#打开和关闭图像处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33099101/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com