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[]) 282、效果
原始图像:
去除小连通域之后
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
spc文件怎么看,spc文件用什么打开?
0文件怎么看,0文件用什么打开?
sparseimage文件怎么看,sparseimage文件用什么打开?
sp文件怎么看,sp文件用什么打开?
dv文件怎么看,dv文件用什么打开?
soundpack文件怎么看,soundpack文件用什么打开?
dus文件怎么看,dus文件用什么打开?
dtw文件怎么看,dtw文件用什么打开?
spdf文件怎么看,spdf文件用什么打开?
0文件怎么看,0文件用什么打开?