static void CreateImage(UnsignedCharImageType::Pointer image);
int main(int, char*[])
{
UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
CreateImage(image);
for(
unsigned int i = 0; i < neighborhood.
GetSize()[0] * neighborhood.
GetSize()[1]; ++i)
{
neighborhood[i] = 1;
}
NeighborhoodOperatorImageFunctionType::Pointer neighborhoodOperatorImageFunction = NeighborhoodOperatorImageFunctionType::New();
neighborhoodOperatorImageFunction->SetOperator(neighborhood);
neighborhoodOperatorImageFunction->SetInputImage(image);
{
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum on border: " << output << std::endl;
}
{
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum in center: " << output << std::endl;
}
{
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
std::cout << "Sum outside: " << output << std::endl;
}
return EXIT_SUCCESS;
}
void CreateImage(UnsignedCharImageType::Pointer image)
{
UnsignedCharImageType::IndexType start;
start.Fill(0);
UnsignedCharImageType::SizeType size;
size.Fill(100);
UnsignedCharImageType::RegionType region(start,size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 20; r < 80; r++)
{
for(unsigned int c = 20; c < 80; c++)
{
UnsignedCharImageType::IndexType pixelIndex;
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 1);
}
}
}