public override EImageBW8 Run(EImageBW8 img) { if (!Enable) { return(img); } EImageBW8 imgBw8 = new EImageBW8(); imgBw8.SetSize(img); switch (Type) { case MorphologyType.Square: EasyImage.DilateBox(img, imgBw8, Width); break; case MorphologyType.Rectangle: EasyImage.DilateBox(img, imgBw8, Width, Height); break; case MorphologyType.Circle: EasyImage.DilateDisk(img, imgBw8, Width); break; default: EasyImage.DilateBox(img, imgBw8, Width); break; } img.Dispose(); img = new EImageBW8(); return(imgBw8); }
/// <summary> /// 图片均衡操作,将传入图片自动转换,imgWidth:设定图片宽度,imgHeight图片设定高度 /// 图片(forexample:a.bmp)另存为同文件夹下面的_a.bmp /// </summary> /// <param name="ImagePath"></param> public void QualizerImage(string ImagePath, int imgWidth, int imgHeight) { try { if ((ImagePath.Length == 0) || (!File.Exists(ImagePath))) { return; } EImageBW8 EBW8ImageOrig = new EImageBW8(); // EImageBW8 instance EImageBW8 EBW8ImageDest = new EImageBW8(); // EImageBW8 instance EBW8ImageOrig.SetSize(imgWidth, imgHeight); // Make image black EasyImage.Oper(EArithmeticLogicOperation.Copy, new EBW8(0), EBW8ImageOrig); EBW8ImageOrig.Load(ImagePath); EBW8ImageDest.SetSize(imgWidth, imgHeight); // Make image black EasyImage.Oper(EArithmeticLogicOperation.Copy, new EBW8(0), EBW8ImageDest); EBW8ImageDest.SetSize(EBW8ImageOrig); EasyImage.Equalize(EBW8ImageOrig, EBW8ImageDest); EBW8ImageOrig.Dispose(); //EBW8ImageDest.Save(ImagePath); EBW8ImageDest.Save(ImageSaveAsPath(ImagePath)); } catch { throw; } }
public override EImageBW8 Run(EImageBW8 img) { if (!Enable) { return(img); } EImageBW8 imgBw8 = new EImageBW8(); imgBw8.SetSize(img); switch (Mode) { case MyThresholdMode.Auto: EBW8 value1 = EasyImage.AutoThreshold(img, EThresholdMode.MinResidue); AbsoluteValue = value1.Value; break; case MyThresholdMode.Absolute: break; case MyThresholdMode.Relative: EBW8 value2 = EasyImage.AutoThreshold(img, EThresholdMode.Relative, RelativeValue); AbsoluteValue = value2.Value; break; default: break; } EasyImage.Threshold(img, imgBw8, AbsoluteValue); img.Dispose(); img = new EImageBW8(); return(imgBw8); }
public override EImageBW8 Run(EImageBW8 img) { if (!Enable) { return(img); } EImageBW8 imgBw8 = new EImageBW8(); imgBw8.SetSize(img); EasyImage.GainOffset(img, imgBw8, Gain, Offset); img.Dispose(); img = new EImageBW8(); return(imgBw8); }
public override EImageBW8 Run(EImageBW8 img) { if (!Enable) { return(img); } EImageBW8 imgBw8 = new EImageBW8(); imgBw8.SetSize(img); EasyImage.Median(img, imgBw8); img.Dispose(); img = new EImageBW8(); return(imgBw8); }
public override EImageBW8 Run(EImageBW8 img) { if (!Enable) { return(img); } EImageBW8 imgBw8 = new EImageBW8(); float a = 0f, x = 0f, y = 0f; if (Value % 180 < 90) { //当前角度 a = (float)Math.Atan2((float)img.Height / 2, (float)img.Width / 2); //旋转后角度 float b = a + Value % 90 * ((float)Math.PI / 180); float c = a - Value % 90 * ((float)Math.PI / 180); //斜边 float z = (float)Math.Sqrt(img.Width * img.Width + img.Height * img.Height) / 2; //xy增量 x = (float)(Math.Cos(c) - Math.Cos(a)) * z; y = (float)(Math.Sin(b) - Math.Sin(a)) * z; //设置新图片大小 imgBw8.SetSize((int)(img.Width + 2 * x), (int)(img.Height + 2 * y)); } else if (Value % 180 >= 90) { //当前角度 a = (float)Math.Atan2((float)img.Height / 2, (float)img.Width / 2); //旋转后角度 float b = a + Value % 90 * ((float)Math.PI / 180); float c = a - Value % 90 * ((float)Math.PI / 180); //斜边 float z = (float)Math.Sqrt(img.Width * img.Width + img.Height * img.Height) / 2; //xy增量 y = (float)(Math.Cos(c) - Math.Cos(a)) * z; x = (float)(Math.Sin(b) - Math.Sin(a)) * z; //设置新图片大小 imgBw8.SetSize((int)(img.Height + 2 * x), (int)(img.Width + 2 * y)); } EasyImage.ScaleRotate(img, (float)img.Width / 2, (float)img.Height / 2, (float)imgBw8.Width / 2, (float)imgBw8.Height / 2, 1, 1, Value, imgBw8, 0); img.Dispose(); img = new EImageBW8(); return(imgBw8); }