Files
UVtools/UVtools.Core/Objects/Kernel.cs
T
Tiago Conceição 703960a060 v2.1.3
* (Add) PrusaSlicer printers:
   * Peopoly Phenom XXL
   * QIDI 3D ibox mono
   * Wanhao CGR Mini Mono
   * Wanhao CGR Mono
* (Add) PrusaSlicer light supports profiles
* (Add) Calibration - Elephant Foot: Mirror output
* (Add) Calibration - XYZ Accuracy: Mirror output
* (Add) Calibration - Tolerance: Mirror output
* (Add) Calibration - Grayscale: Mirror output
* (Add) Scripts on github
* (Change) Save 'Display Width' and 'Height' to calibration profiles and load them back only if file format aware from these properties
* (Fix) Tool - Morph: Set a rectangular 3x3 kernel by default
* (Fix) Tool - Blur: Set a rectangular 3x3 kernel by default
* (Fix) Calibration - Elephant Foot: Include part scale on profile text
* (Fix) MSI dont store instalation path (#121)
2021-01-07 05:02:13 +00:00

49 lines
1.4 KiB
C#

/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.Drawing;
using Emgu.CV;
using Emgu.CV.CvEnum;
namespace UVtools.Core.Objects
{
[Serializable]
public sealed class Kernel
{
public Matrix<byte> Matrix { get; set; }
public Point Anchor { get; set; } = new(-1, -1);
public Kernel()
{
Matrix = new(3,3);
for(int y = 0; y < Matrix.Height; y++)
for(int x = 0; x < Matrix.Width; x++)
{
Matrix[x, y] = 1;
}
}
public Kernel(Matrix<byte> matrix, Point anchor)
{
Matrix = matrix;
Anchor = anchor;
}
public void SetKernel(ElementShape shape, Size size, Point anchor)
{
using var mat = CvInvoke.GetStructuringElement(shape, size, anchor);
Matrix = new Matrix<byte>(mat.Rows, mat.Cols);
mat.CopyTo(Matrix.Mat);
}
public void SetKernel(ElementShape shape, Size size) => SetKernel(shape, size, new Point(-1, -1));
public void SetKernel(ElementShape shape) => SetKernel(shape, new Size(3, 3), new Point(-1, -1));
}
}