分水图像后保存图像时出错 [英] Error while save image after watershed the image

查看:139
本文介绍了分水图像后保存图像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个读取图像的项目,然后使用emgu cv库通过分水岭算法对图像进行了分割...然后我要保存它.
这是我的代码

i have a project that read an image and then i segmented the image by watershed algorithm using emgu cv library...then i want to save it.
this is my code

void Readimage (OpenFileDialog openFileDialog)
 {
    //Read input image
     var image = new Image<Bgr, Byte>(openFileDialog.FileName);
     //Get the binary image
     Image<Gray, Byte> binary = image.Convert<Gray, Byte>().ThresholdBinaryInv(new Gray(140), new Gray(255));
        var closeElement = new StructuringElementEx(5, 5, 2, 2,Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
        binary = binary.MorphologyEx(closeElement, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, 1);

        //Eliminate noise and smaller objects
        Image<Gray, Byte> foreground = binary.Erode(6);

        //Identify image pixels without objects
        Image<Gray, Byte> background = binary.Dilate(6);
        background._ThresholdBinaryInv(new Gray(1), new Gray(128));

        //Create markers image
        Image<Gray, Byte> markers = background + foreground;
        //Create watershed segmentation object
        WatershedSegmenter watershedSegmenter = new WatershedSegmenter();
        //Set markers and process
        watershedSegmenter.SetMakers(markers);
        Image<Gray, Int32> boundaryImage = watershedSegmenter.Process(image);
        string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\ProImages\";
        boundaryImage.ToBitmap().Save(appPath);}



但是我有这个例外:(

GDI +中发生一般错误.
我应该怎么做?



but i had this exception :(

A generic error occurred in GDI+.
what should i do ?

推荐答案

好,将该行分成两行,这样您就可以看到要抛出的方法是ToBitmap还是Save.

很有可能是ToBitmap调用.这通常是因为数据无效,无法使用它来构建位图.

掌握从中获得该图书馆的人员,并询问他们的情况.
OK, break that line down into two separate lines so you can see which method is throwing, ToBitmap or Save.

Chances are it''s going to be the ToBitmap call. That''s usually because the data isn''t valid to build a bitmap with.

Get a hold of the people you got that library from and ask them what''s going on.


这篇关于分水图像后保存图像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆