[vtkusers] show a histogram

daliang_guo daliang_guo at 163.com
Tue May 15 08:19:24 EDT 2007


how to show a histogram?I' a new vtkuser,and  now I'm try to show a histogram of an image(dicom).I tried in this way.But the histogram looks ugly.if i want to show it with vtk,what should i do?help me,please.  /////////////////////////////////void HISTOGRAM::OnPaint()
{
 CPaintDC dc(this);
 CWnd* pWnd=GetDlgItem(IDC_DLG_HIST_SHOW);
 
 CDC *pDC=pWnd->GetDC();
 pWnd->Invalidate();
 pWnd->UpdateWindow(); CPen *pPenRed=new CPen;  pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));  CPen* pOldPen=pDC->SelectObject(pPenRed);  pDC->MoveTo(10,10);  pDC->LineTo(10,280);  pDC->LineTo(320,280);  long MaxCount=0;
 for(int i=0;i<65536;i++)
 {
  if(Hist[i]>MaxCount)
   MaxCount=Hist[i];
 }
 CString strTemp;
 strTemp.Format("%d",MaxCount);
 pDC->TextOut(25,25,strTemp);
 CPen *pPenBlue=new CPen;
 
  pPenBlue->CreatePen(PS_SOLID,1,RGB(0,0,255));
 pDC->SelectObject(pPenBlue); if(MaxCount>0)
  for(int i=0;i<65536;i=i+1)
  {
   pDC->MoveTo(i+10,280);
   pDC->LineTo(i+10,281-(int)(Hist[i]*10000/MaxCount));
  }
 
 pDC->SelectObject(pOldPen);
 
 delete pPenRed;
 delete pPenBlue;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070515/e505152b/attachment.htm>


More information about the vtkusers mailing list