123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using PaintDotNet.Data.Param;
- using System.Collections.Generic;
- using System.Drawing;
- namespace PaintDotNet.Data.Action
- {
- /// <summary>
- /// 二值提取
- /// </summary>
- public class Action901 : ParamObject
- {
- /// <summary>
- /// 无视场执行提取,给二值用
- /// </summary>
- /// <param name="src"></param>
- /// <returns></returns>
- public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, bool findContours = false)
- {
- return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists, findContours);
- }
- /// <summary>
- /// 无视场执行提取,给其它程序用,findContours默认false
- /// </summary>
- /// <param name="src"></param>
- /// <returns></returns>
- public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src)
- {
- return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists);
- }
- /// <summary>
- /// 多视场执行提取,给二值用
- /// </summary>
- /// <param name="src">视场mat</param>
- /// <param name="mat">原图mat</param>
- /// <returns></returns>
- public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat, bool findContours = false)
- {
- return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists, findContours);
- }
- /// <summary>
- /// 多视场执行提取,给其它程序用,findContours默认false
- /// </summary>
- /// <param name="src"></param>
- /// <param name="mat"></param>
- /// <returns></returns>
- public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat)
- {
- return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists);
- }
- /// <summary>
- /// 用于初始化参数
- /// </summary>
- public Action901()
- {
- this.MenuId = ActionType.ActionBinaryExtraction;
- this.OpenImage = "addPhase";
- //默认1个颜色区间
- BooleanObject colorInterval = new BooleanObject();
- colorInterval.key = "colorInterval";
- colorInterval.name = PdnResources.GetString("Menu.inverse.text");
- colorInterval.initialValue = false;
- colorInterval.value = false;
- lists.Add(colorInterval);
- //第一个参数
- List<double> oneL = new List<double>();
- oneL.Add(0);
- oneL.Add(0);
- DecimalScope one = new DecimalScope(0, 255);
- one.key = "scope1";
- one.name = PdnResources.GetString("Menu.Colorinterval.text");
- one.value = oneL;
- lists.Add(one);
- List<double> threeL = new List<double>();
- threeL.Add(0);
- threeL.Add(0);
- DecimalScope three = new DecimalScope(0, 255);
- three.key = "scope3";
- three.name = "反选" + PdnResources.GetString("Menu.Colorinterval.text");
- three.value = threeL;
- lists.Add(three);
- List<double> twoL = new List<double>();
- twoL.Add(0);
- twoL.Add(0);
- DecimalScope two = new DecimalScope(0, 255);
- two.key = "scope2";
- two.name = "反选" + PdnResources.GetString("Menu.Colorinterval.text");
- two.value = twoL;
- lists.Add(two);
- BooleanObject autoThreshold = new BooleanObject();
- autoThreshold.key = "autoThreshold";
- autoThreshold.name = PdnResources.GetString("Menu.Automaticthreshold.text");
- autoThreshold.initialValue = false;
- autoThreshold.value = false;
- lists.Add(autoThreshold);
- //处理细节
- BooleanObject deleteBoundaryObject = new BooleanObject();
- deleteBoundaryObject.key = "deleteBoundaryObject";
- deleteBoundaryObject.name = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
- deleteBoundaryObject.initialValue = false;
- deleteBoundaryObject.value = false;
- lists.Add(deleteBoundaryObject);
- BooleanObject holeFilling = new BooleanObject();
- holeFilling.key = "holeFilling";
- holeFilling.name = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
- holeFilling.initialValue = false;
- holeFilling.Value = false;
- lists.Add(holeFilling);
- BooleanObject debrisRemoval = new BooleanObject();
- debrisRemoval.key = "debrisRemoval";
- debrisRemoval.name = PdnResources.GetString("Menu.Clasticdelete.text");
- debrisRemoval.initialValue = false;
- debrisRemoval.value = false;
- lists.Add(debrisRemoval);
- List<double> fiveL = new List<double>();
- fiveL.Add(0);
- fiveL.Add(0);
- DecimalScope five = new DecimalScope(0, int.MaxValue);
- five.key = "scope4";
- five.name = PdnResources.GetString("Menu.suiarea.Text");
- five.value = fiveL;
- lists.Add(five);
- //二值样式
- ChoiseArray binaryType = new ChoiseArray("binaryStyle", PdnResources.GetString("Menu.Binarystyle.text"),
- new BooleanObject[]
- {
- new BooleanObject("1", PdnResources.GetString("Menu.solid.text"), true, null),//fill
- new BooleanObject("2", PdnResources.GetString("Menu.Sideline.text"), false, null)//solid
- }
- );
- binaryType.initialValue = 1;
- binaryType.value = 1;
- ////实心/边线 1实心 2边线
- //IntegerNumber binaryType = new IntegerNumber(0, 1);
- //binaryType.key = "binaryStyle";
- //binaryType.name = PdnResources.GetString("Menu.Binarystyle.text");
- //binaryType.Value = 1;
- lists.Add(binaryType);
- ColorNumber phaseColor = new ColorNumber();
- phaseColor.key = "phaseColor";
- phaseColor.name = PdnResources.GetString("Menu.Phasecolor.text");
- phaseColor.Value = Color.Red.ToArgb();
- lists.Add(phaseColor);
- //目标选择,用于视场 1/2/3
- ChoiseArray targetSelection = new ChoiseArray("targetSelection", PdnResources.GetString("Menu.Targetselection.text"),
- new BooleanObject[]//####
- {
- new BooleanObject("1", PdnResources.GetString("Menu.inlun.Text"), true, null),
- new BooleanObject("2", PdnResources.GetString("Menu.inlunfen.Text"), false, null),
- new BooleanObject("3", PdnResources.GetString("Menu.haslun.Text"), false, null)
- }
- );
- targetSelection.initialValue = 2;
- targetSelection.value = 2;
- lists.Add(targetSelection);
- //生成新图
- ChoiseArray createNewImg = new ChoiseArray("createNewImg", "是否生成新图",
- new BooleanObject[]//####
- {
- new BooleanObject("0", "是", true, null),
- new BooleanObject("1", "否", false, null)
- }
- );
- createNewImg.initialValue = 0;
- createNewImg.value = 0;
- lists.Add(createNewImg);
- }
- }
- }
|