GetHistogramGray example for C++ 5.0 and later
//This example gets a histogram for a 12-bit or 16-bit grayscale image and then
//displays the number of occurrences of the brightest and darkest intensities
void CRemapHueDlg::OnGetHistogramGray()
{
int nRet;
CString strMsg;
ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
if (pRasterProc != NULL)
{
strMsg.Format(TEXT("Table size before call to GetHistogramGray: %d"), pRasterProc->GetHistogramGrayTableSize ());
MessageBox(strMsg);
nRet = pRasterProc->GetHistogramGray (m_LEADRasterView1.GetRaster());
if(nRet == 0)
{
m_LEADRasterView1.GetRaster().GetMinMaxVal ();
strMsg.Format(TEXT("Highest Intensity: 0x%0x Count: %d\nLowest Intensity: 0x%0x Count: %d"),
m_LEADRasterView1.GetRaster().GetMaxVal (),
pRasterProc->GetHistogramGrayTable(m_LEADRasterView1.GetRaster().GetMaxVal()),
m_LEADRasterView1.GetRaster().GetMinVal (),
pRasterProc->GetHistogramGrayTable (m_LEADRasterView1.GetRaster().GetMinVal())
);
MessageBox(strMsg);
}
strMsg.Format(TEXT("Table size of current histogram: %d"), pRasterProc->GetHistogramGrayTableSize());
MessageBox(strMsg);
pRasterProc->Release();
}
}