FARSIGHT Tutorials/Multi-Component Images

From FarsightWiki
Jump to: navigation, search

Contents

Details

  • Goal: This tutorial is intended to show you how to decompose multi-component (also known as multi-channel) images into individual channels in FARSIGHT
  • Duration: 30 minutes
  • Requisites: Having completed the tutorial: Quick Start for users of ITK (30 minutes)
  • Materials: FARSIGHT Installed

Basics Concepts

Image Nature

  • Multi-channel images: are images for which every pixel contains multiple scalar values. They are common in microsocopy as
    • RGB color images
    • Images acquired with multiple color filters
      • Images corresponding to different frequencies of fluorescent proteins

It is common for the number of components in an image to be known only when the image is loaded into memory.

ITK Image Types

The proper type for managing multi-component images is the

itk.VectorImage

You can create an itk.VectorImage with the following Python command

vimage1 = itk.VectorImage[ itk.UC, 2 ].New()

This will create an image of 2 dimensions, where every pixel has components represented as "unsigned chars" and therefore encoded in 8-bits.

You can then create a reader for this type of images with the command

vreader1 = itk.ImageFileReader[ vimage1 ].New()
vreader1.SetFileName(pathToImages+"/peppers.png")
vreader1.Update()
vimage1 = vreader1.GetOutput()

a more direct way of doing this will be

reader1 = itk.ImageFileReader.VIUC2.New(FileName=pathToImages+"/peppers.png")
image = reader.GetOutput()
itk.write( image, pathToImages+"/peppers2.mhd")
  • Note that the symbol VIUC2 is used to indicate
    • V: Vector
    • I: Image
    • U: Unsigned
    • C: Char
    • 2: Two-dimensional

Extracting one Component

A common operation with multi-component images is to extract one of their components and store it into a scalar image. This could be done with the following commands

componentFilter = itk.VectorIndexSelectionCastImageFilter[itk.VectorImage.UC2,itk.Image.UC2].New()
componentFilter.SetInput( reader.GetOutput() )
componentFilter.SetIndex(0);
componentFilter.Update()
pepper0 = componentFilter.GetOutput()
itk.write( pepper0, pathToImages+"/peppers0.png")