实例15:图像数据测量
// ±?ày×ó?éó?óú?áè?μ¥·ùCTí???2¢??ê??àó|DICOM???t?Dí·D??¢?£
// First include the required header files for the VTK classes we are using.
#include "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include "vtkDICOMImageReader.h"
#include "vtkBMPReader.h"
#include "vtkVolume16Reader.h"
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"
//??2¨oˉêy
#include "vtkImageMagnify.h"
#include "vtkTransform.h"
int main()
{
vtkBMPReader *dr = vtkBMPReader::New();
dr->SetDataByteOrderToLittleEndian();
dr->SetFileName("1234.bmp");
dr->SetDataOrigin(0,0,0.0);
vtkTransform *t1=vtkTransform::New();
t1->RotateZ(0);
dr->SetTransform(t1);
//=================================================
//??2¨2ù×÷
vtkImageMagnify *mfy=vtkImageMagnify::New();
//í???·?′ó,2??áó?
mfy->SetInputConnection(dr->GetOutputPort());
mfy->SetMagnificationFactors(3,2,2);//???ü·?′ó??êy±?,??DCMí????TD§
//=======================================================
vtkImageViewer *viewer = vtkImageViewer::New();
viewer->SetInputConnection(mfy->GetOutputPort());
viewer->SetColorWindow(1000);
viewer->SetColorLevel(200);
viewer->SetPosition(0,0);
viewer->Render();
vtkRenderWindowInteractor *viewerinter = vtkRenderWindowInteractor::New();
viewer->SetupInteractor(viewerinter);
vtkImageViewer *viewer2 = vtkImageViewer::New();
viewer2->SetInputConnection(dr->GetOutputPort());
viewer2->SetColorWindow(256);
viewer2->SetColorLevel(200);
viewer2->SetPosition(0,100);
viewer2->Render();
vtkRenderWindowInteractor *viewerinter2 = vtkRenderWindowInteractor::New();
viewer2->SetupInteractor(viewerinter2);
viewerinter->Initialize();
viewerinter->Start();
// cout<GetPatientName()<GetHeight()<GetWidth()<GetStudyUID()<GetDataByteOrderAsString()<GetHeaderSize()<GetPixelSpacing()<Delete();
mfy->Delete();
viewer->Delete();
viewerinter->Delete();
viewer2->Delete();
viewerinter2->Delete();
return 0;
}
VTK系列目录:
1 VTK基本概念
2 VTK图像处理
3 VTK图形处理
4 VTK体绘制