#include <mil.h>
#if M_MIL_USE_RT
#define MIL_SLAVE_EXPORT __declspec(dllexport)
#else
#define MIL_SLAVE_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
MIL_SLAVE_EXPORT void MFTYPE SlaveCustomRemap(MIL_ID Func);
#ifdef __cplusplus
}
#endif
void MFTYPE SlaveCustomRemap(MIL_ID Func)
{
MIL_ID SrcImage, DstImage, OwnerSystem, ExtremeResult, Lut;
MIL_UINT Option;
MIL_INT MinAndMax[2];
MfuncParamValue(Func, 1, &SrcImage);
MfuncParamValue(Func, 2, &DstImage);
MfuncParamValue(Func, 3, &Option);
MbufInquire(SrcImage, M_OWNER_SYSTEM, &OwnerSystem);
MimAllocResult(OwnerSystem, 2L, M_EXTREME_LIST, &ExtremeResult);
MimFindExtreme(SrcImage, ExtremeResult, M_MIN_VALUE+M_MAX_VALUE);
MimGetResult(ExtremeResult, M_VALUE, MinAndMax);
MimFree(ExtremeResult);
MbufAlloc1d(OwnerSystem, 256, 8+M_UNSIGNED, M_LUT, &Lut);
MgenLutRamp(Lut, MinAndMax[0], 0x00, MinAndMax[1], 0xFF);
MimLutMap(SrcImage, DstImage, Lut);
MbufFree(Lut);
}