SlideShare una empresa de Scribd logo
1 de 38
ITK Input/Output Kitware Inc.
Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
IO Factory Mechanism
Why do we need a Factory? How many file formats can you list? … (and many more exist…)
Supported file formats 2D Only - JPEG (.jpg/.jpeg) - Bitmap (.bmp) - PNG (.png) 2D/3D - Analyze 3.5 - GIPL (.gipl) - RAW (.raw) - DICOM - GE 4x,5x - IPLCommon - MetaImage (.mha/.mhd) - Siemens - Stimulate - TIFF - VTKImage  - NRRD - LSM - NIFTI
How does the Factory work? reading JPEGImageIO TIFFImageIO DICOMImageIO AnalyzeImageIO Image Filename itk::Image Image IO Factory … Can you read this file?
How does the Factory work? writing JPEGImageIO TIFFImageIO DICOMImageIO AnalyzeImageIO Image Filename itk::Image Image IO Factory … Can you write this file?
Image File IO
Reading my first image #include <itkImageFileReader.h>   typedef unsigned char PixelType;  typedef itk::Image<PixelType, 2>  ImageType ;   itk::ImageFileReader< ImageType > ::Pointer  reader     =  itk::ImageFileReader< ImageType > ::New();     reader->SetFileName (“ lena.jpg ”);     try   {   reader->Update() ;   }   catch (itk::ExceptionObject & e)   {   std::cerr << e.GetDescription() << std::endl;   return EXIT_FAILURE;   }    ImageType::Pointer image =  reader->GetOutput() ;
Writing my first image #include <itkImageFileWriter.h>   typedef unsigned char PixelType;  typedef itk::Image<PixelType, 2>  ImageType ;   itk::ImageFileWriter< ImageType > ::Pointer  writer     =  itk::ImageFileWriter< ImageType > ::New();     writer->SetFileName (“ lena.jpg ”);   writer->SetInput (image);     try   {   writer- >Update();   }   catch (itk::ExceptionObject & e)   {   std::cerr << e.GetDescription() << std::endl;   return EXIT_FAILURE;   }
My file format converter itk::ImageFileReader< ImageType > ::Pointer  reader     =  itk::ImageFileReader< ImageType > ::New();   itk::ImageFileWriter< ImageType > ::Pointer  writer     =  itk::ImageFileWriter< ImageType > ::New();   reader ->SetFileName(“myImage. jpg ”)    writer->SetFileName (“myImage .tiff ”);   writer->SetInput ( reader->GetOutput() );     try   {   writer- >Update();   }   catch (itk::ExceptionObject & e)   {   std::cerr << e.GetDescription() << std::endl;   return EXIT_FAILURE;   }
How to avoid using the Factory? #include <itkTIFFImageIO.h>   itk::TIFFImageIO::Pointer tiffImageIO = itk::TIFFImageIO::New();    reader->SetFilename(“ myimage.tiff ”);    reader->SetImageIO( tiffImageIO );  reader->Update();   ,[object Object],[object Object]
Reading RAW images #include  <itkRawImageIO.h>       itk::RawImageIO<unsigned short,2>::Pointer  io ;   io  = itk::RawImageIO<unsigned short,2>::New();   io ->SetFileName(“myimage .raw ”);   unsigned int dim[2] = {800,60};   double spacing[2] = {0.8, 0.8};   double origin[2] = {0.0,0.0};   for(unsigned int i=0; i<2; i++)   {   io -> SetDimensions (i,dim[i]);   io -> SetSpacing (i,spacing[i]);   io -> SetOrigin (i,origin[i]);   }   io -> SetHeaderSize (0);   io -> SetByteOrderToLittleEndian ();   io -> SetPixelType (itk::ImageIOBase::SCALAR);   io -> SetNumberOfComponents (1);
Reading RAW images (2) itk::ImageFileReader< ImageType > ::Pointer  reader     =  itk::ImageFileReader< ImageType > ::New();   reader ->SetFileName(“myImage. raw ”);   reader ->SetImageIO( io );   try   {   reader->Update();   }   catch (itk::ExceptionObject & e)   {   std::cerr << e.GetDescription() << std::endl;   return EXIT_FAILURE;   }
Creating a MetaImage Header NDims = 3 DimSize = 100 200 300 ElementSpacing = 1.2 1.2 1.0 ElementType = MET_UCHAR ElementByteOrderMSB = False ElementDataFile =  HeadMRVolume.raw OR  ElementDataFile =  HeadMRVolume%04d.raw 0 10 1 ,[object Object],[object Object],[object Object]
Dealing with DICOM images ,[object Object],[object Object],[object Object]
Reading DICOM images // Select the correct files from the directory   typedef  itk::ImageSeriesReader < ImageType >  ReaderType;   ReaderType::Pointer  reader  = ReaderType::New();  typedef  itk::GDCMSeriesFileNames  NamesGeneratorType;  NamesGeneratorType::Pointer  nameGenerator  = NamesGeneratorType::New();   nameGenerator ->SetUseSeriesDetails( true );   nameGenerator->SetDirectory ( “./MyDirectory/” );  typedef std::vector< std::string >  FileNamesContainer;  FileNamesContainer fileNames;   fileNames = nameGenerator->GetFileNames(  seriesIdentifier  );     reader->SetFileNames (  fileNames  );   // Set the DicomIO   typedef itk::GDCMImageIO  ImageIOType;  ImageIOType::Pointer dicomIO = ImageIOType::New();    reader->SetImageIO ( dicomIO );  reader->Update();
More on Series Filenames ,[object Object],[object Object]
Metadata
MetaData ,[object Object],[object Object]
MetaData Dictionary ,[object Object],[object Object],[object Object],[object Object],  ImageType::Pointer image =  reader ->GetOutput();   typedef itk::MetaDataDictionary  DictionaryType;   DictionaryType & dictionary = image->GetMetaDataDictionary();
Transform File IO
Transform IO ,[object Object],[object Object],[object Object],[object Object]
Write Transform Example #include &quot;itkTransformFileWriter.h”  #include &quot;itkAffineTransform.h”   typedef itk::AffineTransform<double,3> AffineTransformType;   AffineTransformType::Pointer  affine  = AffineTransformType::New();   itk::TransformFileWriter::Pointer  writer ;   writer  = itk::TransformFileWriter::New();     writer->AddTransform ( affine );   writer->SetFileName ( “AffineTransform.txt&quot; );   try   {   writer->Update() ;   }   catch( itk::ExceptionObject & excp )   {   std::cerr << excp << std::endl;   return EXIT_FAILURE;   }
Read Transform Example #include &quot;itkTransformFileReader.h”     itk::TransformFileReader::Pointer  reader ;   reader  = itk::TransformFileReader::New();     reader ->SetFileName ( “AffineTransform.txt&quot; );   reader ->Update() ;  typedef itk::TransformFileReader::TransformListType * TransformListType;  TransformListType  transforms  =  reader ->GetTransformList() ;  itk::TransformFileReader::TransformListType::const_iterator  it ;   it   =  transforms ->begin();  if(!strcmp((* it )->GetNameOfClass(),&quot;AffineTransform&quot;))   {   AffineTransformType::Pointer affineTransform =    static_cast<AffineTransformType*>((* it ).GetPointer());   }
Object File IO
Spatial Objects ,[object Object],[object Object],[object Object],[object Object]
Spatial Object Example Liver Tumor Blood Vessels Abdomen Kidneys
Spatial Objects IO ,[object Object],[object Object],[object Object],[object Object],[object Object]
Writing Spatial Objects #include &quot;itkSpatialObjectWriter.h”  #include &quot;itkEllipseSpatialObject.h”     typedef itk::EllipseSpatialObject<3> SphereType;  SphereType::Pointer  sphere  = SphereType::New();   sphere ->SetRadius(2);   typedef  itk::SpatialObjectWriter<3>  WriterType;  WriterType::Pointer  writer  = WriterType::New();   writer ->SetInput( sphere );   writer ->SetFileName( &quot;ellipse.meta&quot; );   writer ->Update();
Reading Spatial Objects #include &quot;itkSpatialObjectReader.h”     typedef  itk::SpatialObjectReader<3>  ReaderType;  ReaderType::Pointer  reader  = ReaderType::New();   reader ->SetFileName( &quot;ellipse.meta&quot; );   reader ->Update(); // Return an itk::SceneSpatialObject with all the objects in the file ReaderType::ScenePointer  scene  =  reader -> GetScene() ; // Return an itk::GroupSpatialObject with all the objects in the file ReaderType::GroupPointer group =  reader -> GetGroup() ;  ReaderType::SceneType::ObjectListType *  sceneChildren  =  scene ->GetObjects(999);  ReaderType::SceneType::ObjectListType::const_iterator  objectIterator ;  objectIterator =  sceneChildren ->begin();  if(!strcmp((*  objectIterator )->GetTypeName(),“EllipseSpatialObject&quot;))   {   SphereType::Pointer sphere = dynamic_cast<SphereType*>((* objectIterator ).GetPointer());   }
Writing an itkMesh #include &quot;itkSpatialObjectWriter.h”  #include &quot;itkMeshSpatialObject.h”   typedef itk::DefaultDynamicMeshTraits< float , 3, 3 >  MeshTrait ;  typedef itk::Mesh<float,3,MeshTrait>  MeshType ;  MeshType::Pointer  mesh  = MeshType::New();   // Create the mesh Spatial Object  MeshSpatialObjectType::Pointer  meshSO  =  MeshSpatialObjectType::New();   meshSO ->SetMesh( mesh );     // Writing the file  typedef itk:: SpatialObjectWriter<3,float,MeshTrait>  WriterType;  WriterType::Pointer  writer  = WriterType::New();   writer ->SetInput( meshSO );   writer ->SetFileName(&quot;metamesh.txt&quot;);   writer ->Update();
Logging Capabilities
Logger ,[object Object],[object Object],[object Object],[object Object]
Logger in use #include <itkLogger.h>  #include <itkStdStreamLogOutput.h>     itk::Logger::Pointer  logger  = itk::Logger::New();  itk::StdStreamLogOutput::Pointer  output  =  itk::StdStreamLogOutput::New();   output ->SetStream(std::cout); logger -> SetName (“MyLogger”); logger -> SetPriorityLevel (itk::LoggerBase::INFO); logger -> SetLevelForFlushing (itk::LoggerBase::CRITICAL); logger -> AddLogOutput ( output ); logger -> Write (itk::LoggerBase::INFO, &quot;This is the INFO message.&quot;);
Logger Manager ,[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object]
Enjoy ITK  !

Más contenido relacionado

La actualidad más candente

Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseAlexandra N. Martinez
 
Hibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic IntroductionHibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic IntroductionEr. Gaurav Kumar
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Alexandra N. Martinez
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - PraticalsFahad Shaikh
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptecker
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Alexandra N. Martinez
 
Java simple programs
Java simple programsJava simple programs
Java simple programsVEERA RAGAVAN
 
Swift Basics with iOS 8 features
Swift Basics with iOS 8 featuresSwift Basics with iOS 8 features
Swift Basics with iOS 8 featuresVivekChaudharyDev
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Datagreenwop
 
JDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJosé Paumard
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data ModelKros Huang
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript ConceptsNaresh Kumar
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL fileRACHIT_GUPTA
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 

La actualidad más candente (20)

Reviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-caseReviewing a Complex DataWeave Transformation Use-case
Reviewing a Complex DataWeave Transformation Use-case
 
Hibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic IntroductionHibernate working with criteria- Basic Introduction
Hibernate working with criteria- Basic Introduction
 
Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2Reviewing a Complex DataWeave Transformation Use-case v2
Reviewing a Complex DataWeave Transformation Use-case v2
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
Java generics final
Java generics finalJava generics final
Java generics final
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - Praticals
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
 
Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3Reviewing a complex dataweave transformation use case v3
Reviewing a complex dataweave transformation use case v3
 
Java simple programs
Java simple programsJava simple programs
Java simple programs
 
Swift Basics with iOS 8 features
Swift Basics with iOS 8 featuresSwift Basics with iOS 8 features
Swift Basics with iOS 8 features
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
JDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easy
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
Thread
ThreadThread
Thread
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 

Similar a ITK Tutorial Presentation Slides-948

Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and OutputEduardo Bergavera
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12Vince Vo
 
Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talkdtdannen
 
For this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdfFor this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdffathimahardwareelect
 
OSCON 2005: Build Your Own Chandler Parcel
OSCON 2005: Build Your Own Chandler ParcelOSCON 2005: Build Your Own Chandler Parcel
OSCON 2005: Build Your Own Chandler ParcelTed Leung
 
Instagram filters (10-5)
Instagram filters (10-5)Instagram filters (10-5)
Instagram filters (10-5)Ivy Rueb
 
jQuery for Sharepoint Dev
jQuery for Sharepoint DevjQuery for Sharepoint Dev
jQuery for Sharepoint DevZeddy Iskandar
 
the next web now
the next web nowthe next web now
the next web nowzulin Gu
 
HTMLarea to CKEditor - create presets and your own plugin for TYPO3
HTMLarea to CKEditor - create presets and your own plugin for TYPO3HTMLarea to CKEditor - create presets and your own plugin for TYPO3
HTMLarea to CKEditor - create presets and your own plugin for TYPO3Frans Saris
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component PresentationJohn Coonen
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8PrinceGuru MS
 
Rapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingRapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingFelix Meschberger
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderAndres Almiray
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architectureViktor Nyblom
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 

Similar a ITK Tutorial Presentation Slides-948 (20)

Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
Java căn bản - Chapter12
Java căn bản - Chapter12Java căn bản - Chapter12
Java căn bản - Chapter12
 
Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talk
 
For this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdfFor this project your task is to update the RSS Reader program you w.pdf
For this project your task is to update the RSS Reader program you w.pdf
 
OSCON 2005: Build Your Own Chandler Parcel
OSCON 2005: Build Your Own Chandler ParcelOSCON 2005: Build Your Own Chandler Parcel
OSCON 2005: Build Your Own Chandler Parcel
 
Django
DjangoDjango
Django
 
Jsoup tutorial
Jsoup tutorialJsoup tutorial
Jsoup tutorial
 
Instagram filters (10-5)
Instagram filters (10-5)Instagram filters (10-5)
Instagram filters (10-5)
 
jQuery for Sharepoint Dev
jQuery for Sharepoint DevjQuery for Sharepoint Dev
jQuery for Sharepoint Dev
 
the next web now
the next web nowthe next web now
the next web now
 
HTMLarea to CKEditor - create presets and your own plugin for TYPO3
HTMLarea to CKEditor - create presets and your own plugin for TYPO3HTMLarea to CKEditor - create presets and your own plugin for TYPO3
HTMLarea to CKEditor - create presets and your own plugin for TYPO3
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
Rapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingRapid JCR Applications Development with Sling
Rapid JCR Applications Development with Sling
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilder
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architecture
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 

Más de Kitware Kitware

Radial Thickness Calculation and Visualization for Volumetric Layers-8397
Radial Thickness Calculation and Visualization for Volumetric Layers-8397Radial Thickness Calculation and Visualization for Volumetric Layers-8397
Radial Thickness Calculation and Visualization for Volumetric Layers-8397Kitware Kitware
 
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...Kitware Kitware
 
Automatic Brain Segmentation-3770
Automatic Brain Segmentation-3770Automatic Brain Segmentation-3770
Automatic Brain Segmentation-3770Kitware Kitware
 
Nrrd to Dicom Conversion-3769
Nrrd to Dicom Conversion-3769Nrrd to Dicom Conversion-3769
Nrrd to Dicom Conversion-3769Kitware Kitware
 
Functional Magnetic Resonance Imaging Analysis-3765
Functional Magnetic Resonance Imaging Analysis-3765Functional Magnetic Resonance Imaging Analysis-3765
Functional Magnetic Resonance Imaging Analysis-3765Kitware Kitware
 
Diffusion Tensor Imaging Analysis-3749
Diffusion Tensor Imaging Analysis-3749Diffusion Tensor Imaging Analysis-3749
Diffusion Tensor Imaging Analysis-3749Kitware Kitware
 
Manual Segmentation-3747
Manual Segmentation-3747Manual Segmentation-3747
Manual Segmentation-3747Kitware Kitware
 
Data Loading and Visualization-3735
Data Loading and Visualization-3735Data Loading and Visualization-3735
Data Loading and Visualization-3735Kitware Kitware
 
Principles and Practices of Scientific Originology-8392
Principles and Practices of Scientific Originology-8392Principles and Practices of Scientific Originology-8392
Principles and Practices of Scientific Originology-8392Kitware Kitware
 
Principles and Practices of Scientific Originology-8391
Principles and Practices of Scientific Originology-8391Principles and Practices of Scientific Originology-8391
Principles and Practices of Scientific Originology-8391Kitware Kitware
 
ITK Tutorial Presentation Slides-953
ITK Tutorial Presentation Slides-953ITK Tutorial Presentation Slides-953
ITK Tutorial Presentation Slides-953Kitware Kitware
 
ITK Tutorial Presentation Slides-952
ITK Tutorial Presentation Slides-952ITK Tutorial Presentation Slides-952
ITK Tutorial Presentation Slides-952Kitware Kitware
 
ITK Tutorial Presentation Slides-951
ITK Tutorial Presentation Slides-951ITK Tutorial Presentation Slides-951
ITK Tutorial Presentation Slides-951Kitware Kitware
 
ITK Tutorial Presentation Slides-950
ITK Tutorial Presentation Slides-950ITK Tutorial Presentation Slides-950
ITK Tutorial Presentation Slides-950Kitware Kitware
 
ITK Tutorial Presentation Slides-949
ITK Tutorial Presentation Slides-949ITK Tutorial Presentation Slides-949
ITK Tutorial Presentation Slides-949Kitware Kitware
 
ITK Tutorial Presentation Slides-947
ITK Tutorial Presentation Slides-947ITK Tutorial Presentation Slides-947
ITK Tutorial Presentation Slides-947Kitware Kitware
 
ITK Tutorial Presentation Slides-946
ITK Tutorial Presentation Slides-946ITK Tutorial Presentation Slides-946
ITK Tutorial Presentation Slides-946Kitware Kitware
 

Más de Kitware Kitware (20)

Radial Thickness Calculation and Visualization for Volumetric Layers-8397
Radial Thickness Calculation and Visualization for Volumetric Layers-8397Radial Thickness Calculation and Visualization for Volumetric Layers-8397
Radial Thickness Calculation and Visualization for Volumetric Layers-8397
 
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...
A Framework for Comparison and Evaluation of Nonlinear Intra-Subject Image Re...
 
Registration-3771
Registration-3771Registration-3771
Registration-3771
 
Automatic Brain Segmentation-3770
Automatic Brain Segmentation-3770Automatic Brain Segmentation-3770
Automatic Brain Segmentation-3770
 
Nrrd to Dicom Conversion-3769
Nrrd to Dicom Conversion-3769Nrrd to Dicom Conversion-3769
Nrrd to Dicom Conversion-3769
 
Data Saving-3767
Data Saving-3767Data Saving-3767
Data Saving-3767
 
FreeSurfer Reader-3766
FreeSurfer Reader-3766FreeSurfer Reader-3766
FreeSurfer Reader-3766
 
Functional Magnetic Resonance Imaging Analysis-3765
Functional Magnetic Resonance Imaging Analysis-3765Functional Magnetic Resonance Imaging Analysis-3765
Functional Magnetic Resonance Imaging Analysis-3765
 
Diffusion Tensor Imaging Analysis-3749
Diffusion Tensor Imaging Analysis-3749Diffusion Tensor Imaging Analysis-3749
Diffusion Tensor Imaging Analysis-3749
 
Manual Segmentation-3747
Manual Segmentation-3747Manual Segmentation-3747
Manual Segmentation-3747
 
Data Loading and Visualization-3735
Data Loading and Visualization-3735Data Loading and Visualization-3735
Data Loading and Visualization-3735
 
Principles and Practices of Scientific Originology-8392
Principles and Practices of Scientific Originology-8392Principles and Practices of Scientific Originology-8392
Principles and Practices of Scientific Originology-8392
 
Principles and Practices of Scientific Originology-8391
Principles and Practices of Scientific Originology-8391Principles and Practices of Scientific Originology-8391
Principles and Practices of Scientific Originology-8391
 
ITK Tutorial Presentation Slides-953
ITK Tutorial Presentation Slides-953ITK Tutorial Presentation Slides-953
ITK Tutorial Presentation Slides-953
 
ITK Tutorial Presentation Slides-952
ITK Tutorial Presentation Slides-952ITK Tutorial Presentation Slides-952
ITK Tutorial Presentation Slides-952
 
ITK Tutorial Presentation Slides-951
ITK Tutorial Presentation Slides-951ITK Tutorial Presentation Slides-951
ITK Tutorial Presentation Slides-951
 
ITK Tutorial Presentation Slides-950
ITK Tutorial Presentation Slides-950ITK Tutorial Presentation Slides-950
ITK Tutorial Presentation Slides-950
 
ITK Tutorial Presentation Slides-949
ITK Tutorial Presentation Slides-949ITK Tutorial Presentation Slides-949
ITK Tutorial Presentation Slides-949
 
ITK Tutorial Presentation Slides-947
ITK Tutorial Presentation Slides-947ITK Tutorial Presentation Slides-947
ITK Tutorial Presentation Slides-947
 
ITK Tutorial Presentation Slides-946
ITK Tutorial Presentation Slides-946ITK Tutorial Presentation Slides-946
ITK Tutorial Presentation Slides-946
 

ITK Tutorial Presentation Slides-948

  • 2.
  • 4. Why do we need a Factory? How many file formats can you list? … (and many more exist…)
  • 5. Supported file formats 2D Only - JPEG (.jpg/.jpeg) - Bitmap (.bmp) - PNG (.png) 2D/3D - Analyze 3.5 - GIPL (.gipl) - RAW (.raw) - DICOM - GE 4x,5x - IPLCommon - MetaImage (.mha/.mhd) - Siemens - Stimulate - TIFF - VTKImage - NRRD - LSM - NIFTI
  • 6. How does the Factory work? reading JPEGImageIO TIFFImageIO DICOMImageIO AnalyzeImageIO Image Filename itk::Image Image IO Factory … Can you read this file?
  • 7. How does the Factory work? writing JPEGImageIO TIFFImageIO DICOMImageIO AnalyzeImageIO Image Filename itk::Image Image IO Factory … Can you write this file?
  • 9. Reading my first image #include <itkImageFileReader.h> typedef unsigned char PixelType; typedef itk::Image<PixelType, 2> ImageType ; itk::ImageFileReader< ImageType > ::Pointer reader = itk::ImageFileReader< ImageType > ::New(); reader->SetFileName (“ lena.jpg ”); try { reader->Update() ; } catch (itk::ExceptionObject & e) { std::cerr << e.GetDescription() << std::endl; return EXIT_FAILURE; } ImageType::Pointer image = reader->GetOutput() ;
  • 10. Writing my first image #include <itkImageFileWriter.h> typedef unsigned char PixelType; typedef itk::Image<PixelType, 2> ImageType ; itk::ImageFileWriter< ImageType > ::Pointer writer = itk::ImageFileWriter< ImageType > ::New(); writer->SetFileName (“ lena.jpg ”); writer->SetInput (image); try { writer- >Update(); } catch (itk::ExceptionObject & e) { std::cerr << e.GetDescription() << std::endl; return EXIT_FAILURE; }
  • 11. My file format converter itk::ImageFileReader< ImageType > ::Pointer reader = itk::ImageFileReader< ImageType > ::New(); itk::ImageFileWriter< ImageType > ::Pointer writer = itk::ImageFileWriter< ImageType > ::New(); reader ->SetFileName(“myImage. jpg ”) writer->SetFileName (“myImage .tiff ”); writer->SetInput ( reader->GetOutput() ); try { writer- >Update(); } catch (itk::ExceptionObject & e) { std::cerr << e.GetDescription() << std::endl; return EXIT_FAILURE; }
  • 12.
  • 13. Reading RAW images #include <itkRawImageIO.h> itk::RawImageIO<unsigned short,2>::Pointer io ; io = itk::RawImageIO<unsigned short,2>::New(); io ->SetFileName(“myimage .raw ”); unsigned int dim[2] = {800,60}; double spacing[2] = {0.8, 0.8}; double origin[2] = {0.0,0.0}; for(unsigned int i=0; i<2; i++) { io -> SetDimensions (i,dim[i]); io -> SetSpacing (i,spacing[i]); io -> SetOrigin (i,origin[i]); } io -> SetHeaderSize (0); io -> SetByteOrderToLittleEndian (); io -> SetPixelType (itk::ImageIOBase::SCALAR); io -> SetNumberOfComponents (1);
  • 14. Reading RAW images (2) itk::ImageFileReader< ImageType > ::Pointer reader = itk::ImageFileReader< ImageType > ::New(); reader ->SetFileName(“myImage. raw ”); reader ->SetImageIO( io ); try { reader->Update(); } catch (itk::ExceptionObject & e) { std::cerr << e.GetDescription() << std::endl; return EXIT_FAILURE; }
  • 15.
  • 16.
  • 17. Reading DICOM images // Select the correct files from the directory typedef itk::ImageSeriesReader < ImageType > ReaderType; ReaderType::Pointer reader = ReaderType::New(); typedef itk::GDCMSeriesFileNames NamesGeneratorType; NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New(); nameGenerator ->SetUseSeriesDetails( true ); nameGenerator->SetDirectory ( “./MyDirectory/” ); typedef std::vector< std::string > FileNamesContainer; FileNamesContainer fileNames; fileNames = nameGenerator->GetFileNames( seriesIdentifier ); reader->SetFileNames ( fileNames ); // Set the DicomIO typedef itk::GDCMImageIO ImageIOType; ImageIOType::Pointer dicomIO = ImageIOType::New(); reader->SetImageIO ( dicomIO ); reader->Update();
  • 18.
  • 20.
  • 21.
  • 23.
  • 24. Write Transform Example #include &quot;itkTransformFileWriter.h” #include &quot;itkAffineTransform.h” typedef itk::AffineTransform<double,3> AffineTransformType; AffineTransformType::Pointer affine = AffineTransformType::New(); itk::TransformFileWriter::Pointer writer ; writer = itk::TransformFileWriter::New(); writer->AddTransform ( affine ); writer->SetFileName ( “AffineTransform.txt&quot; ); try { writer->Update() ; } catch( itk::ExceptionObject & excp ) { std::cerr << excp << std::endl; return EXIT_FAILURE; }
  • 25. Read Transform Example #include &quot;itkTransformFileReader.h” itk::TransformFileReader::Pointer reader ; reader = itk::TransformFileReader::New(); reader ->SetFileName ( “AffineTransform.txt&quot; ); reader ->Update() ; typedef itk::TransformFileReader::TransformListType * TransformListType; TransformListType transforms = reader ->GetTransformList() ; itk::TransformFileReader::TransformListType::const_iterator it ; it = transforms ->begin(); if(!strcmp((* it )->GetNameOfClass(),&quot;AffineTransform&quot;)) { AffineTransformType::Pointer affineTransform = static_cast<AffineTransformType*>((* it ).GetPointer()); }
  • 27.
  • 28. Spatial Object Example Liver Tumor Blood Vessels Abdomen Kidneys
  • 29.
  • 30. Writing Spatial Objects #include &quot;itkSpatialObjectWriter.h” #include &quot;itkEllipseSpatialObject.h” typedef itk::EllipseSpatialObject<3> SphereType; SphereType::Pointer sphere = SphereType::New(); sphere ->SetRadius(2); typedef itk::SpatialObjectWriter<3> WriterType; WriterType::Pointer writer = WriterType::New(); writer ->SetInput( sphere ); writer ->SetFileName( &quot;ellipse.meta&quot; ); writer ->Update();
  • 31. Reading Spatial Objects #include &quot;itkSpatialObjectReader.h” typedef itk::SpatialObjectReader<3> ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader ->SetFileName( &quot;ellipse.meta&quot; ); reader ->Update(); // Return an itk::SceneSpatialObject with all the objects in the file ReaderType::ScenePointer scene = reader -> GetScene() ; // Return an itk::GroupSpatialObject with all the objects in the file ReaderType::GroupPointer group = reader -> GetGroup() ; ReaderType::SceneType::ObjectListType * sceneChildren = scene ->GetObjects(999); ReaderType::SceneType::ObjectListType::const_iterator objectIterator ; objectIterator = sceneChildren ->begin(); if(!strcmp((* objectIterator )->GetTypeName(),“EllipseSpatialObject&quot;)) { SphereType::Pointer sphere = dynamic_cast<SphereType*>((* objectIterator ).GetPointer()); }
  • 32. Writing an itkMesh #include &quot;itkSpatialObjectWriter.h” #include &quot;itkMeshSpatialObject.h” typedef itk::DefaultDynamicMeshTraits< float , 3, 3 > MeshTrait ; typedef itk::Mesh<float,3,MeshTrait> MeshType ; MeshType::Pointer mesh = MeshType::New(); // Create the mesh Spatial Object MeshSpatialObjectType::Pointer meshSO = MeshSpatialObjectType::New(); meshSO ->SetMesh( mesh ); // Writing the file typedef itk:: SpatialObjectWriter<3,float,MeshTrait> WriterType; WriterType::Pointer writer = WriterType::New(); writer ->SetInput( meshSO ); writer ->SetFileName(&quot;metamesh.txt&quot;); writer ->Update();
  • 34.
  • 35. Logger in use #include <itkLogger.h> #include <itkStdStreamLogOutput.h> itk::Logger::Pointer logger = itk::Logger::New(); itk::StdStreamLogOutput::Pointer output = itk::StdStreamLogOutput::New(); output ->SetStream(std::cout); logger -> SetName (“MyLogger”); logger -> SetPriorityLevel (itk::LoggerBase::INFO); logger -> SetLevelForFlushing (itk::LoggerBase::CRITICAL); logger -> AddLogOutput ( output ); logger -> Write (itk::LoggerBase::INFO, &quot;This is the INFO message.&quot;);
  • 36.
  • 37.