1 #include "vtkAutoInit.h" 2 VTK_MODULE_INIT(vtkRenderingOpenGL2); 3 VTK_MODULE_INIT(vtkInteractionStyle); 4 5 #include <vtkSmartPointer.h> 6 #include <vtkCamera.h> 7 #include <vtkImageActor.h> 8 #include <vtkImageAnisotropicDiffusion2D.h> 9 #include <vtkImageAnisotropicDiffusion3D.h> 10 #include <vtkImageCast.h> 11 #include <vtkImageData.h> 12 #include <vtkImageMandelbrotSource.h> 13 #include <vtkInteractorStyleImage.h> 14 #include <vtkJPEGReader.h> 15 #include <vtkRenderWindow.h> 16 #include <vtkRenderWindowInteractor.h> 17 #include <vtkRenderer.h> 18 19 //测试图像:../data/lena-gray.jpg 20 int main(int argc, char* argv[]) 21 { 22 vtkSmartPointer<vtkJPEGReader> reader = 23 vtkSmartPointer<vtkJPEGReader>::New(); 24 reader->SetFileName("lena-gray.jpg"); 25 26 vtkSmartPointer<vtkImageAnisotropicDiffusion2D> diffusion = 27 vtkSmartPointer<vtkImageAnisotropicDiffusion2D>::New(); 28 diffusion->SetInputConnection(reader->GetOutputPort()); 29 diffusion->SetNumberOfIterations(10); 30 diffusion->SetDiffusionThreshold(20); 31 diffusion->Update(); 32 33 vtkSmartPointer<vtkImageActor> originalActor = 34 vtkSmartPointer<vtkImageActor>::New(); 35 originalActor->SetInputData(reader->GetOutput()); 36 37 vtkSmartPointer<vtkImageActor> diffusionActor = 38 vtkSmartPointer<vtkImageActor>::New(); 39 diffusionActor->SetInputData(diffusion->GetOutput()); 40 41 double leftViewport[4] = {0.0, 0.0, 0.5, 1.0}; 42 double rightViewport[4] = {0.5, 0.0, 1.0, 1.0}; 43 44 vtkSmartPointer<vtkCamera> camera = 45 vtkSmartPointer<vtkCamera>::New(); 46 vtkSmartPointer<vtkRenderer> leftRenderer = 47 vtkSmartPointer<vtkRenderer>::New(); 48 leftRenderer->SetViewport(leftViewport); 49 leftRenderer->AddActor(originalActor); 50 leftRenderer->SetBackground(1.0, 1.0, 1.0); 51 leftRenderer->SetActiveCamera(camera); 52 leftRenderer->ResetCamera(); 53 54 vtkSmartPointer<vtkRenderer> rightRenderer = 55 vtkSmartPointer<vtkRenderer>::New(); 56 rightRenderer->SetViewport(rightViewport); 57 rightRenderer->SetBackground(1.0, 1.0, 1.0); 58 rightRenderer->AddActor(diffusionActor); 59 rightRenderer->SetActiveCamera(camera); 60 61 vtkSmartPointer<vtkRenderWindow> renderWindow = 62 vtkSmartPointer<vtkRenderWindow>::New(); 63 renderWindow->AddRenderer(leftRenderer); 64 renderWindow->AddRenderer(rightRenderer); 65 renderWindow->SetSize(640, 320); 66 renderWindow->Render(); 67 renderWindow->SetWindowName("AnistropicFilteringExample"); 68 69 vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = 70 vtkSmartPointer<vtkRenderWindowInteractor>::New(); 71 vtkSmartPointer<vtkInteractorStyleImage> style = 72 vtkSmartPointer<vtkInteractorStyleImage>::New(); 73 74 renderWindowInteractor->SetInteractorStyle(style); 75 renderWindowInteractor->SetRenderWindow(renderWindow); 76 renderWindowInteractor->Initialize(); 77 renderWindowInteractor->Start(); 78 79 return EXIT_SUCCESS; 80 }标签:1.0,VTK,滤波,43,vtkSmartPointer,renderWindow,New,include,leftRenderer From: https://www.cnblogs.com/ybqjymy/p/17631002.html