ITK  5.2.0
Insight Toolkit
SphinxExamples/src/Core/SpatialObjects/LineSpatialObject2/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
int
main(int itkNotUsed(argc), char * itkNotUsed(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.SetPositionInObjectSpace(10, i);
LineType::LinePointType::CovariantVectorType normal;
normal[0] = 0;
normal[1] = 1;
point.SetNormalInObjectSpace(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();
using WriterType = itk::ImageFileWriter<ImageType>;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("line.png");
writer->SetInput(imageFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
itk::LineSpatialObject
Representation of a Line based on the spatial object classes.
Definition: itkLineSpatialObject.h:40
itk::Size< 2 >
itk::SpatialObjectToImageFilter
Base class for filters that take a SpatialObject as input and produce an image as output....
Definition: itkSpatialObjectToImageFilter.h:41
itk::Size::Fill
void Fill(SizeValueType value)
Definition: itkSize.h:211
itk::ImageFileWriter
Writes image data to a single file.
Definition: itkImageFileWriter.h:87
itkSpatialObjectToImageFilter.h
itkImageFileWriter.h
itkLineSpatialObjectPoint.h
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itkLineSpatialObject.h