/***********************************************************************************/ /* * File name: MImHistogram.c * * Synopsis: This program loads an image of a tissue sample, calculates its intensity * histogram and draws it. */ #include #include /* Target MIL image file specifications. */ #define IMAGE_FILE M_IMAGE_PATH MIL_TEXT("Cell.mim") /* Number of possible pixel intensities. */ #define HIST_NUM_INTENSITIES 256 #define HIST_SCALE_FACTOR 8 #define HIST_X_POSITION 250 #define HIST_Y_POSITION 450 /* Main function. */ void main(void) { MIL_ID MilApplication, /* Application identifier */ MilSystem, /* System identifier. */ MilDisplay, /* Display identifier. */ MilImage, /* Image buffer identifier. */ MilOverlayImage, /* Overlay buffer identifier. */ HistResult; /* Histogram buffer identifier. */ long HistValues[HIST_NUM_INTENSITIES]; /* Histogram values. */ long XStart[HIST_NUM_INTENSITIES], YStart[HIST_NUM_INTENSITIES], XEnd[HIST_NUM_INTENSITIES], YEnd[HIST_NUM_INTENSITIES]; long AnnotationColor = M_COLOR_RED, i; /* Allocate the default system and image buffer. */ MappAllocDefault(M_SETUP, &MilApplication, &MilSystem, &MilDisplay, M_NULL, M_NULL); /* Restore source image into an automatically allocated image buffer. */ MbufRestore(IMAGE_FILE, MilSystem, &MilImage); /* Display the image buffer and prepare for overlay annotations. */ MdispSelect(MilDisplay, MilImage); MdispControl(MilDisplay, M_OVERLAY, M_ENABLE); MdispInquire(MilDisplay, M_OVERLAY_ID, &MilOverlayImage); /* Allocate a histogram result buffer. */ MimAllocResult(MilSystem, HIST_NUM_INTENSITIES, M_HIST_LIST, &HistResult); /* Calculate the histogram. */ MimHistogram(MilImage, HistResult); /* Get the results. */ MimGetResult(HistResult, M_VALUE, HistValues); /* Draw the histogram in the overlay. */ MgraColor(M_DEFAULT, AnnotationColor); for(i=0; i to end.\n\n"); getch(); /* Free all allocations. */ MimFree(HistResult); MbufFree(MilImage); MappFreeDefault(MilApplication, MilSystem, MilDisplay, M_NULL, M_NULL); }