MINC/軟體開發/EZMINC/ITK整合
外觀
如果您對 ITK 提供的僅 MINC2 介面不滿意,或者需要訪問 MINC 檔案屬性,或者想要讀取/寫入 4D 資料,請使用 EZMINC 提供的 ITK 介面
使用 ITK 支援編譯 EZMINC,請參閱 [EZMINC_安裝] 如果您沒有使用 ITK 外掛(目前不推薦使用外掛),請將以下程式碼新增到您的 ITK 程式中以將其“mincify”
#include "itkMincImageIOFactory.h"
#include "itkMincImageIO.h"
//....
int main(int argc,char **argv)
{
//registering the MINC_IO factory
itk::ObjectFactoryBase::RegisterFactory(itk::MincImageIOFactory::New());
//....
來自示例中的 itk_dti.cpp 的程式碼
- 應用變換
來自 itk_resample.cpp 的程式碼
#include "itkMincImageIOFactory.h"
#include "itkMincImageIO.h"
#include "minc_helpers.h"
typedef itk::ResampleImageFilter<minc::image3d, minc::image3d> FilterType;
typedef minc::XfmTransform TransformType;
//...
TransformType::Pointer transform = TransformType::New();
//reading a minc style xfm file
transform->OpenXfm(xfm_f.c_str());
transform->Invert();
filter->SetTransform( transform );
//...
- 將仿射變換儲存在 .xfm 檔案中
#include <minc_helpers.h>
//...
itk::AffineTransform<double,3> m_AffineTransform;
//...
minc::write_linear_xfm(output_xfm, m_AffineTransform->GetMatrix(), m_AffineTransform->GetOffset());
- 從 .xfm 檔案中讀取仿射變換
itk::AffineTransform<double,3> m_AffineTransform;
//...
itk::Matrix<double,3,3> rotation;
itk::Vector<double,3> translation;
read_linear_xfm(input_xfm,rotation,translation);
//...
m_AffineTransform.SetOffset(translation);
m_AffineTransform.SetMatrix(rotation);
- 讀取/寫入 .tag 檔案
std::vector<int> labels;
std::vector<itk::Point<double>,3> tags;
read_tags(tags, labels, input_tag);
//....
write_tags(tags, labels, ouput_tag);