首页 > 其他分享 >VTK 实例47:理想高通滤波器(频域处理)

VTK 实例47:理想高通滤波器(频域处理)

时间:2023-08-15 13:34:37浏览次数:59  
标签:1.0 47 VTK 频域 vtkSmartPointer renderWindow New include leftRenderer

 1 #include "vtkAutoInit.h" 
 2 VTK_MODULE_INIT(vtkRenderingOpenGL2);
 3 VTK_MODULE_INIT(vtkInteractionStyle);
 4 
 5 #include <vtkSmartPointer.h>
 6 #include <vtkImageData.h>
 7 #include <vtkImageIdealHighPass.h>
 8 #include <vtkImageActor.h>
 9 #include <vtkRenderWindow.h>
10 #include <vtkRenderWindowInteractor.h>
11 #include <vtkRenderer.h>
12 #include <vtkJPEGReader.h>
13 #include <vtkImageFFT.h>
14 #include <vtkImageRFFT.h>
15 #include <vtkImageExtractComponents.h>
16 #include <vtkImageCast.h>
17 
18 //测试图像:../data/lena-gray.jpg
19 int main(int argc, char* argv[])
20 {
21     vtkSmartPointer<vtkJPEGReader> reader = 
22         vtkSmartPointer<vtkJPEGReader>::New();
23     reader->SetFileName("lena-gray.jpg");
24     reader->Update();
25 
26     vtkSmartPointer<vtkImageFFT> fftFilter =
27         vtkSmartPointer<vtkImageFFT>::New();
28     fftFilter->SetInputConnection(reader->GetOutputPort());
29     fftFilter->Update();
30 
31     vtkSmartPointer<vtkImageIdealHighPass> highPassFilter = 
32         vtkSmartPointer<vtkImageIdealHighPass>::New();
33     highPassFilter->SetInputConnection(fftFilter->GetOutputPort());
34     highPassFilter->SetXCutOff(0.1);
35     highPassFilter->SetYCutOff(0.1);
36     highPassFilter->Update();
37 
38     vtkSmartPointer<vtkImageRFFT> rfftFilter =
39         vtkSmartPointer<vtkImageRFFT>::New();
40     rfftFilter->SetInputConnection(highPassFilter->GetOutputPort());
41     rfftFilter->Update();
42 
43     vtkSmartPointer<vtkImageExtractComponents> ifftExtractReal =
44         vtkSmartPointer<vtkImageExtractComponents>::New();
45     ifftExtractReal->SetInputConnection(rfftFilter->GetOutputPort());
46     ifftExtractReal->SetComponents(0);
47 
48     vtkSmartPointer<vtkImageCast> castFilter =
49         vtkSmartPointer<vtkImageCast>::New();
50     castFilter->SetInputConnection(ifftExtractReal->GetOutputPort());
51     castFilter->SetOutputScalarTypeToUnsignedChar();
52     castFilter->Update();
53 
54     vtkSmartPointer<vtkImageActor> originalActor =
55         vtkSmartPointer<vtkImageActor>::New();
56     originalActor->SetInputData(reader->GetOutput());
57 
58     vtkSmartPointer<vtkImageActor> erodedActor =
59         vtkSmartPointer<vtkImageActor>::New();
60     erodedActor->SetInputData(castFilter->GetOutput());
61 
62     double leftViewport[4] = {0.0, 0.0, 0.5, 1.0};
63     double rightViewport[4] = {0.5, 0.0, 1.0, 1.0};
64 
65     vtkSmartPointer<vtkRenderWindow> renderWindow =
66         vtkSmartPointer<vtkRenderWindow>::New();
67     renderWindow->SetSize(640, 320);
68     renderWindow->Render();
69     renderWindow->SetWindowName("IdealHighPassExample");
70 
71     vtkSmartPointer<vtkRenderWindowInteractor> interactor =
72         vtkSmartPointer<vtkRenderWindowInteractor>::New();
73     interactor->SetRenderWindow(renderWindow);
74 
75     vtkSmartPointer<vtkRenderer> leftRenderer =
76         vtkSmartPointer<vtkRenderer>::New();
77     renderWindow->AddRenderer(leftRenderer);
78     leftRenderer->SetViewport(leftViewport);
79     leftRenderer->SetBackground(1.0, 1.0, 1.0);
80 
81     vtkSmartPointer<vtkRenderer> rightRenderer =
82         vtkSmartPointer<vtkRenderer>::New();
83     renderWindow->AddRenderer(rightRenderer);
84     rightRenderer->SetViewport(rightViewport);
85     rightRenderer->SetBackground(1.0, 1.0, 1.0);
86 
87     leftRenderer->AddActor(originalActor);
88     rightRenderer->AddActor(erodedActor);
89 
90     leftRenderer->ResetCamera();
91     rightRenderer->ResetCamera();
92 
93     renderWindow->Render();
94     interactor->Start();
95 
96     return EXIT_SUCCESS;
97 }

标签:1.0,47,VTK,频域,vtkSmartPointer,renderWindow,New,include,leftRenderer
From: https://www.cnblogs.com/ybqjymy/p/17631075.html

相关文章

  • VTK 实例48:巴沃斯特高通滤波器(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageButterworthHighPass.h>8#inc......
  • VTK 实例43:各向异性滤波(图像光滑)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkCamera.h>7#include<vtkImageActor.h>8#include<vtkImage......
  • VTK 实例44:二维图像快速傅里叶变换(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageFFT.h>8#include<......
  • VTK 实例35:图像运算(逻辑运算)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkMath.h>7#include<vtkImageData.h>8#include<vtk......
  • VTK 实例36:图像二值化
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkRenderWindow.h>8#include<vtk......
  • VTK 实例37:梯度算子(边缘检测)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkRenderWindow.h>8#include<vtk......
  • VTK 实例38:Sobel梯度算子(边缘检测)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageMathematics.h>7#include<vtkImageData.h>8#inc......
  • VTK 实例39:拉普拉斯算子(边缘检测)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageCanvasSource2D.h>8#include......
  • VTK 实例40:均值滤波(图像光滑)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageConvolve.h>8#include<vt......
  • VTK 实例31:灰度图像直方图
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkActor.h>6#include<vtkBarChartActor.h>7#include<vtkFieldData.h>8#include<v......