Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ITK上标记过滤器的形态分水岭_C++_Image Processing_Image Segmentation_Itk_Watershed - Fatal编程技术网

C++ ITK上标记过滤器的形态分水岭

C++ ITK上标记过滤器的形态分水岭,c++,image-processing,image-segmentation,itk,watershed,C++,Image Processing,Image Segmentation,Itk,Watershed,我正试图用ITK的库创建一个用于图像分割的管道。但是,当我应用ITK形态分水岭FromMarkersFilter时,结果是一个空白图像(只有1的二值图像) 有人知道如何正确应用此过滤器吗 我的输入图像应该是图像的梯度,标记图像应该是在同一图像上应用分水岭过滤器的结果 输入 标记 这是过滤器的声明和应用: typedef itk::MorphologicalWatershedFromMarkersImageFilter < OutputImageType, OutputImageType &

我正试图用ITK的库创建一个用于图像分割的管道。但是,当我应用ITK形态分水岭FromMarkersFilter时,结果是一个空白图像(只有1的二值图像)

有人知道如何正确应用此过滤器吗

我的输入图像应该是图像的梯度,标记图像应该是在同一图像上应用分水岭过滤器的结果

输入

标记

这是过滤器的声明和应用:

typedef itk::MorphologicalWatershedFromMarkersImageFilter < OutputImageType, OutputImageType >
      MorphologicalWatershedFromMarkersImageFilterType;

MorphologicalWatershedFromMarkersImageFilterType::Pointer CwatershedFilter
      = MorphologicalWatershedFromMarkersImageFilterType::New();


CwatershedFilter->SetInput1(reader1->GetOutput());
CwatershedFilter->SetMarkerImage(reader2->GetOutput());

CwatershedFilter->SetMarkWatershedLine(true);

try{

    CwatershedFilter->Update();

}
catch (itk::ExceptionObject & error)
{
    std::cerr << "Error: " << error << std::endl;
    getchar();
    return EXIT_FAILURE;
}
typedef itk::形态学流域来自MarkersImageFilter
MarkersImageFilterType的形态分水岭;
形态学流域来自MarkersImageFilterType::指针CwatershedFilter
=形态学流域FromMarkersImageFilterType::New();
CwatershedFilter->SetInput1(reader1->GetOutput());
CwatershedFilter->SetMarkerImage(reader2->GetOutput());
CwatershedFilter->SetMarkWatershedLine(真);
试一试{
CwatershedFilter->Update();
}
捕获(itk::ExceptionObject&error)
{

STR::CURR

而不是C++ +ITK,有一个SimuleTk笔记本,演示了它的用法:

您的标记图像只是二进制图像,而不是标签图像。我的意思是您的图像仅为0和1(或255)。在链接的示例中,请注意以下内容:

min_img = sitk.RegionalMinima(feature_img, backgroundValue=0, foregroundValue=1.0, fullyConnected=False, flatIsMinima=True)
marker_img = sitk.ConnectedComponent(min_img, fullyConnected=False)
“min_img”是一个二值图像,但随后使用“ConnectedComponent”图像过滤器处理图像,该过滤器为每个“孤岛”提供一个唯一的编号。这是WatershedFromMarker过滤器的标记(或标签)图像的预期值


我还将注意到,您的输入图像有一些边界线,您可能不希望将其作为输入。

如果粘贴相关代码会有所帮助。有代码。我不知道这是否有帮助,但我也粘贴了指向过滤器文档的链接。如果您为代码提供一个更简单的图像,过滤器会工作吗?例如,尝试设置黑色图像以中间的白色正方形作为输入,看看你的代码是否产生正确的结果。这将有助于确定问题是用代码还是输入。我试过,它给出了相同的结果:/谢谢你的例子。我的特点是原稿的梯度。标记图像是一个带有预处理的二值图像。ted:为了更好地查看图像,我的输入图像不应该有边界线。但是如何删除这些边界线?或者应该使用哪个图像?原始RGB图像,还是灰度图像?我不明白。非常感谢您的帮助!