Action0001.cs 8.1 KB

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