#include <mil.h>
#define IMAGE_FILE M_IMAGE_PATH MIL_TEXT("Cell.mim")
#define IMAGE_SMALL_PARTICLE_RADIUS 1
int MosMain(void)
{
MIL_ID MilApplication,
MilRemoteApplication,
MilSystem,
MilDisplay,
MilImage,
MilExtremeResult = 0;
MIL_INT MaxLabelNumber = 0;
MIL_INT LicenseModules = 0;
MappAllocDefault(M_DEFAULT, &MilApplication, &MilSystem,
&MilDisplay, M_NULL, M_NULL);
MbufRestore(IMAGE_FILE, MilSystem, &MilImage);
MdispSelect(MilDisplay, MilImage);
MosPrintf(MIL_TEXT("\nIMAGE PROCESSING:\n"));
MosPrintf(MIL_TEXT("-----------------\n\n"));
MosPrintf(MIL_TEXT("This program extracts the dark particles in the image.\n"));
MosPrintf(MIL_TEXT("Press <Enter> to continue.\n\n"));
MosGetch();
MimBinarize(MilImage, MilImage, M_BIMODAL+M_LESS_OR_EQUAL, M_NULL, M_NULL);
MosPrintf(MIL_TEXT("These particles were extracted from the original image.\n"));
#if (!M_MIL_LITE)
MsysInquire(MilSystem, M_OWNER_APPLICATION, &MilRemoteApplication);
MappInquire(MilRemoteApplication, M_LICENSE_MODULES, &LicenseModules);
if (LicenseModules & M_LICENSE_IM)
{
MosPrintf(MIL_TEXT("Press <Enter> to continue.\n\n"));
MosGetch();
MimClose(MilImage, MilImage, IMAGE_SMALL_PARTICLE_RADIUS, M_BINARY);
MimOpen(MilImage, MilImage, IMAGE_SMALL_PARTICLE_RADIUS, M_BINARY);
MimLabel(MilImage, MilImage, M_DEFAULT);
MimAllocResult(MilSystem, 1L, M_EXTREME_LIST, &MilExtremeResult);
MimFindExtreme(MilImage, MilExtremeResult, M_MAX_VALUE);
MimGetResult(MilExtremeResult, M_VALUE, &MaxLabelNumber);
MimFree(MilExtremeResult);
MimArith(MilImage,(MIL_INT)(256L/(MIL_DOUBLE)MaxLabelNumber), MilImage,
M_MULT_CONST);
MdispLut(MilDisplay, M_PSEUDO);
MosPrintf(MIL_TEXT("There were %d large particles in the original image.\n"),
(int)MaxLabelNumber);
}
#endif
MosPrintf(MIL_TEXT("Press <Enter> to end.\n\n"));
MosGetch();
MbufFree(MilImage);
MappFreeDefault(MilApplication, MilSystem, MilDisplay, M_NULL, M_NULL);
return 0;
}