Action1010.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using PaintDotNet.Data.Param;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace PaintDotNet.Data.Action
  9. {
  10. /// <summary>
  11. /// 物相间距
  12. /// </summary>
  13. public class Action1010 : ParamObject
  14. {
  15. /// <summary>
  16. /// 无视场执行提取
  17. /// </summary>
  18. /// <param name="src"></param>
  19. /// <returns></returns>
  20. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src)
  21. {
  22. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists);
  23. }
  24. /// <summary>
  25. /// 多视场执行提取
  26. /// </summary>
  27. /// <param name="src">视场mat</param>
  28. /// <param name="mat">原图mat</param>
  29. /// <returns></returns>
  30. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat)
  31. {
  32. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists);
  33. }
  34. /// <summary>
  35. /// 用于初始化参数
  36. /// </summary>
  37. public Action1010()
  38. {
  39. this.MenuId = ActionType.ActionBinaryExtraction;
  40. this.OpenImage = "current";
  41. //默认1个颜色区间
  42. BooleanObject colorInterval = new BooleanObject();
  43. colorInterval.key = "colorInterval";
  44. colorInterval.name = PdnResources.GetString("Menu.inverse.text");
  45. colorInterval.initialValue = 1;
  46. colorInterval.value = 1;
  47. lists.Add(colorInterval);
  48. //第一个参数
  49. List<double> oneL = new List<double>();
  50. oneL.Add(0);
  51. oneL.Add(0);
  52. DecimalScope one = new DecimalScope(0, 255);
  53. one.key = "scope1";
  54. one.name = PdnResources.GetString("Menu.Colorinterval.text");
  55. one.value = oneL;
  56. lists.Add(one);
  57. List<double> twoL = new List<double>();
  58. twoL.Add(0);
  59. twoL.Add(0);
  60. DecimalScope two = new DecimalScope(0, 255);
  61. two.key = "scope2";
  62. two.name = PdnResources.GetString("Menu.Colorinterval.text");
  63. two.value = twoL;
  64. lists.Add(two);
  65. List<double> threeL = new List<double>();
  66. threeL.Add(0);
  67. threeL.Add(0);
  68. DecimalScope three = new DecimalScope(0, 255);
  69. three.key = "scope3";
  70. three.name = PdnResources.GetString("Menu.Colorinterval.text");
  71. three.value = threeL;
  72. lists.Add(three);
  73. BooleanObject autoThreshold = new BooleanObject();
  74. autoThreshold.key = "autoThreshold";
  75. autoThreshold.name = PdnResources.GetString("Menu.Automaticthreshold.text");
  76. autoThreshold.initialValue = false;
  77. autoThreshold.value = false;
  78. lists.Add(autoThreshold);
  79. //处理细节
  80. BooleanObject deleteBoundaryObject = new BooleanObject();
  81. deleteBoundaryObject.key = "deleteBoundaryObject";
  82. deleteBoundaryObject.name = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
  83. deleteBoundaryObject.initialValue = false;
  84. deleteBoundaryObject.value = false;
  85. lists.Add(deleteBoundaryObject);
  86. BooleanObject holeFilling = new BooleanObject();
  87. holeFilling.key = "holeFilling";
  88. holeFilling.name = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
  89. holeFilling.initialValue = false;
  90. holeFilling.Value = false;
  91. lists.Add(holeFilling);
  92. BooleanObject debrisRemoval = new BooleanObject();
  93. debrisRemoval.key = "debrisRemoval";
  94. debrisRemoval.name = PdnResources.GetString("Menu.Clasticdelete.text");
  95. debrisRemoval.initialValue = false;
  96. debrisRemoval.value = false;
  97. lists.Add(debrisRemoval);
  98. List<double> fiveL = new List<double>();
  99. fiveL.Add(0);
  100. fiveL.Add(0);
  101. DecimalScope five = new DecimalScope(0, int.MaxValue);
  102. five.key = "scope4";
  103. five.name = PdnResources.GetString("Menu.suiarea.Text");
  104. five.value = fiveL;
  105. lists.Add(five);
  106. //二值样式
  107. //实心/边线 1实心 2边线
  108. IntegerNumber binaryType = new IntegerNumber(0, 1);
  109. binaryType.key = "binaryStyle";
  110. binaryType.name = PdnResources.GetString("Menu.Binarystyle.text");
  111. binaryType.Value = 1;
  112. lists.Add(binaryType);
  113. ColorNumber phaseColor = new ColorNumber();
  114. phaseColor.key = "phaseColor";
  115. phaseColor.name = PdnResources.GetString("Menu.Phasecolor.text");
  116. phaseColor.Value = Color.Red.ToArgb();
  117. lists.Add(phaseColor);
  118. //目标选择,用于视场 1/2/3
  119. IntegerNumber targetSelection = new IntegerNumber(1, 3);
  120. targetSelection.key = "targetSelection";
  121. targetSelection.name = PdnResources.GetString("Menu.Targetselection.text");
  122. targetSelection.Value = 1;
  123. lists.Add(targetSelection);
  124. }
  125. }
  126. }