static void CreateKernel(ImageType::Pointer kernel, unsigned int width);
int main(int argc, char * argv[])
{
if( argc < 2 )
{
std::cerr << "Usage: ";
std::cerr << argv[0] << "inputImageFile [width]" << std::endl;
return EXIT_FAILURE;
}
unsigned int width = 3;
if (argc > 2)
{
width = atoi(argv[2]);
}
ImageType::Pointer kernel = ImageType::New();
CreateKernel(kernel, width);
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
FilterType::Pointer convolutionFilter = FilterType::New();
convolutionFilter->SetInput(reader->GetOutput());
#if ITK_VERSION_MAJOR >= 4
convolutionFilter->SetKernelImage(kernel);
#else
convolutionFilter->SetImageKernelInput(kernel);
#endif
reader->GetOutput(),true,
itksys::SystemTools::GetFilenameName(argv[1]));
std::stringstream desc;
desc << "ConvolutionFilter\n"
<< "Kernel Witdh = " << width;
convolutionFilter->GetOutput(),
true,
desc.str());
return EXIT_SUCCESS;
}
void CreateKernel(ImageType::Pointer kernel, unsigned int width)
{
region.SetIndex(start);
kernel->SetRegions(region);
kernel->Allocate();
while(!imageIterator.IsAtEnd())
{
imageIterator.Set(1);
++imageIterator;
}
}