ITK  6.0.0
Insight Toolkit
SphinxExamples/src/Core/SpatialObjects/CreateALineSpatialObject/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
*
* https://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
auto line = LineType::New();
line->SetPoints(points);
size.Fill(50);
imageFilter->SetInsideValue(255); // white
imageFilter->SetSize(size);
imageFilter->SetInput(line);
imageFilter->Update();
itk::WriteImage(imageFilter->GetOutput(), "line.png");
return EXIT_SUCCESS;
}
itk::LineSpatialObject
Representation of a Line based on the spatial object classes.
Definition: itkLineSpatialObject.h:43
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::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itkSpatialObjectToImageFilter.h
itkImageFileWriter.h
itkLineSpatialObjectPoint.h
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
New
static Pointer New()
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itkLineSpatialObject.h
itk::WriteImage
ITK_TEMPLATE_EXPORT void WriteImage(TImagePointer &&image, const std::string &filename, bool compress=false)
Definition: itkImageFileWriter.h:256