using PaintDotNet.Data.Param;
using System.Collections.Generic;
using System.Drawing;
namespace PaintDotNet.Data.Action
{
///
/// 二值提取
///
public class Action901 : ParamObject
{
///
/// 无视场执行提取,给二值用
///
///
///
public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, bool findContours = false)
{
return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists, findContours);
}
///
/// 无视场执行提取,给其它程序用,findContours默认false
///
///
///
public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src)
{
return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, this.Lists);
}
///
/// 多视场执行提取,给二值用
///
/// 视场mat
/// 原图mat
///
public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat, bool findContours = false)
{
return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists, findContours);
}
///
/// 多视场执行提取,给其它程序用,findContours默认false
///
///
///
///
public override OpenCvSharp.Mat PerformProcess(OpenCvSharp.Mat src, OpenCvSharp.Mat mat)
{
return Adjust.BinaryExtractionIntent.ImageBinaryExtraction(src, mat, this.Lists);
}
///
/// 用于初始化参数
///
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 oneL = new List();
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 threeL = new List();
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 twoL = new List();
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 fiveL = new List();
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);
}
}
}