itk将小图像贴在大图像上面

void pastImageToImage(
	ImagePointerType& big_image, 
	const ImagePointerType& small_image, 
	const int startXYZ[3])
{
    
    
	using pastImageFilterType = itk::PasteImageFilter<ImageType, ImageType>;
	auto pastImageFilter = pastImageFilterType::New();

	ImageType::IndexType index;
	for (int i = 0; i < 3; ++i) {
    
    
		index[i] = startXYZ[i];
	}

	pastImageFilter->SetSourceImage(small_image);
	pastImageFilter->SetSourceRegion(small_image->GetLargestPossibleRegion());
	pastImageFilter->SetDestinationImage(big_image);
	pastImageFilter->SetDestinationIndex(index);

	try {
    
    
		pastImageFilter->Update();
	}
	catch (const itk::ExceptionObject& e) {
    
    
		std::cout << e.what() << std::endl;
	}
	big_image = pastImageFilter->GetOutput();
}

猜你喜欢

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