Create An RGB Image

Synopsis

Create an RGB Image

Results

Code

C++

#include "itkImage.h"
#include "itkRGBPixel.h"

int
main(int, char *[])
{
  constexpr unsigned int Dimension = 2;
  using RGBPixelType = itk::RGBPixel<unsigned char>;

  using RGBImageType = itk::Image<RGBPixelType, Dimension>;
  RGBImageType::Pointer image = RGBImageType::New();

  return EXIT_SUCCESS;
}

Python

#!/usr/bin/env python

Dimension = 2
RGBPixelType = itk.RGBPixel[itk.ctype('unsigned char')]

image = itk.Image[RGBPixelType, Dimension].New()

Classes demonstrated