1117
This commit is contained in:
@@ -1,40 +1,33 @@
|
||||
using OpenCvSharp;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
//string filepath = (@"C:\Users\Surface\Downloads\" + @"1682575881230001.png");
|
||||
string[] testFiles = [
|
||||
@"C:\Users\Surface\Downloads\1682575881230001.png", // 风景图
|
||||
@"C:\Users\Surface\Downloads\Sprite-0001.png", // 二值图
|
||||
@"C:\Users\Surface\Downloads\R-C.jfif", // 街道图
|
||||
@"C:\Users\Surface\Downloads\OIP.webp" // 指纹图
|
||||
];
|
||||
string filepath = testFiles[3];
|
||||
|
||||
int year = 2025;
|
||||
bool isLeap1 = DateTime.IsLeapYear(year);
|
||||
bool isLeap2 = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
|
||||
bool isLeap3 = year switch
|
||||
if (!ImageUtils.TryRead(filepath, out Mat image))
|
||||
{
|
||||
_ 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("Failed to read image: " + filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
int thresholdValue = 128;
|
||||
int thresholdDelta = 30;
|
||||
|
||||
Cv2.Dilate(image, dst, kernel);
|
||||
Mat gray = new();
|
||||
Cv2.CvtColor(image, gray, ColorConversionCodes.BGR2GRAY);
|
||||
|
||||
dst = dst - image;
|
||||
Mat img1 = new(), img2 = new();
|
||||
float delta = float.MaxValue;
|
||||
int loopCount = 0;
|
||||
|
||||
dst.ImWrite(@"C:\Users\Surface\Downloads\" + @"filtered_opencv.png");
|
||||
while(delta > thresholdValue)
|
||||
{
|
||||
//Cv2.Threshold(gray, img1, thresholdValue, 255, ThresholdTypes.Binary);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user