在 ITK 中获取区域最小值坐标

Getting regional minima coordinates in ITK

我是 ITK 新手,想获取模糊 2D 图像的区域最小值(强度)的位置。应用 itk::RegionalMinimaImageFilter 后,我想将这些点存储在一个向量中。我对该特定部分的代码如下所示:

// find regional minima
typedef itk::RegionalMinimaImageFilter <FloatImageType, ImageType > RegionalMinimaImageFilterType;
RegionalMinimaImageFilterType::Pointer regionalMinimaImageFilter = RegionalMinimaImageFilterType::New ();
regionalMinimaImageFilter->SetInput(gaussianFilter->GetOutput());
regionalMinimaImageFilter->Update();

在此之后,我想我需要调用 regionalMinimaImageFilter->GetIndexedOutputs();,但我不太确定。如何简单的得到区域最小值的位置?

你可以做的就是用索引迭代器简单地遍历输出,存储所有像素的坐标,其值等于你使用 SetForegroundValue 方法在 RegionalMinimaImageFilter 中设置的前景值>它可以完成或多或少像这样(尚未测试代码):

//Declare an iterator of a given type to iterate in all the image
//See how to declare the iterator type in the example given
IteratorType outputIt( outputImage, filter->GetOutput()->GetRequestedRegion());

//Go to the begin of the image
outputIt.GoToBegin();

//Iterate over the image
while( !outputIt.IsAtEnd() )
{
    if ( outputIt.Get() == filter->GetForegroundValue () ) {
        ImageType::IndexType idx = outputIt.GetIndex();
        //Print the coordinates of the pixel 
        //This are array coordinates, to get 'world' coordinates
        //multiply by spacing and add origin
        std::cout << "Coordinates : " << idx[0] << "," << idx[1] << std::endl;
    }
    ++outputIt; //Go to the next pixel
}

这是浏览 ITK 图像的标准方法,无论尺寸如何。它将首先经过第一个维度,然后到达第二个维度,依此类推。

可以在此处找到使用索引迭代器的完整示例:http://www.itk.org/Doxygen45/html/Iterators_2ImageRegionIteratorWithIndex_8cxx-example.html

您还可以在 ITK 手册 (http://www.itk.org/ItkSoftwareGuide.pdf) 的第 6.3 节中阅读有关迭代器的内容。