ITK/Examples/Visualization/QuickViewDemo: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
m (moved ITK/Examples/Visualization/QuickView to ITK/Examples/Visualization/QuickViewDemo: QuickView.cxx was already the name of the actual QuickView implementation file!)
(Deprecated content that is moved to sphinxed)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==QuickView.cxx==
{{warning|1=The media wiki content on this page is no longer maintainedThe examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releasesIn 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 "itkRescaleIntensityImageFilter.h"
 
#include "QuickView.h"
 
typedef itk::Image<unsigned char, 2> ImageType;
 
static void CreateImage(ImageType* const image);
 
int main(int argc, char *argv[])
{
  ImageType::Pointer image;
 
  if(argc < 2)
    {
    //std::cerr << "Required: filename" << std::endl;
    //return EXIT_FAILURE;
    image = ImageType::New();
    CreateImage(image);
    }
  else
  {
    typedef itk::ImageFileReader<ImageType> ReaderType;
    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName(argv[1]);
    image = reader->GetOutput();
  }
 
  typedef itk::RescaleIntensityImageFilter< ImageType, ImageType > RescaleFilterType;
  RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
  rescaleFilter->SetInput(image);
  rescaleFilter->SetOutputMinimum(0);
  rescaleFilter->SetOutputMaximum(255);
  rescaleFilter->Update();
 
  QuickView viewer;
  viewer.AddImage(image.GetPointer());
  viewer.AddImage(rescaleFilter->GetOutput());
  viewer.Visualize();
 
  return EXIT_SUCCESS;
}
 
void CreateImage(ImageType* const image)
{
  // Create an image with 2 connected components
  ImageType::IndexType corner = {{0,0}};
 
  ImageType::SizeType size;
  unsigned int NumRows = 200;
  unsigned int NumCols = 300;
  size[0] = NumRows;
  size[1] = NumCols;
 
   ImageType::RegionType region(corner, size);
 
  image->SetRegions(region);
  image->Allocate();
 
  // Make a square
  for(unsigned int r = 40; r < 100; r++)
    {
    for(unsigned int c = 40; c < 100; c++)
      {
      ImageType::IndexType pixelIndex;
      pixelIndex[0] = r;
      pixelIndex[1] = c;
 
      image->SetPixel(pixelIndex, 15);
      }
    }
}
 
</source>
 
{{ITKCMakeLists|QuickView}}

Latest revision as of 23:47, 7 June 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.