VTK学习笔记-2-TIFF图像数据的重切片
来源:互联网 发布:mac 命令行打开文件夹 编辑:程序博客网 时间:2024/05/16 02:54
玩了半天,终于可以实现对于TIFF图像的三维重切片。首先需要注意的是vtkTIFFReader并不是支持所有的TIFF压缩格式,比如LZ压缩的就不支持。个人觉得,VTK在DICOM格式上具有更强的操作性,貌似其存在便是针对了DICOM格式而进行的,至于其他格式的数据,有点是后期为了迎合兼容性而做出的各种的添加。再者,VTK的资料是有限有限的,除了那些Examples。。。那个用户手册是要钱的,79美金。。。。。。
#include "vtkImageReader2.h"#include "vtkImageReslice.h"#include "vtkWindowLevelLookupTable.h"#include "vtkImageMapToColors.h"#include "vtkImageActor.h"#include "vtkRenderer.h"#include "vtkRenderWindow.h"#include "vtkRenderWindowInteractor.h"#include "vtkImageData.h"#include<vtkTIFFReader.h>int main (){ vtkTIFFReader *reader= vtkTIFFReader::New();//用tiff进行读取 reader->SetFilePrefix("H:\\Crop_test4_4X4\\");//尝试更大的数据 reader->SetFilePattern("%saaaa_%05d%_bbb.tif");//这个具体的图片的命名,就要看自己的实际操作了 reader->SetDataExtent(0, 63, 0, 63, 188, 230); reader->SetDataSpacing(3.2, 3.2, 1.5); reader->SetDataOrigin(0.0, 0.0, 0.0); reader->SetDataScalarTypeToUnsignedShort(); reader->UpdateWholeExtent(); // 更新并获取图像参数。 reader->GetOutput()->UpdateInformation(); int extent[6]; double spacing[3]; double origin[3]; reader->GetOutput()->GetWholeExtent(extent); reader->GetOutput()->GetSpacing(spacing); reader->GetOutput()->GetOrigin(origin); // 计算中心位置。 double center[3]; center[0] = origin[0] + spacing[0] * 0.5 * (extent[0] + extent[1]); center[1] = origin[1] + spacing[1] * 0.5 * (extent[2] + extent[3]); center[2] = origin[2] + spacing[2] * 0.5 * (extent[4] + extent[5]); //使用下面三个轴重切后,ZSlice将对应原图像横断面(默认) /*static double axialX[3]={ 1, 0, 0}; static double axialY[3]={ 0, 1, 0}; static double axialZ[3]={ 0, 0, 1};*/ // ZSlice对应原图像冠状面(即重切的z轴方向为原y轴方向) // static double coronalX[3]={ 1, 0, 0}; // static double coronalY[3]={ 0, 0,-1}; // static double coronalZ[3]={ 0, 1, 0}; // ZSlice对应原图像矢状面(即重切的z轴方向为原x轴方向) static double sagittalX[3]={ 0, 1, 0}; static double sagittalY[3]={ 0, 0,-1}; static double sagittalZ[3]={-1, 0, 0}; // ZSlice对应原图像斜面 static double obliqueX[3]={ 1, 0, 0}; static double obliqueY[3]={ 0, 0.866025,0.5}; static double obliqueZ[3]={ 0,-0.5, 0.866025}; // 按指定的方向抽取片。 vtkImageReslice *reslice = vtkImageReslice::New(); reslice->SetInputConnection(reader->GetOutputPort()); reslice->SetOutputDimensionality(2); //reslice->SetResliceAxesDirectionCosines(sagittalX, sagittalY, sagittalZ); //reslice->SetResliceAxesDirectionCosines(axialX, axialY, axialZ); reslice->SetResliceAxesDirectionCosines(obliqueX, obliqueY, obliqueZ); reslice->SetResliceAxesOrigin(center); reslice->SetInterpolationModeToLinear(); vtkWindowLevelLookupTable *table=vtkWindowLevelLookupTable::New(); /*table->SetWindow(2000); table->SetLevel(1000);*/ table->SetWindow(200); table->SetLevel(100); vtkImageMapToColors *color = vtkImageMapToColors::New(); color->SetLookupTable(table); color->SetInputConnection(reslice->GetOutputPort()); vtkImageActor *actor = vtkImageActor::New(); actor->SetInput(color->GetOutput()); vtkRenderer *renderer = vtkRenderer::New(); renderer->AddActor(actor); vtkRenderWindow *window = vtkRenderWindow::New(); window->AddRenderer(renderer); vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New(); window->SetInteractor(interactor); window->Render(); interactor->Start(); return 0;}
- VTK学习笔记-2-TIFF图像数据的重切片
- 用VTK读取单张的TIFF图片
- TIFF图像数据的排列方式的装换
- vtk学习笔记——利用vtk显示地震数据
- tiff切片、合并、转换
- 【VTK】VTK中设置默认的三维切片方向
- VTK学习(二)VTK图像创建
- VTK学习(十一)VTK图像显示
- vtk图像的读写
- VTK学习笔记:数据集之多边形数据集
- caffe学习笔记2:计算图像数据集的均值
- Python学习---第2天---数据切片
- Python学习笔记 - 切片
- python学习笔记 切片
- VTK 学习笔记 - 天行健
- VTK学习笔记1
- VTK学习笔记-1
- VTk学习笔记--vtkInteractorStyleRubberBand2D
- error while loading shared libraries的解決方法
- 杭电1007题
- 程序员的禅修之路
- C语言宽字符——字符集与字符编码和宽字符之间的关系
- 怎么在用asp代码来创建Access数据库
- VTK学习笔记-2-TIFF图像数据的重切片
- ubuntu下离线手动安装软件包 例: libncurses5-dev
- 《c专家编程》笔记--define和typedef的区别
- 还有一个月,我不会放弃
- spring 事物管理配置
- 第六周—1.改错
- JavaCC使用小结
- [正能量系列]失业的程序员(一)
- Unix/Linux下的open函数(O_CREAT和O_EXCL)