当前位置:网站首页>VTK image sequence mouse interactive flipping
VTK image sequence mouse interactive flipping
2022-06-12 12:41:00 【April 16!】
Read a group dcm Images , Mouse interactive flipping , Take some
#include <vtkAbstractPicker.h>
#include <itkGDCMImageIO.h>
#include <itkGDCMSeriesFileNames.h>
#include <itkImageSeriesReader.h>
#include <vtkPolyDataMapper.h>
#include <vtkImageData.h>
#include <vtkProperty.h>
#include <vtkRendererCollection.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkSmartPointer.h>
#include <vtkMetaImageReader.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkMarchingCubes.h>
#include <vtkStripper.h>
#include <vtkDecimatePro.h>
#include <vtkSmoothPolyDataFilter.h>
#include <vtkPolyDataNormals.h>
#include <vtkActor.h>
#include <vtkImageActor.h>
#include <vtkTriangleFilter.h>
#include <vtkMassProperties.h>
#include <vtkDICOMImageReader.h>
#include <vtkImageViewer2.h>
#include <vtkInteractorStyleImage.h>
#include <vtkCornerAnnotation.h>
#include <vtkAbstractMapper3D.h>
#include <vtkInteractorStyleImage.h>
#include "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <vtkTextProperty.h>
typedef int16_t PixelType;
typedef itk::Image< PixelType, 3 > ImageType;
class Interactor : public vtkInteractorStyleTrackballCamera {
protected:
vtkImageViewer2 *Viewer;
int CurrentSliceNum = 1;
int num = 0;
int SliceNum;
ImageType::SizeType Dim;
ImageType::SpacingType Spacing;
ImageType::PointType origin;
ImageType::Pointer Image;
ImageType::IndexType point_tempx;
public:
static Interactor *New();
vtkTypeMacro(Interactor, vtkInteractorStyleTrackballCamera);
void SetViewer(vtkImageViewer2 *viewer) { this->Viewer = viewer; }
void SetImage(ImageType::Pointer ima) {
Image = ima;
Spacing = Image->GetSpacing();
origin = Image->GetOrigin();
Dim = Image->GetLargestPossibleRegion().GetSize();
SliceNum = Dim[2];
}
void OnMouseWheelForward() override {
//+
if (CurrentSliceNum < SliceNum) CurrentSliceNum++;
this->Viewer->SetSlice(CurrentSliceNum);
this->Viewer->GetRenderer()->ResetCamera(); // need
}
void OnMouseWheelBackward() override {
//-
if (CurrentSliceNum > 1) CurrentSliceNum--;
this->Viewer->SetSlice(CurrentSliceNum);
this->Viewer->GetRenderer()->ResetCamera(); // need
}
void OnLeftButtonDown() override {
this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0],
this->Interactor->GetEventPosition()[1],
0, // always zero.
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double world_pos[3];
this->Interactor->GetPicker()->GetPickPosition(world_pos);
point_tempx[0] = (world_pos[0] - origin[0]) / Spacing[0];
point_tempx[1] = (world_pos[1] - origin[1]) / Spacing[1];
point_tempx[2] = (world_pos[2] - origin[2]) / Spacing[2];
this->Viewer->GetRenderWindow()->GetInteractor()->Render();
vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
}
void OnKeyDown() override {
std::string key = this->GetInteractor()->GetKeySym();
if (key.compare("Left") == 0)
{
// do something
}
}
~Interactor() {}
};
vtkStandardNewMacro(Interactor);
#include <vtkPointPicker.h>
#include"itkImageToVTKImageFilter.h"
int main() {
// read dcm
//also can be read using vtk
std::string dicom_path = "D:/xiaoxue/CTdata/mask/3Dircadb1.14/PATIENT_DICOM";
ImageType::Pointer inputImg = LoadDicom<ImageType>(dicom_path);
typedef itk::ImageToVTKImageFilter< ImageType > itkTovtkFilterType;
auto itkTovtkImageFilter_Liver = itkTovtkFilterType::New();
itkTovtkImageFilter_Liver->SetInput(inputImg);
itkTovtkImageFilter_Liver->Update();
vtkNew<vtkPointPicker> pointPicker;
vtkSmartPointer<vtkImageViewer2> viewer =
vtkSmartPointer<vtkImageViewer2>::New();
viewer->SetInputData(itkTovtkImageFilter_Liver->GetOutput());
viewer->SetSize(800, 800);
viewer->SetSliceOrientationToXY();
viewer->GetRenderer()->SetBackground(1, 1, 1);
vtkSmartPointer<vtkRenderWindowInteractor> rwi =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
rwi->SetPicker(pointPicker);
viewer->SetupInteractor(rwi);
vtkSmartPointer<Interactor> imagestyle =
vtkSmartPointer<Interactor>::New();
imagestyle->SetViewer(viewer);
imagestyle->SetImage(inputImg);
rwi->SetInteractorStyle(imagestyle);
viewer->Render();
rwi->Start();
return 0;
}
边栏推荐
- Object. Detailed explanation of assign()
- [VIM] VIM plug-in youcompleteme configuration file
- OpenMAX (OMX)框架
- C语言进阶篇——深度解剖数据在内存中的存储(配练习)
- Pre order, middle order and post order traversal of tree
- Is yuancosmos a short-term speculation or a future trend?
- AND THE BIT GOES DOWN: REVISITING THE QUANTIZATION OF NEURAL NETWORKS
- Three dimensional coordinate point fitting sphere (MATLAB and C)
- Easy to use assistant tools and websites
- 【C语言】关键字static&&多文件&&猜字游戏
猜你喜欢

MySQL 分区表介绍与测试
![[JS] some handwriting functions: deep copy, bind, debounce, etc](/img/f8/cf51a24450a88abb9e68c78e0e3aa8.jpg)
[JS] some handwriting functions: deep copy, bind, debounce, etc

You can't just use console Log ()?

Uniapp wechat applet long press the identification QR code to jump to applet and personal wechat

Binary tree (serialization)

Vs2019 set ctrl+/ as shortcut key for annotation and uncomment

Advanced chapter of C language -- ten thousand words explanation pointer and qsort function

NewOJ Week 10题解

Advanced C language -- storage of deep anatomical data in memory (with exercise)

八大误区,逐个击破(2):性能差?应用程序少?你对云的这些担心很多余!
随机推荐
Boot entry directory
Binary tree (program)
2021-11-16
[HXBCTF 2021]easywill
Three dimensional coordinate point fitting sphere (MATLAB and C)
Brush questions [de1ctf 2019]shellshellshell
Typescript and abstract classes
Numpy数值计算基础
Summary of knowledge points of ES6, ES7, es8, es9, ES10, es11 and ES12 (interview)
Typeof and instanceof, how to simulate the implementation of an instanceof? Is there a general detection data type?
Geek challenge 2021 Web
Map and set of ES6
【Leetcode】637. Layer average of binary tree
【vim】vim插件YouCompleteMe配置文件
二叉树(纲领篇)
Uniapp wechat applet long press the identification QR code to jump to applet and personal wechat
三维坐标点拟合球(matlab and C )
Principle of master-slave replication of redis
Object. Detailed explanation of assign()
this.$ How to solve the problem when refs is undefined?