itk中的基本数学运算
2017-05-17 09:13
162 查看
数字图像处理的本质就是数学运算,今天我们看下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();
Σ( ° △ °|||)︴,代码写的多了,文采果然越来越烂,除了注释,居然不知道写些什么。这样下去不是办法,我会尽力从最简单的写起。
相关文章推荐
- MATLAB矩阵的基本数学运算
- JAVA 入坑教程 | 章节十 基本数学运算Math类
- opencv中Mat的数学运算和基本操作
- 数学运算_基本_01
- C++实现对数学基本运算表达式的解析
- 数学运算_基本_01
- php数学运算基本语法
- Shell脚本基础10-基本的数学运算
- 因数分解 因数分解是十分基本的数学运算,应用广泛。下面的程序对整数n(n>1)进行因数分解。 比如,n=60, 则输出:2 2 3 5。请补充缺失的部分。
- 双栈方式实现带括号的基本数学运算
- Java基础教程7-基本数学运算
- 数学运算基本题型速解技巧及实例
- 第三章 基本数学运算
- opencv中Mat的数学运算和基本操作
- 离散数学-集合运算基本法则
- Math:类包含用于执行基本数学运算的方法
- 因数分解 因数分解是十分基本的数学运算,应用广泛。下面的程序对整数n(n>1)进行因数分解。 比如,n=60, 则输出:2 2 3 5。请补充缺失的部分。
- JAVA基础知识思维导图:unit01_开发环境,变量,基本类型及转换,数学运算,流程控制,数组
- C++实现对数学基本运算表达式的解析
- python的基本数学运算