/// <summary> /// /// </summary> /// <param name="img"></param> /// <returns></returns> public static Bitmap greyImg(Bitmap img, double threshValue1, double blurValue) { //Matrix für das Bild Mat imgMat = new Mat(); //Bild zu Matrix umwandeln Utils.BitmapToMat(img, imgMat); //-----------------Bild bearbeiten--------------------- //Variablen //Size s = new Size(10.0, 10.0); Size s = new Size(blurValue, blurValue); OpenCV.Core.Point p = new OpenCV.Core.Point(0, 0); //TODO Matrix größe beachten? Bitmap bmp = null; Mat tmpgrey = new Mat(10, 10, CvType.Cv8uc1, new Scalar(4)); Mat tmpblur = new Mat(10, 10, CvType.Cv8uc1, new Scalar(4)); Mat tmpthresh = new Mat(10, 10, CvType.Cv8uc1, new Scalar(4)); Mat imgresult = new Mat(10, 10, CvType.Cv8uc1, new Scalar(4)); try { //Grau Imgproc.CvtColor(imgMat, tmpgrey, Imgproc.ColorBgr2gray, 4); //Blur Imgproc.Blur(tmpgrey, tmpblur, s, p); //Thresh //Orginal //Imgproc.Threshold(tmpblur, tmpthresh, 90, 255, Imgproc.ThreshBinary); Imgproc.Threshold(tmpblur, tmpthresh, threshValue1, 255, Imgproc.ThreshBinary); //Kontrast //tmpthresh.ConvertTo(imgresult, -1, 9.0, 10); bmp = Bitmap.CreateBitmap(tmpthresh.Cols(), tmpthresh.Rows(), Bitmap.Config.Argb8888); Utils.MatToBitmap(tmpthresh, bmp); } catch (CvException e) { System.Console.WriteLine(e.Message); } return(bmp); }