#include <mil.h>
#define IMAGE_FILE M_IMAGE_PATH MIL_TEXT("Bird.mim")
#define IMAGE_LUMINANCE_OFFSET 40L
int MosMain(void)
{
MIL_ID MilApplication,
MilSystem,
MilDisplay,
MilImage,
MilLeftSubImage,
MilRightSubImage,
MilLumSubImage=0,
MilRedBandSubImage,
MilGreenBandSubImage,
MilBlueBandSubImage;
MIL_INT SizeX, SizeY, SizeBand, Type;
MappAllocDefault(M_DEFAULT, &MilApplication, &MilSystem, &MilDisplay, M_NULL, M_NULL);
MbufAllocColor(MilSystem,
MbufDiskInquire(IMAGE_FILE, M_SIZE_BAND, &SizeBand),
MbufDiskInquire(IMAGE_FILE, M_SIZE_X, &SizeX) * 2,
MbufDiskInquire(IMAGE_FILE, M_SIZE_Y, &SizeY),
MbufDiskInquire(IMAGE_FILE, M_TYPE, &Type),
M_IMAGE+M_DISP+M_PROC, &MilImage);
MbufClear(MilImage, 0L);
MdispSelect(MilDisplay, MilImage);
MbufChild2d(MilImage, 0L, 0L, SizeX, SizeY, &MilLeftSubImage);
MbufChild2d(MilImage, SizeX, 0L, SizeX, SizeY, &MilRightSubImage);
MbufLoad(IMAGE_FILE, MilLeftSubImage);
MbufChildColor(MilLeftSubImage, M_RED, &MilRedBandSubImage);
MbufChildColor(MilLeftSubImage, M_GREEN, &MilGreenBandSubImage);
MbufChildColor(MilLeftSubImage, M_BLUE, &MilBlueBandSubImage);
MgraColor(M_DEFAULT, 0xFF);
MgraText(M_DEFAULT, MilRedBandSubImage, SizeX/16, SizeY/8, MIL_TEXT(" TOUCAN "));
MgraColor(M_DEFAULT, 0x90);
MgraText(M_DEFAULT, MilGreenBandSubImage, SizeX/16, SizeY/8, MIL_TEXT(" TOUCAN "));
MgraColor(M_DEFAULT, 0x00);
MgraText(M_DEFAULT, MilBlueBandSubImage, SizeX/16, SizeY/8, MIL_TEXT(" TOUCAN "));
MosPrintf(MIL_TEXT("\nCOLOR OPERATIONS:\n"));
MosPrintf(MIL_TEXT("-----------------\n\n"));
MosPrintf(MIL_TEXT("A color source image was loaded on the left and color text\n"));
MosPrintf(MIL_TEXT("annotations were written in it.\n"));
MosPrintf(MIL_TEXT("Press <Enter> to continue.\n\n"));
MosGetch();
MimConvert(MilLeftSubImage, MilRightSubImage, M_RGB_TO_HSL);
MbufChildColor(MilRightSubImage, M_LUMINANCE, &MilLumSubImage);
MimArith(MilLumSubImage, IMAGE_LUMINANCE_OFFSET, MilLumSubImage,
M_ADD_CONST+M_SATURATION);
MimConvert(MilRightSubImage, MilRightSubImage, M_HSL_TO_RGB);
MosPrintf(MIL_TEXT("Luminance was increased using color image processing.\n"));
MosPrintf(MIL_TEXT("Press <Enter> to end.\n"));
MosGetch();
MbufFree(MilLumSubImage);
MbufFree(MilRedBandSubImage);
MbufFree(MilGreenBandSubImage);
MbufFree(MilBlueBandSubImage);
MbufFree(MilRightSubImage);
MbufFree(MilLeftSubImage);
MbufFree(MilImage);
MappFreeDefault(MilApplication, MilSystem, MilDisplay, M_NULL, M_NULL);
return 0;
}