itk中的基本数学运算

来源:互联网 发布:2016开淘宝店晚不晚 编辑:程序博客网 时间:2024/05/01 21:14
数字图像处理的本质就是数学运算,今天我们看下itk中的有哪些基本的数学运算。

//1、加,减,乘(注意,没有除哦)#include "itkAddImageFilter.h"//加#include "itkSubtractImageFilter.h"//减#include "itkMultiplyImageFilter.h"//乘typedef itk::AddImageFilter <ImageType, ImageType >mathFilterType;mathFilterType::Pointer mathFilter= mathFilterType::New ();mathFilter->SetInput1(input1);mathFilter->SetInput2(input2);mathFilter->Update();typedef itk::SubtractImageFilter <ImageType, ImageType >mathFilterType;mathFilterType::Pointer mathFilter= mathFilterType::New ();mathFilter->SetInput1(input1);mathFilter->SetInput2(input2);mathFilter->Update();typedef itk::MultiplyImageFilter <ImageType, ImageType >mathFilterType;mathFilterType::Pointer mathFilter= mathFilterType::New ();mathFilter->SetInput1(input1);mathFilter->SetInput2(input2);mathFilter->Update();//2、与,或,非#include "itkAndImageFilter.h"//与#include "itkOrImageFilter.h"//或#include "itkBinaryNotImageFilter.h"//非typedef itk::AndImageFilter <ImageType, ImageType >mathFilterType;mathFilterType::Pointer mathFilter= mathFilterType::New ();mathFilter->SetInput1(input1);mathFilter->SetInput2(input2);mathFilter->Update();typedef itk::OrImageFilter <ImageType, ImageType >mathFilterType;mathFilterType::Pointer mathFilter= mathFilterType::New ();mathFilter->SetInput1(input1);mathFilter->SetInput2(input2);mathFilter->Update();typedef itk::BinaryNotImageFilter <ImageType>       mathFilterType; mathFilterType::Pointer mathFilter = mathFilterType::New();mathFilter ->SetInput(input1);mathFilter ->Update();//3、膨胀,腐蚀,开,闭#include "itkBinaryBallStructuringElement.h"//基本球形#include "itkBinaryMorphologicalOpeningImageFilter.h"//开运算#include "itkBinaryMorphologicalClosingImageFilter.h"//闭运算#include "itkGrayscaleErodeImageFilter.h"//灰度膨胀#include "itkGrayscaleDilateImageFilter.h"//灰度膨胀#include "itkBinaryDilateImageFilter.h"//二值膨胀#include "itkBinaryErodeImageFilter.h"//二值膨胀typedef itk::BinaryBallStructuringElement<ImageType::PixelType, ImageType::ImageDimension>StructuringElementType;StructuringElementType structuringElement;structuringElement.SetRadius(rad);structuringElement.CreateStructuringElement();typedef itk::BinaryMorphologicalOpeningImageFilter <ImageType, ImageType, StructuringElementType> BinaryMorphologicalOpeningImageFilterType;BinaryMorphologicalOpeningImageFilterType::Pointer mathOperationFilter= BinaryMorphologicalOpeningImageFilterType::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::BinaryMorphologicalClosingImageFilter <ImageType, ImageType, StructuringElementType>BinaryMorphologicalClosingImageFilterType;BinaryMorphologicalClosingImageFilterType::Pointer mathOperationFilter= BinaryMorphologicalClosingImageFilterType::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::GrayscaleErodeImageFilter <ImageType, ImageType, StructuringElementType>GrayscaleErodeImageFilterType;GrayscaleErodeImageFilterType::Pointer mathOperationFilter = GrayscaleErodeImageFilterType::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::GrayscaleDilateImageFilter <ImageType, ImageType, StructuringElementType>GrayscaleDilateImageFilterType;GrayscaleDilateImageFilterType::Pointer mathOperationFilter = GrayscaleDilateImageFilterType::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::BinaryErodeImageFilter  <ImageType, ImageType, StructuringElementType>BinaryErodeImageFilter ;BinaryErodeImageFilter ::Pointer mathOperationFilter = BinaryErodeImageFilter ::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::BinaryDilateImageFilter  <ImageType, ImageType, StructuringElementType>BinaryDilateImageFilter ;BinaryDilateImageFilter ::Pointer mathOperationFilter = BinaryDilateImageFilter ::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->Update();typedef itk::BinaryErodeImageFilter  <ImageType, ImageType, StructuringElementType>BinaryErodeImageFilter ;BinaryErodeImageFilter ::Pointer mathOperationFilter = BinaryErodeImageFilter ::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->SetBackgroundValue(0);mathOperationFilter->SetForegroundValue(1);mathOperationFilter->Update();typedef itk::BinaryDilateImageFilter  <ImageType, ImageType, StructuringElementType>BinaryDilateImageFilter ;BinaryDilateImageFilter ::Pointer mathOperationFilter = BinaryDilateImageFilter ::New();mathOperationFilter->SetInput(*input);mathOperationFilter->SetKernel(structuringElement);mathOperationFilter->SetBackgroundValue(0);mathOperationFilter->SetForegroundValue(1);mathOperationFilter->Update();


Σ( ° △ °|||)︴,代码写的多了,文采果然越来越烂,除了注释,居然不知道写些什么。这样下去不是办法,我会尽力从最简单的写起。