本文介绍了分水图像后保存图像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个读取图像的项目,然后使用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 ?
推荐答案
这篇关于分水图像后保存图像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!