Files
DigitalImageProcessing/DIgitalImageProcessingImageSharp/Program.cs
T
2025-11-12 16:37:01 +08:00

40 lines
1.1 KiB
C#

using OpenCvSharp;
using System.Xml.Serialization;
//string filepath = (@"C:\Users\Surface\Downloads\" + @"1682575881230001.png");
int year = 2025;
bool isLeap1 = DateTime.IsLeapYear(year);
bool isLeap2 = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
bool isLeap3 = year switch
{
_ when year % 400 == 0 => true,
_ when year % 100 == 0 => false,
_ when year % 4 == 0 => true,
_ => false,
};
bool isLeap4 = year % 4 == 0 ? (year % 100 == 0 ? (year % 400 == 0 ? true : false) : true) : false;
bool isLeap5 = year % 4 != 0 ? false : year % 100 != 0 ? true : year % 400 == 0 ? true : false;
Console.WriteLine(isLeap1);
Console.WriteLine(isLeap2);
Console.WriteLine(isLeap3);
Console.WriteLine(isLeap4);
Console.WriteLine(isLeap5);
string filepath = (@"C:\Users\Surface\Downloads\" + @"sprite-0001.png");
Mat image = Cv2.ImRead(filepath);
InputArray kernel = InputArray.Create<int>(new int[,] {
{ 0, 1, 0 },
{ 1, 1, 1 },
{ 0, 1, 0 }
}, MatType.CV_8U);
Mat dst = new();
//Cv2.Filter2D(image, dst, image.Depth(), kernel);
Cv2.Dilate(image, dst, kernel);
dst = dst - image;
dst.ImWrite(@"C:\Users\Surface\Downloads\" + @"filtered_opencv.png");