ITK 形态学运算

 

膨胀、腐蚀、开、闭运算、顶帽、低帽:

#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();
 


TopHat是应用在灰度图像的。TopHat算法本质是形态学变换中开闭运算的组合。
WhiteTopHat:原图像-开运算结果
BlackTopHat:闭运算结果-原图像

原文:https://blog.csdn.net/rabbitbride/article/details/73179465 

#include "itkBlackTopHatImageFilter.h"
#include "itkWhiteTopHatImageFilter.h"

typedef itk::BinaryBallStructuringElement<PixelType, ImageDimension > SRType;
SRType kernel;
kernel.SetRadius( 22 );
kernel.CreateStructuringElement();
 
//typedef itk::WhiteTopHatImageFilter<ImageType,ImageType,SRType > TopHatFilterType;
typedef itk::BlackTopHatImageFilter<ImageType,ImageType,SRType > TopHatFilterType;
TopHatFilterType::Pointer topHatFilter = TopHatFilterType::New();
topHatFilter->SetInput( intput_data );
topHatFilter->SetSafeBorder( false);
topHatFilter->SetKernel( kernel );
topHatFilter->Update();

 

原文:https://blog.csdn.net/rabbitbride/article/details/72356474 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值