ITK 基于C++和ITK获取3D医学图像的最大连通区域


1、代码

1 #include "itkConnectedCponentImageFilter.h" 2 #include "itkImage.h" 3 #include "itkImageFileReader.h" 4 #include "itkImageFileWriter.h" 5 #include "itkImageRegionIterator.h" 6 #include "itkLabelShapeKeepNObjectsImageFilter.h" 7 8 using namespace std; 9 10 void print(const std::string& file, itk::Image<unsigned char, 2>* image) 11 }; 19 auto c = image>GetPixel(index); 20 fout << (int)c; 21 } 22 fout << std::endl; 23 } 24 } 25 26 27 int main(int argc, char *argv[]) 28

2、效果

原始图像:

去除小连通域之后

3、主要函数介绍

itk::ConnectedCponentImageFilter<ImageType, OutputImageType>;

该filter值检测连通区域,不编号,不排序。

itk::LabelShapeKeepNObjectsImageFilter;

该filter对连通区域进行排序,然后只保留最大的几个连通区域。

itk::LabelImageToShapeLabelMapFilter< OutputImageType, LabelMapType> ;

为保留的每个连通区域打上标签(标号),编号顺序为找到不同区域的顺序.

虽然LabelShapeKeepNObjectsImageFilter调用SetAttribute 之后,按照attribute对连通区域大小进行了排序,但该排序并不反映在label上。即大的label并不一定对应大的size。反映在 SetNumberOfObjects(n) 设定保留区域之后,只保留排序后前n个区域的label。

itk::RescaleIntensityImageFilter<OutputImageType, ImageType>;

上一步图像只有标签,图像上没有直接的区别,本步对保留下来的不同连通区域进行不同的染色,以示区分。



上一篇:Qt 专门的宏Q_GLOBAL_STATIC,用来实现线程安全的单例模式

下一篇:Qt 解析命令行(QCommandLineOption和QCommandLineParser类)


ITK
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图