ITK/Examples/ImageProcessing/RGBToLuminanceImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==RGBToLuminanceImageFilter.cxx== <source lang="cpp"> #include "itkImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkNormalizeImageFilter.h" #...")
 
(Deprecated content that is moved to sphinx)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==RGBToLuminanceImageFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkNormalizeImageFilter.h"
#include "itkRGBToLuminanceImageFilter.h"


typedef itk::Image<itk::RGBPixel<unsigned char>, 2>  RGBImageType;
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
typedef itk::Image<float, 2>  ScalarImageType;
 
int main(int argc, char *argv[])
{
  // Verify arguments
  if(argc < 2)
    {
    std::cerr << "Required: input output" << std::endl;
    return EXIT_FAILURE;
    }
 
  // Parse arguments
  std::string inputFileName = argv[1];
  std::string outputFileName = argv[2];
 
  typedef itk::ImageFileReader<RGBImageType> ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(inputFileName);
  reader->Update();
 
  typedef itk::RGBToLuminanceImageFilter< RGBImageType, ScalarImageType > LuminanceFilterType;
  LuminanceFilterType::Pointer luminanceFilter = LuminanceFilterType::New();
  luminanceFilter->SetInput(reader->GetOutput());
  luminanceFilter->Update();
 
  typedef itk::ImageFileWriter<ScalarImageType> WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName(outputFileName);
  writer->SetInput(luminanceFilter->GetOutput());
  writer->Update();
 
  return EXIT_SUCCESS;
}
 
</source>
 
{{ITKCMakeLists|BinaryThinningImageFilter}}

Latest revision as of 13:57, 31 May 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.

[ITK Sphinx Examples]