#region Opencv自带颜色表操作
static void Main(string[] args)
{
ColormapTypes[] color_map = new ColormapTypes[Enum.GetValues(typeof(ColormapTypes)).Length];
int index = 0;
foreach (ColormapTypes temp in Enum.GetValues(typeof(ColormapTypes)))
{
color_map[index] = temp;
index++;
}
index = 0;
Mat src = Cv2.ImRead("lenna.png", ImreadModes.AnyColor);
Cv2.ImShow("src image", src);
int key;
Cv2.NamedWindow("output image", WindowFlags.AutoSize);
Mat output_image = new Mat(src.Size(), src.Type());
while (true)
{
key = Cv2.WaitKey(500);
if (key == 27) break;
Cv2.ApplyColorMap(src, output_image, color_map[index % color_map.Length]);
index++;
if (index >= color_map.Length) index = 0;
Cv2.ImShow("output image", output_image);
}
Cv2.DestroyAllWindows();
}
#endregion