void CreateImage(FloatImageType::Pointer image);
void CastRescaleAndWrite(FloatImageType::Pointer image, const std::string& filename);
int main(int, char*[])
{
FloatImageType::Pointer image = FloatImageType::New();
CreateImage(image);
CastRescaleAndWrite(image, "input.png");
SobelOperatorType sobelOperator;
sobelOperator.SetDirection(0);
sobelOperator.CreateToRadius(radius);
NeighborhoodOperatorImageFilterType::Pointer filter = NeighborhoodOperatorImageFilterType::New();
filter->SetOperator(sobelOperator);
filter->SetInput(image);
filter->Update();
CastRescaleAndWrite(filter->GetOutput(), "output.png");
return EXIT_SUCCESS;
}
void CreateImage(FloatImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 20; r < 80; r++)
{
for(unsigned int c = 20; c < 80; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 15);
}
}
}
void CastRescaleAndWrite(FloatImageType::Pointer image, const std::string& filename)
{
RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
rescaleFilter->SetInput(image);
rescaleFilter->SetOutputMinimum(0);
rescaleFilter->SetOutputMaximum(255);
rescaleFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(filename);
writer->SetInput(rescaleFilter->GetOutput());
writer->Update();
}