缺口图图
测试网站
111https://www.591mf.top/duibi/hk.html
using System;
using System.Drawing;
public class ColorGapCounter
{
public static int CountGaps(Color startColor, Color endColor, int threshold)
{
int gaps = 0;
int startR = startColor.R;
int startG = startColor.G;
int startB = startColor.B;
int endR = endColor.R;
int endG = endColor.G;
int endB = endColor.B;
if (Math.Abs(endR - startR) > threshold) gaps++;
if (Math.Abs(endG - startG) > threshold) gaps++;
if (Math.Abs(endB - startB) > threshold) gaps++;
return gaps;
}
}
// 使用示例
class Program
{
static void Main()
{
Color startColor = Color.FromArgb(100, 100, 100);
Color endColor = Color.FromArgb(150, 150, 150);
int threshold = 50; // 阈值可以根据需要调整
int gaps = ColorGapCounter.CountGaps(startColor, endColor, threshold);
Console.WriteLine($"缺口数量: {gaps}");
}
}