我在访问itk::LabelObject的像素列表时遇到了问题。这个LabelObject是通过itk::OrientedBoundingBoxLabelObject (https://github.com/blowekamp/itkOBBLabelMap)获得的。最初的3D图像是一个CBCT,在其中我正在寻找一个小的矩形标记的位置和方向。
下面是通向itk::LabelObject的代码:
typedef short LabelPixelType;
typedef itk::LabelMap<LabelObjectType> LabelMapType;
typedef itk::OrientedBoundingBoxLabelMapFilter<LabelMapType> OBBLabelMapFilter;
typename OBBLabelMapFilter::Pointer toOBBLabelMap = OBBLabelMapFilter::New();
typename ToLabelMapFilterType::Pointer toLabelMap = ToLabelMapFilterType::New();
toOBBLabelMap->SetInput(toLabelMap->GetOutput());
toOBBLabelMap->Update();
LabelObjectType* labelObject = toOBBLabelMap->GetOutput()->GetNthLabelObject(idx);
OBBSize = labelObject->GetOrientedBoundingBoxSize();我想访问像素坐标是可能的,因为为了计算边界框,必须以某种方式访问它,但到目前为止我还没有做到这一点。然后,我尝试将itk::LabelMap (或LabelObject )转换为二进制图像,在那里我可以更容易地到达像素;并使用VTK转换和显示这个markerBinaryImage,没有更多的结果(我得到一个黑色图像)。
typedef itk::LabelMapToBinaryImageFilter<LabelMapType, ImageType> LabelMapToBinaryImageFilterType;
LabelMapToBinaryImageFilterType::Pointer labelImageConverter = LabelMapToBinaryImageFilterType::New();
labelImageConverter->SetInput(toLabelMap->GetOutput());
labelImageConverter->Update();
ImageType::Pointer markerBinaryImage = labelImageConverter->GetOutput();有人知道如何到达这个像素列表吗?
发布于 2015-10-27 09:44:06
你可以这样做:
for(unsigned int i = 0; i < filter->GetOutput()->GetNumberOfLabelObjects(); ++i) {
    //Obtain the ith label object
    FilterType::OutputImageType::LabelObjectType* labelObject =
        filter->GetOutput()->GetNthLabelObject(i);
    //Then, you may obtain the pixels of each label object like this:
    for(unsigned int pixelId = 0; pixelId < labelObject->Size(); pixelId++) {
        std::cout << labelObject->GetIndex(pixelId);
    }
}这一信息是从“洞察杂志”( Insight Journal )的文章用ITK标记对象表示和操作获得的。在这里,它说您可以直接使用Region属性获得边界框。我没有找到在itk::LabelObject中获取区域的方法,但是下面是itk::LabelObject的继承图

如果标签对象的类型为itk::ShapeLabelObject,则可以使用GetBoundingBox()方法获取边框。它还有其他许多值得研究的方法。
然后我尝试转换itk::LabelMap (.)没有更多的结果(我得到一个黑色的图像)。
这里有一条建议,不要尝试这些复杂的东西来验证其他复杂的东西。你可能在其他地方失败了。相反,像我之前说的那样读取像素并检查数据。看上去不错!
https://stackoverflow.com/questions/33354569
复制相似问题