itk提取感兴趣区域

itk::IndexValueType startx, starty, startz;
itk::IndexValueType endx, endy, endz;
using FilterType = itk::RegionOfInterestImageFilter<ImageType, ImageType>;
auto filter = FilterType::New();
filter->SetInput(input_image);


startx = static_cast<itk::IndexValueType>(0);
starty = static_cast<itk::IndexValueType>(0);
startz = static_cast<itk::IndexValueType>(0);
ImageType::IndexType start;
start[0] = startx;
start[1] = starty;
start[2] = startz;

endx = static_cast<itk::IndexValueType>(63);
endy = static_cast<itk::IndexValueType>(63);
endz = static_cast<itk::IndexValueType>(63);
ImageType::IndexType end;
end[0] = endx;
end[1] = endy;
end[2] = endz;

ImageType::RegionType region;
region.SetIndex(start);
region.SetUpperIndex(end);
filter->SetRegionOfInterest(region);

try {
    
    
	filter->Update();
}
catch (const itk::ExceptionObject& e) {
    
    
	std::cout << e.what() << std::endl;
}
patchImage = filter->GetOutput(); // [64,64,64]

猜你喜欢

转载自blog.csdn.net/sdhdsf132452/article/details/130759165
今日推荐