Available in LEADTOOLS Medical Imaging toolkits. |
GetHistogramGray example for C++ 4.0 and later
This example is for Medical only.
//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 CHistogramGrayDlg::OnButton4()
{
int nRet;
char szMsg[100];
long lMin, lMax;
m_Lead.UnlockSupport(L_SUPPORT_MEDICAL, L_KEY_MEDICAL);
wsprintf(szMsg, "Table size before call to GetHistogramGray: %d", m_Lead.GetHistogramGrayTableSize());
::MessageBox(NULL, szMsg, "", MB_OK);
nRet = m_Lead.GetHistogramGray();
if (nRet == 0)
{
m_Lead.GetMinMaxVal();
lMin = m_Lead.GetMinVal();
lMax = m_Lead.GetMaxVal();
wsprintf(szMsg, "Highest Intensity: 0x%X Count: %d\nLowest Intensity: 0x%X Count:%d",
lMax,
m_Lead.GetHistogramGrayTable(lMax),
lMin,
m_Lead.GetHistogramGrayTable(lMin)
);
::MessageBox(NULL, szMsg, "", MB_OK);
}
wsprintf(szMsg, "Table size after call to GetHistogramGray: %d", m_Lead.GetHistogramGrayTableSize());
::MessageBox(NULL, szMsg, "", MB_OK);
}