Action901.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using PaintDotNet.Data.Param;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. namespace PaintDotNet.Data.Action
  5. {
  6. /// <summary>
  7. /// 二值提取
  8. /// </summary>
  9. public class Action901 : ParamObject
  10. {
  11. /// <summary>
  12. /// 无视场执行提取,给二值用
  13. /// </summary>
  14. /// <param name="src"></param>
  15. /// <returns></returns>
  16. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, bool findContours = false)
  17. {
  18. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists, findContours);
  19. }
  20. /// <summary>
  21. /// 无视场执行提取,给其它程序用,findContours默认false
  22. /// </summary>
  23. /// <param name="src"></param>
  24. /// <returns></returns>
  25. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src)
  26. {
  27. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists);
  28. }
  29. /// <summary>
  30. /// 多视场执行提取,给二值用
  31. /// </summary>
  32. /// <param name="src">视场mat</param>
  33. /// <param name="mat">原图mat</param>
  34. /// <returns></returns>
  35. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat, bool findContours = false)
  36. {
  37. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists, findContours);
  38. }
  39. /// <summary>
  40. /// 多视场执行提取,给其它程序用,findContours默认false
  41. /// </summary>
  42. /// <param name="src"></param>
  43. /// <param name="mat"></param>
  44. /// <returns></returns>
  45. public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat)
  46. {
  47. return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists);
  48. }
  49. /// <summary>
  50. /// 用于初始化参数
  51. /// </summary>
  52. public Action901()
  53. {
  54. this.MenuId = ActionType.ActionBinaryExtraction;
  55. this.OpenImage = "addPhase";
  56. //默认1个颜色区间
  57. BooleanObject colorInterval = new BooleanObject();
  58. colorInterval.key = "colorInterval";
  59. colorInterval.name = PdnResources.GetString("Menu.inverse.text");
  60. colorInterval.initialValue = false;
  61. colorInterval.value = false;
  62. lists.Add(colorInterval);
  63. //第一个参数
  64. List<double> oneL = new List<double>();
  65. oneL.Add(0);
  66. oneL.Add(0);
  67. DecimalScope one = new DecimalScope(0, 255);
  68. one.key = "scope1";
  69. one.name = PdnResources.GetString("Menu.Colorinterval.text");
  70. one.value = oneL;
  71. lists.Add(one);
  72. List<double> threeL = new List<double>();
  73. threeL.Add(0);
  74. threeL.Add(0);
  75. DecimalScope three = new DecimalScope(0, 255);
  76. three.key = "scope3";
  77. three.name = "反选" + PdnResources.GetString("Menu.Colorinterval.text");
  78. three.value = threeL;
  79. lists.Add(three);
  80. List<double> twoL = new List<double>();
  81. twoL.Add(0);
  82. twoL.Add(0);
  83. DecimalScope two = new DecimalScope(0, 255);
  84. two.key = "scope2";
  85. two.name = "反选" + PdnResources.GetString("Menu.Colorinterval.text");
  86. two.value = twoL;
  87. lists.Add(two);
  88. BooleanObject autoThreshold = new BooleanObject();
  89. autoThreshold.key = "autoThreshold";
  90. autoThreshold.name = PdnResources.GetString("Menu.Automaticthreshold.text");
  91. autoThreshold.initialValue = false;
  92. autoThreshold.value = false;
  93. lists.Add(autoThreshold);
  94. //处理细节
  95. BooleanObject deleteBoundaryObject = new BooleanObject();
  96. deleteBoundaryObject.key = "deleteBoundaryObject";
  97. deleteBoundaryObject.name = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
  98. deleteBoundaryObject.initialValue = false;
  99. deleteBoundaryObject.value = false;
  100. lists.Add(deleteBoundaryObject);
  101. BooleanObject holeFilling = new BooleanObject();
  102. holeFilling.key = "holeFilling";
  103. holeFilling.name = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
  104. holeFilling.initialValue = false;
  105. holeFilling.Value = false;
  106. lists.Add(holeFilling);
  107. BooleanObject debrisRemoval = new BooleanObject();
  108. debrisRemoval.key = "debrisRemoval";
  109. debrisRemoval.name = PdnResources.GetString("Menu.Clasticdelete.text");
  110. debrisRemoval.initialValue = false;
  111. debrisRemoval.value = false;
  112. lists.Add(debrisRemoval);
  113. List<double> fiveL = new List<double>();
  114. fiveL.Add(0);
  115. fiveL.Add(0);
  116. DecimalScope five = new DecimalScope(0, int.MaxValue);
  117. five.key = "scope4";
  118. five.name = PdnResources.GetString("Menu.suiarea.Text");
  119. five.value = fiveL;
  120. lists.Add(five);
  121. //二值样式
  122. ChoiseArray binaryType = new ChoiseArray("binaryStyle", PdnResources.GetString("Menu.Binarystyle.text"),
  123. new BooleanObject[]
  124. {
  125. new BooleanObject("1", PdnResources.GetString("Menu.solid.text"), true, null),//fill
  126. new BooleanObject("2", PdnResources.GetString("Menu.Sideline.text"), false, null)//solid
  127. }
  128. );
  129. binaryType.initialValue = 1;
  130. binaryType.value = 1;
  131. ////实心/边线 1实心 2边线
  132. //IntegerNumber binaryType = new IntegerNumber(0, 1);
  133. //binaryType.key = "binaryStyle";
  134. //binaryType.name = PdnResources.GetString("Menu.Binarystyle.text");
  135. //binaryType.Value = 1;
  136. lists.Add(binaryType);
  137. ColorNumber phaseColor = new ColorNumber();
  138. phaseColor.key = "phaseColor";
  139. phaseColor.name = PdnResources.GetString("Menu.Phasecolor.text");
  140. phaseColor.Value = Color.Red.ToArgb();
  141. lists.Add(phaseColor);
  142. //目标选择,用于视场 1/2/3
  143. ChoiseArray targetSelection = new ChoiseArray("targetSelection", PdnResources.GetString("Menu.Targetselection.text"),
  144. new BooleanObject[]//####
  145. {
  146. new BooleanObject("1", PdnResources.GetString("Menu.inlun.Text"), true, null),
  147. new BooleanObject("2", PdnResources.GetString("Menu.inlunfen.Text"), false, null),
  148. new BooleanObject("3", PdnResources.GetString("Menu.haslun.Text"), false, null)
  149. }
  150. );
  151. targetSelection.initialValue = 2;
  152. targetSelection.value = 2;
  153. lists.Add(targetSelection);
  154. //生成新图
  155. ChoiseArray createNewImg = new ChoiseArray("createNewImg", "是否生成新图",
  156. new BooleanObject[]//####
  157. {
  158. new BooleanObject("0", "是", true, null),
  159. new BooleanObject("1", "否", false, null)
  160. }
  161. );
  162. createNewImg.initialValue = 0;
  163. createNewImg.value = 0;
  164. lists.Add(createNewImg);
  165. }
  166. }
  167. }