using System;
using System.Collections.Generic;
using System.Text;
using Matrox.MatroxImagingLibrary;
namespace MCol
{
class Program
{
const int DISPLAY_CENTER_MARGIN_X = 5;
const int COLOR_PATCH_SIZEX = 30;
const int COLOR_PATCH_SIZEY = 40;
static void Main(string[] args)
{
MIL_ID MilApplication = MIL.M_NULL;
MIL_ID MilSystem = MIL.M_NULL;
MIL_ID MilDisplay = MIL.M_NULL;
MIL.MappAllocDefault(MIL.M_DEFAULT, ref MilApplication, ref MilSystem, ref MilDisplay, MIL.M_NULL, MIL.M_NULL);
ColorSegmentationExample(MilSystem, MilDisplay);
ColorMatchingExample(MilSystem, MilDisplay);
ColorSeparationExample(MilSystem, MilDisplay);
MIL.MappFreeDefault(MilApplication, MilSystem, MilDisplay, MIL.M_NULL, MIL.M_NULL);
}
const string CANDY_SAMPLE_IMAGE_FILE = MIL.M_IMAGE_PATH + "CandySamples.mim";
const string CANDY_TARGET_IMAGE_FILE = MIL.M_IMAGE_PATH + "Candy.mim";
const int NUM_SAMPLES = 6;
const int CANDY_SAMPLES_XSPACING = 35;
const int CANDY_SAMPLES_YOFFSET = 145;
const int MATCH_MODE = MIL.M_MIN_DIST_VOTE;
const int DISTANCE_TYPE = MIL.M_MAHALANOBIS;
const int TOLERANCE_MODE = MIL.M_SAMPLE_STDDEV;
const double TOLERANCE_VALUE = 6.0;
const double RED_TOLERANCE_VALUE = 6.0;
const double YELLOW_TOLERANCE_VALUE = 12.0;
const double PINK_TOLERANCE_VALUE = 5.0;
static void ColorSegmentationExample(MIL_ID MilSystem, MIL_ID MilDisplay)
{
MIL_ID SourceChild = MIL.M_NULL;
MIL_ID DestChild = MIL.M_NULL;
MIL_ID MatchContext = MIL.M_NULL;
MIL_ID MatchResult = MIL.M_NULL;
MIL_ID DisplayImage = MIL.M_NULL;
MIL_INT SourceSizeX = 0;
MIL_INT SourceSizeY = 0;
MIL_INT SampleIndex = 0;
MIL_INT SpacesIndex = 0;
double MatchScore = 0.0;
string[] Spaces = { "", " ", " ", " " };
string[] SampleNames = { "Green", "Red", "Yellow", "Purple", "Blue", "Pink" };
double[,] SamplesROI = new double[,] { { 58, 143 }, { 136, 148 }, { 217, 144 }, { 295, 142 }, { 367, 143 }, { 442, 147 } };
const double SampleSizeX = 36, SampleSizeY = 32;
MIL_INT[,] SampleMatchColor = new MIL_INT[NUM_SAMPLES, 3];
Console.Write("\nCOLOR SEGMENTATION:\n");
Console.Write("-------------------\n");
MIL.MbufDiskInquire(CANDY_SAMPLE_IMAGE_FILE, MIL.M_SIZE_X, ref SourceSizeX);
MIL.MbufDiskInquire(CANDY_SAMPLE_IMAGE_FILE, MIL.M_SIZE_Y, ref SourceSizeY);
MIL.MbufAllocColor(MilSystem, 3, 2 * SourceSizeX + DISPLAY_CENTER_MARGIN_X, SourceSizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_DISP + MIL.M_PROC, ref DisplayImage);
MIL.MbufClear(DisplayImage, MIL.M_COLOR_BLACK);
MIL.MbufChild2d(DisplayImage, 0, 0, SourceSizeX, SourceSizeY, ref SourceChild);
MIL.MbufChild2d(DisplayImage, SourceSizeX + DISPLAY_CENTER_MARGIN_X, 0, SourceSizeX, SourceSizeY, ref DestChild);
MIL.MbufLoad(CANDY_SAMPLE_IMAGE_FILE, SourceChild);
MIL.McolAlloc(MilSystem, MIL.M_COLOR_MATCHING, MIL.M_RGB, MIL.M_DEFAULT, MIL.M_DEFAULT, ref MatchContext);
for (int i = 0; i < NUM_SAMPLES; i++)
{
MIL.McolDefine(MatchContext, SourceChild, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_IMAGE, SamplesROI[i, 0], SamplesROI[i, 1], SampleSizeX, SampleSizeY);
}
MIL.McolSetMethod(MatchContext, MATCH_MODE, DISTANCE_TYPE, MIL.M_DEFAULT, MIL.M_DEFAULT);
MIL.McolControl(MatchContext, MIL.M_CONTEXT, MIL.M_DISTANCE_TOLERANCE_MODE, TOLERANCE_MODE);
MIL.McolControl(MatchContext, MIL.M_ALL, MIL.M_DISTANCE_TOLERANCE, TOLERANCE_VALUE);
MIL.McolControl(MatchContext, MIL.M_SAMPLE_INDEX(1), MIL.M_DISTANCE_TOLERANCE, RED_TOLERANCE_VALUE);
MIL.McolControl(MatchContext, MIL.M_SAMPLE_INDEX(2), MIL.M_DISTANCE_TOLERANCE, YELLOW_TOLERANCE_VALUE);
MIL.McolControl(MatchContext, MIL.M_SAMPLE_INDEX(5), MIL.M_DISTANCE_TOLERANCE, PINK_TOLERANCE_VALUE);
MIL.McolPreprocess(MatchContext, MIL.M_DEFAULT);
for (int i = 0; i < NUM_SAMPLES; i++)
{
MIL.McolInquire(MatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_0 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 0]);
MIL.McolInquire(MatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_1 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 1]);
MIL.McolInquire(MatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_2 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 2]);
}
DrawSampleColors(DestChild, SampleMatchColor, SampleNames, NUM_SAMPLES, CANDY_SAMPLES_XSPACING, CANDY_SAMPLES_YOFFSET);
MIL.MdispSelect(MilDisplay, DisplayImage);
Console.Write("Color samples are defined for each possible candy color.\n");
Console.Write("Press <Enter> to do color matching.\n\n");
Console.ReadKey();
MIL.MbufClear(DisplayImage, MIL.M_COLOR_BLACK);
MIL.MbufLoad(CANDY_TARGET_IMAGE_FILE, SourceChild);
MIL.McolAllocResult(MilSystem, MIL.M_COLOR_MATCHING_RESULT, MIL.M_DEFAULT, ref MatchResult);
MIL.McolControl(MatchContext, MIL.M_CONTEXT, MIL.M_GENERATE_PIXEL_MATCH, MIL.M_ENABLE);
MIL.McolControl(MatchContext, MIL.M_CONTEXT, MIL.M_GENERATE_SAMPLE_COLOR_LUT, MIL.M_ENABLE);
MIL.McolMatch(MatchContext, SourceChild, MIL.M_DEFAULT, MIL.M_NULL, MatchResult, MIL.M_DEFAULT);
Console.Write("Each pixel of the mixture is matched " +
"with one of the color samples.\n");
Console.Write("\nColor segmentation results:\n");
Console.Write("---------------------------\n");
for (SampleIndex = 0; SampleIndex < NUM_SAMPLES; SampleIndex++)
{
MIL.McolGetResult(MatchResult, MIL.M_DEFAULT, MIL.M_SAMPLE_INDEX((int)SampleIndex), MIL.M_SCORE, ref MatchScore);
SpacesIndex = 6 - SampleNames[SampleIndex].Length;
Console.Write("Ratio of {0}{1} sample = {2,5:0.00}%\n", SampleNames[SampleIndex], Spaces[SpacesIndex], MatchScore);
}
Console.Write("\nResults reveal the low proportion of Blue candy.\n");
MIL.McolDraw(MIL.M_DEFAULT, MatchResult, DestChild, MIL.M_DRAW_PIXEL_MATCH_USING_COLOR, MIL.M_ALL, MIL.M_ALL, MIL.M_DEFAULT);
Console.Write("\nPress <Enter> to end.\n\n");
Console.ReadKey();
MIL.MbufFree(DestChild);
MIL.MbufFree(SourceChild);
MIL.MbufFree(DisplayImage);
MIL.McolFree(MatchResult);
MIL.McolFree(MatchContext);
}
const string FUSE_SAMPLES_IMAGE = MIL.M_IMAGE_PATH + "FuseSamples.mim";
const string FUSE_TARGET_IMAGE = MIL.M_IMAGE_PATH + "Fuse.mim";
const string FINDER_CONTEXT = MIL.M_IMAGE_PATH + "FuseModel.mmf";
const int NUM_FUSES = 4;
const int FUSE_SAMPLES_XSPACING = 40;
const int FUSE_SAMPLES_YOFFSET = 145;
static void ColorMatchingExample(MIL_ID MilSystem, MIL_ID MilDisplay)
{
MIL_ID DisplayImage = MIL.M_NULL;
MIL_ID SourceChild = MIL.M_NULL;
MIL_ID DestChild = MIL.M_NULL;
MIL_ID ColMatchContext = MIL.M_NULL;
MIL_ID ColMatchResult = MIL.M_NULL;
MIL_ID ModelImage = MIL.M_NULL;
MIL_ID AreaImage = MIL.M_NULL;
MIL_ID OverlayID = MIL.M_NULL;
MIL_ID OverlaySourceChild = MIL.M_NULL;
MIL_ID OverlayDestChild = MIL.M_NULL;
MIL_ID FuseFinderCtx = MIL.M_NULL;
MIL_ID FuseFinderRes = MIL.M_NULL;
MIL_INT SizeX = 0;
MIL_INT SizeY = 0;
string[] SampleNames = { "Green", " Blue", " Red", "Yellow" };
MIL_INT[,] SampleROIs = new MIL_INT[,]{{ 54, 139, 28, 14},
{172, 137, 30, 23},
{296, 135, 31, 23},
{417, 134, 27, 22}};
MIL_INT[,] SampleMatchColor = new MIL_INT[NUM_FUSES, 3];
Console.Write("\nCOLOR IDENTIFICATION:\n");
Console.Write("---------------------\n");
MIL.MbufDiskInquire(FUSE_TARGET_IMAGE, MIL.M_SIZE_X, ref SizeX);
MIL.MbufDiskInquire(FUSE_TARGET_IMAGE, MIL.M_SIZE_Y, ref SizeY);
MIL.MbufAllocColor(MilSystem, 3, 2 * SizeX + DISPLAY_CENTER_MARGIN_X, SizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_DISP + MIL.M_PROC, ref DisplayImage);
MIL.MbufClear(DisplayImage, MIL.M_COLOR_BLACK);
MIL.MbufAlloc2d(MilSystem, SizeX, SizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_PROC + MIL.M_DISP, ref ModelImage);
MIL.MbufAlloc2d(MilSystem, SizeX, SizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_PROC + MIL.M_DISP, ref AreaImage);
MIL.MbufChild2d(DisplayImage, 0, 0, SizeX, SizeY, ref SourceChild);
MIL.MbufChild2d(DisplayImage, SizeX + DISPLAY_CENTER_MARGIN_X, 0, SizeX, SizeY, ref DestChild);
MIL.MbufLoad(FUSE_SAMPLES_IMAGE, SourceChild);
MIL.MdispSelect(MilDisplay, DisplayImage);
MIL.MdispControl(MilDisplay, MIL.M_OVERLAY, MIL.M_ENABLE);
MIL.MdispControl(MilDisplay, MIL.M_OVERLAY_CLEAR, MIL.M_DEFAULT);
MIL.MdispInquire(MilDisplay, MIL.M_OVERLAY_ID, ref OverlayID);
MIL.MbufChild2d(OverlayID, 0, 0, SizeX, SizeY, ref OverlaySourceChild);
MIL.MbufChild2d(OverlayID, SizeX + DISPLAY_CENTER_MARGIN_X, 0, SizeX, SizeY, ref OverlayDestChild);
MIL.MmodRestore(FINDER_CONTEXT, MilSystem, MIL.M_DEFAULT, ref FuseFinderCtx);
MIL.MmodPreprocess(FuseFinderCtx, MIL.M_DEFAULT);
MIL.MmodAllocResult(MilSystem, MIL.M_DEFAULT, ref FuseFinderRes);
MIL.McolAlloc(MilSystem, MIL.M_COLOR_MATCHING, MIL.M_RGB, MIL.M_DEFAULT, MIL.M_DEFAULT, ref ColMatchContext);
MIL.McolAllocResult(MilSystem, MIL.M_COLOR_MATCHING_RESULT, MIL.M_DEFAULT, ref ColMatchResult);
for (int i = 0; i < NUM_FUSES; i++)
{
MIL.McolDefine(ColMatchContext, SourceChild, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_IMAGE, (double)SampleROIs[i, 0], (double)SampleROIs[i, 1], (double)SampleROIs[i, 2], (double)SampleROIs[i, 3]);
}
MIL.McolPreprocess(ColMatchContext, MIL.M_DEFAULT);
for (int i = 0; i < NUM_FUSES; i++)
{
MIL.McolInquire(ColMatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_0 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 0]);
MIL.McolInquire(ColMatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_1 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 1]);
MIL.McolInquire(ColMatchContext, MIL.M_SAMPLE_LABEL(i + 1), MIL.M_MATCH_SAMPLE_COLOR_BAND_2 + MIL.M_TYPE_MIL_INT, ref SampleMatchColor[i, 2]);
}
DrawSampleColors(DestChild, SampleMatchColor, SampleNames, NUM_FUSES, FUSE_SAMPLES_XSPACING, FUSE_SAMPLES_YOFFSET);
MIL.MgraColor(MIL.M_DEFAULT, MIL.M_COLOR_RED);
for (MIL_INT SampleIndex = 0; SampleIndex < NUM_FUSES; SampleIndex++)
{
MIL_INT XEnd = SampleROIs[SampleIndex, 0] + SampleROIs[SampleIndex, 2] - 1;
MIL_INT YEnd = SampleROIs[SampleIndex, 1] + SampleROIs[SampleIndex, 3] - 1;
MIL.MgraRect(MIL.M_DEFAULT, OverlaySourceChild, SampleROIs[SampleIndex, 0], SampleROIs[SampleIndex, 1], XEnd, YEnd);
}
Console.Write("Colors are defined using one color sample region per fuse.\n");
Console.Write("Press <Enter> to process the target image.\n");
Console.ReadKey();
MIL.MdispControl(MilDisplay, MIL.M_OVERLAY_CLEAR, MIL.M_DEFAULT);
MIL.MdispControl(MilDisplay, MIL.M_UPDATE, MIL.M_DISABLE);
MIL.MbufLoad(FUSE_TARGET_IMAGE, SourceChild);
MIL.MimConvert(SourceChild, ModelImage, MIL.M_RGB_TO_L);
MIL.MbufCopy(ModelImage, DestChild);
MIL.MmodFind(FuseFinderCtx, ModelImage, FuseFinderRes);
MIL_INT Number = 0;
MIL.MmodGetResult(FuseFinderRes, MIL.M_DEFAULT, MIL.M_NUMBER + MIL.M_TYPE_MIL_INT, ref Number);
MIL.MbufClear(AreaImage, 0);
for (MIL_INT ii = 0; ii < Number; ii++)
{
double X = 0.0;
double Y = 0.0;
MIL.MmodGetResult(FuseFinderRes, ii, MIL.M_POSITION_X, ref X);
MIL.MmodGetResult(FuseFinderRes, ii, MIL.M_POSITION_Y, ref Y);
MIL.MgraColor(MIL.M_DEFAULT, (double)ii + 1);
MIL.MgraArcFill(MIL.M_DEFAULT, AreaImage, X, Y, 20, 20, 0, 360);
}
MIL.McolControl(ColMatchContext, MIL.M_CONTEXT, MIL.M_SAVE_AREA_IMAGE, MIL.M_ENABLE);
MIL.McolControl(ColMatchContext, MIL.M_CONTEXT, MIL.M_GENERATE_SAMPLE_COLOR_LUT, MIL.M_ENABLE);
MIL.McolMatch(ColMatchContext, SourceChild, MIL.M_DEFAULT, AreaImage, ColMatchResult, MIL.M_DEFAULT);
MIL.McolDraw(MIL.M_DEFAULT, ColMatchResult, OverlayDestChild, MIL.M_DRAW_AREA_MATCH_USING_COLOR, MIL.M_ALL, MIL.M_ALL, MIL.M_DEFAULT);
MIL.MgraColor(MIL.M_DEFAULT, MIL.M_COLOR_BLUE);
MIL.MmodDraw(MIL.M_DEFAULT, FuseFinderRes, OverlayDestChild, MIL.M_DRAW_BOX + MIL.M_DRAW_POSITION, MIL.M_ALL, MIL.M_DEFAULT);
MIL.MdispControl(MilDisplay, MIL.M_UPDATE, MIL.M_ENABLE);
Console.Write("\nFuses are located using the Model Finder tool.\n");
Console.Write("The color of each target area is identified.\n");
Console.Write("Press <Enter> to end.\n");
Console.ReadKey();
MIL.MmodFree(FuseFinderRes);
MIL.MmodFree(FuseFinderCtx);
MIL.MbufFree(AreaImage);
MIL.MbufFree(ModelImage);
MIL.MbufFree(SourceChild);
MIL.MbufFree(DestChild);
MIL.MbufFree(OverlaySourceChild);
MIL.MbufFree(OverlayDestChild);
MIL.MbufFree(DisplayImage);
MIL.McolFree(ColMatchContext);
MIL.McolFree(ColMatchResult);
}
const string WRITING_IMAGE_FILE = MIL.M_IMAGE_PATH + "stamp.mim";
static readonly MIL_INT[] BACKGROUND_COLOR ={ 245, 234, 206 };
static readonly MIL_INT[] WRITING_COLOR ={ 141, 174, 174 };
static readonly MIL_INT[] STAMP_COLOR = { 226, 150, 118 };
const int PATCHES_XSPACING = 70;
static void ColorSeparationExample(MIL_ID MilSystem, MIL_ID MilDisplay)
{
MIL_ID DisplayImage = MIL.M_NULL;
MIL_ID SourceChild = MIL.M_NULL;
MIL_ID DestChild = MIL.M_NULL;
MIL_ID Child = MIL.M_NULL;
MIL_ID ColorsArray = MIL.M_NULL;
MIL_INT SourceSizeX = 0;
MIL_INT SourceSizeY = 0;
string[] ColorNames = { "BACKGROUND", "WRITING", "STAMP" };
MIL_INT[,] Colors = new MIL_INT[,] { { 245, 234, 206 }, { 141, 174, 174 }, { 226, 150, 118 } };
byte[] BackgroundColor = new byte[3] { 245, 234, 206 };
byte[] SelectedColor = new byte[3] { 141, 174, 174 };
byte[] RejectedColor = new byte[3] { 226, 150, 118 };
Console.Write("\nCOLOR SEPARATION:\n");
Console.Write("-----------------\n");
MIL.MbufAlloc2d(MilSystem, 3, 3, 8 + MIL.M_UNSIGNED, MIL.M_ARRAY, ref ColorsArray);
MIL.MbufPut2d(ColorsArray, 0, 0, 3, 1, BackgroundColor);
MIL.MbufPut2d(ColorsArray, 0, 1, 3, 1, SelectedColor);
MIL.MbufPut2d(ColorsArray, 0, 2, 3, 1, RejectedColor);
MIL.MbufDiskInquire(WRITING_IMAGE_FILE, MIL.M_SIZE_X, ref SourceSizeX);
MIL.MbufDiskInquire(WRITING_IMAGE_FILE, MIL.M_SIZE_Y, ref SourceSizeY);
MIL.MbufAllocColor(MilSystem, 3, 2 * SourceSizeX + DISPLAY_CENTER_MARGIN_X, SourceSizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_DISP + MIL.M_PROC, ref DisplayImage);
MIL.MbufClear(DisplayImage, MIL.M_COLOR_BLACK);
MIL.MdispControl(MilDisplay, MIL.M_OVERLAY_CLEAR, MIL.M_DEFAULT);
MIL.MbufChild2d(DisplayImage, 0, 0, SourceSizeX, SourceSizeY, ref SourceChild);
MIL.MbufChild2d(DisplayImage, SourceSizeX + DISPLAY_CENTER_MARGIN_X, 0, SourceSizeX, SourceSizeY, ref DestChild);
MIL.MbufLoad(WRITING_IMAGE_FILE, SourceChild);
DrawSampleColors(DestChild, Colors, ColorNames, 3, PATCHES_XSPACING, -1);
MIL.MdispSelect(MilDisplay, DisplayImage);
Console.Write("The writing will be separated from the stamp using the following triplets:\n");
Console.Write("the background color: beige [{0}, {1}, {2}],\n", BackgroundColor[0], BackgroundColor[1], BackgroundColor[2]);
Console.Write("the writing color : green [{0}, {1}, {2}],\n", SelectedColor[0], SelectedColor[1], SelectedColor[2]);
Console.Write("the stamp color : red [{0}, {1}, {2}].\n\n", RejectedColor[0], RejectedColor[1], RejectedColor[2]);
Console.Write("Press <Enter> to extract the writing.\n\n");
Console.ReadKey();
MIL.McolProject(SourceChild, ColorsArray, DestChild, MIL.M_NULL, MIL.M_COLOR_SEPARATION, MIL.M_DEFAULT, MIL.M_NULL);
Console.Write("Press <Enter> to extract the stamp.\n\n");
Console.ReadKey();
MIL.MbufPut2d(ColorsArray, 0, 2, 3, 1, SelectedColor);
MIL.MbufPut2d(ColorsArray, 0, 1, 3, 1, RejectedColor);
MIL.McolProject(SourceChild, ColorsArray, DestChild, MIL.M_NULL, MIL.M_COLOR_SEPARATION, MIL.M_DEFAULT, MIL.M_NULL);
Console.Write("Press <Enter> to end.\n\n");
Console.ReadKey();
MIL.MbufFree(ColorsArray);
MIL.MbufFree(SourceChild);
MIL.MbufFree(DestChild);
MIL.MbufFree(DisplayImage);
}
static void DrawSampleColors(MIL_ID DestImage, MIL_INT[,] pSamplesColors, string[] pSampleNames, MIL_INT NumSamples, MIL_INT XSpacing, MIL_INT YOffset)
{
MIL_INT DestSizeX = MIL.MbufInquire(DestImage, MIL.M_SIZE_X, MIL.M_NULL);
MIL_INT DestSizeY = MIL.MbufInquire(DestImage, MIL.M_SIZE_Y, MIL.M_NULL);
double OffsetX = (DestSizeX - (NumSamples * COLOR_PATCH_SIZEX) - ((NumSamples - 1) * XSpacing)) / 2.0;
double OffsetY = YOffset > 0 ? YOffset : (DestSizeY - COLOR_PATCH_SIZEY) / 2.0;
double TextOffsetX;
MIL.MgraFont(MIL.M_DEFAULT, MIL.M_FONT_DEFAULT_SMALL);
for (MIL_INT SampleIndex = 0; SampleIndex < NumSamples; SampleIndex++)
{
MIL.MgraColor(MIL.M_DEFAULT, MIL.M_RGB888((int)pSamplesColors[SampleIndex, 0], (int)pSamplesColors[SampleIndex, 1], (int)pSamplesColors[SampleIndex, 2]));
MIL.MgraRectFill(MIL.M_DEFAULT, DestImage, OffsetX, OffsetY, OffsetX + COLOR_PATCH_SIZEX, OffsetY + COLOR_PATCH_SIZEY);
MIL.MgraColor(MIL.M_DEFAULT, MIL.M_COLOR_YELLOW);
TextOffsetX = OffsetX + COLOR_PATCH_SIZEX / 2.0 - 4.0 * pSampleNames[SampleIndex].Length + 0.5;
MIL.MgraText(MIL.M_DEFAULT, DestImage, TextOffsetX, OffsetY - 20, pSampleNames[SampleIndex]);
OffsetX += (COLOR_PATCH_SIZEX + XSpacing);
}
}
}
}