我正在寻找一种比较两种RGB颜色并生成其相似性值的算法(其中相似性意味着"与人类平均感知相似").
有任何想法吗?
编辑:
由于我不能回答,我决定将我的"解决方案"作为问题的编辑.
我决定在我的应用程序中使用(非常)小的真彩色子集,以便我可以自己处理颜色的比较.我使用大约30种颜色,并使用它们之间的硬编码距离.
由于它是一个iPhone应用程序,我使用Objective-C,实现或多或少是一个表示下表的矩阵,它显示了颜色之间的距离.
将a转换System.Drawing.Color为类似的最佳方法是什么System.ConsoleColor?
我需要一种方法来绘制Dictionary<int,int>一个控制台应用程序,如
Dictionary<int, int> chartList = new Dictionary<int, int>()
{
{50,31}, // x = 50, y = 31
{71,87},
{25,66},
{94,15},
{33,94}
};
DrawChart(chartList);
Run Code Online (Sandbox Code Playgroud)
应该导致类似的东西
我已经走到这一步了但是我坚持使用这个IsHit方法,它决定了当前坐标是否应该设置一个点.在这一点上有人可以帮助我吗?它总是返回true.
public static void DrawChart(Dictionary<int, int> dict)
{
int consoleWidth = 78;
int consoleHeight = 20;
Console.WriteLine(dict.Max(x => x.Key).ToString());
Func<int, int, bool> IsHit = (hx, hy) => dict.Any(dct => dct.Key / dict.Max(x => x.Key) == hx / dict.Max(x => x.Key) && dct.Value / dict.Max(x => x.Value) == hy / dict.Max(x => x.Value)); …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种在控制台窗口内绘制图像的方法.类似于我可以打电话Console.Write("this will display in the console window");.我不确定这是否可行.
我玩了一点没有运气(可能是因为.NET希望你使用winforms进行图形编程).
这是我正在尝试做的事情的片段:
using System;
using System.Drawing;
namespace DisplayImage
{
class Program
{
static void Main(string[] args)
{
using (var bmp = new Bitmap(100, 100))
using (var gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(Brushes.Orange, new Rectangle(0, 0, bmp.Width, bmp.Height));
Console.WriteLine("draw image");
gr.DrawImage(bmp, 1, 1);
Console.WriteLine("drew image");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
有没有办法在控制台应用程序中操纵像素?也许我可以手动读取图像中的像素,并在控制台中绘制每个像素.
这只是为了好玩,顺便说一下.不是一个实际的项目,只是一个练习/探索项目.我们破解控制台:-)