ITK过滤浮点数组

问题描述 投票:0回答:1

我想使用ITK来过滤连续浮动数组中的3D卷。我要应用this example中所示的曲率流过滤器。

我不知道如何将我的float数组与ITK接口,然后如何在另一侧获得一个float数组。会修改数据吗?如何运作?

这里有一些代码来演示我正在尝试做的事情。

#include "itkCurvatureFlowImageFilter.h"

int main(int argc, char *argv[])
{
    float *my_array; // I have an array I have generated elsewhere
    // This is a 3D volume in order XYZ with these dimensions along each axis
    size_t num_x = 125;
    size_t num_y = 250;
    size_t num_z = 125;
    size_t num_elements = num_x * num_y * num_z;
    float voxel_size = 8e-3; // 8 mm voxels

    constexpr unsigned int Dimension = 3;

    // convert to an itk image
    // itkimage = ???

    using InputPixelType = float;
    using InputImageType = itk::Image<InputPixelType, Dimension>;

    const int numberOfIterations = 10;
    const InputPixelType timeStep = 0.05;


    using FilterType = itk::CurvatureFlowImageFilter<InputImageType, InputImageType>;
    FilterType::Pointer filter = FilterType::New();
    filter->SetInput(itkimage);
    filter->SetNumberOfIterations(numberOfIterations);
    filter->SetTimeStep(timeStep);

    // now I want to put the filter result back in th array
    filter->GetOutput();
    // Is the data modified in place? How can I get a regular float array out??

    return EXIT_SUCCESS;
}
c++ itk
1个回答
0
投票

itk::ImportImageFilter用于将某些数组表示为图像。查看文档中链接的示例。

由于CurvatureFlowImageFilter源自InPlaceImageFilter,并且您的输入和输出像素类型相同(浮动),因此可以就地运行。但是您仍然需要请求:

itkimage = import...;
...
filter->SetInput(itkimage );
// set other parameters
filter->SetInPlace(true);
filter->Update();
itkimage = filter->GetOutput();
© www.soinside.com 2019 - 2024. All rights reserved.