VTK系列45_图像进行理想低通滤波器处理(频域处理)
生活随笔
收集整理的這篇文章主要介紹了
VTK系列45_图像进行理想低通滤波器处理(频域处理)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
實(shí)例45:理想低通濾波器(頻域處理)
#include "vtkAutoInit.h" VTK_MODULE_INIT(vtkRenderingOpenGL2); VTK_MODULE_INIT(vtkInteractionStyle);#include <vtkSmartPointer.h> #include <vtkImageData.h> #include <vtkImageIdealLowPass.h> #include <vtkImageActor.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> #include <vtkRenderer.h> #include <vtkJPEGReader.h> #include <vtkImageFFT.h> #include <vtkImageRFFT.h> #include <vtkImageExtractComponents.h> #include <vtkImageCast.h>//測試圖像:../data/lena-gray.jpg int main(int argc, char* argv[]) {vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();reader->SetFileName("lena-gray.jpg");reader->Update();vtkSmartPointer<vtkImageFFT> fftFilter =vtkSmartPointer<vtkImageFFT>::New();fftFilter->SetInputConnection(reader->GetOutputPort());fftFilter->Update();vtkSmartPointer<vtkImageIdealLowPass> lowPassFilter = vtkSmartPointer<vtkImageIdealLowPass>::New();lowPassFilter->SetInputConnection(fftFilter->GetOutputPort());lowPassFilter->SetXCutOff(0.05);lowPassFilter->SetYCutOff(0.05);lowPassFilter->Update();vtkSmartPointer<vtkImageRFFT> rfftFilter =vtkSmartPointer<vtkImageRFFT>::New();rfftFilter->SetInputConnection(lowPassFilter->GetOutputPort());rfftFilter->Update();vtkSmartPointer<vtkImageExtractComponents> ifftExtractReal =vtkSmartPointer<vtkImageExtractComponents>::New();ifftExtractReal->SetInputConnection(rfftFilter->GetOutputPort());ifftExtractReal->SetComponents(0);vtkSmartPointer<vtkImageCast> castFilter =vtkSmartPointer<vtkImageCast>::New();castFilter->SetInputConnection(ifftExtractReal->GetOutputPort());castFilter->SetOutputScalarTypeToUnsignedChar();castFilter->Update();vtkSmartPointer<vtkImageActor> originalActor =vtkSmartPointer<vtkImageActor>::New();originalActor->SetInputData(reader->GetOutput());vtkSmartPointer<vtkImageActor> erodedActor =vtkSmartPointer<vtkImageActor>::New();erodedActor->SetInputData(castFilter->GetOutput());double leftViewport[4] = {0.0, 0.0, 0.5, 1.0};double rightViewport[4] = {0.5, 0.0, 1.0, 1.0};vtkSmartPointer<vtkRenderWindow> renderWindow =vtkSmartPointer<vtkRenderWindow>::New();renderWindow->SetSize(640, 320);renderWindow->Render();renderWindow->SetWindowName("IdealLowPassExample");vtkSmartPointer<vtkRenderWindowInteractor> interactor =vtkSmartPointer<vtkRenderWindowInteractor>::New();interactor->SetRenderWindow(renderWindow);vtkSmartPointer<vtkRenderer> leftRenderer =vtkSmartPointer<vtkRenderer>::New();renderWindow->AddRenderer(leftRenderer);leftRenderer->SetViewport(leftViewport);leftRenderer->SetBackground(1.0, 1.0, 1.0);vtkSmartPointer<vtkRenderer> rightRenderer =vtkSmartPointer<vtkRenderer>::New();renderWindow->AddRenderer(rightRenderer);rightRenderer->SetViewport(rightViewport);rightRenderer->SetBackground(1.0, 1.0, 1.0);leftRenderer->AddActor(originalActor);rightRenderer->AddActor(erodedActor);leftRenderer->ResetCamera();rightRenderer->ResetCamera();renderWindow->Render();interactor->Start();return EXIT_SUCCESS; }VTK系列目錄:
1 VTK基本概念
2 VTK圖像處理
3 VTK圖形處理
4 VTK體繪制
總結(jié)
以上是生活随笔為你收集整理的VTK系列45_图像进行理想低通滤波器处理(频域处理)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 理性预测,未来音视频开发前景将是这般光景
- 下一篇: c4d物体自发光_如何使用C4D制作发光