ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/SpatialObjects/LineSpatialObject.cxx
int main( int argc, char *argv[] )
{
using PixelType = unsigned char;
constexpr unsigned int Dimension = 2;
using SpatialObjectToImageFilterType = itk::SpatialObjectToImageFilter<
LineType, ImageType >;
// Create a list of points
std::vector<LineType::LinePointType> points;
for(unsigned int i = 0; i < 20; i++)
{
LineType::LinePointType point;
point.SetPosition(10,i);
normal[0] = 0;
normal[1] = 1;
point.SetNormal(normal,0);
points.push_back(point);
}
// Create a line from the list of points
LineType::Pointer line = LineType::New();
line->SetPoints(points);
SpatialObjectToImageFilterType::Pointer imageFilter =
SpatialObjectToImageFilterType::New();
size.Fill(50);
imageFilter->SetInsideValue(255); // white
imageFilter->SetSize(size);
imageFilter->SetInput(line);
imageFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("line.png");
writer->SetInput( imageFilter->GetOutput() );
writer->Update();
return EXIT_SUCCESS;
}