Skip to content, Skip to search

Changes

ImgLib2 Examples

153 bytes removed, 10:42, 18 November 2013
Update Example 1b to reflect new SCIFIO ImgOpener
=== Example 1b - Opening an ImgLib2 image ===
The typical way to open an image in ImgLib2 is to make use of the [http://lociscif.wisc.edu/softwareio/bio-formats OME Bio-FormatsSCIFIO] importer. Below you see two examples of how open to an image as ''(a)'' its own type (e.g. '''UnsignedByteType''') and ''(b)'' as float ('''FloatType'''). For ''(a)'' we assume, however, that the file contains some real valued numbers as defined by the interface '''RealType''' (see here for a complete Type hierarchy). Color images are opened as well and color is represented as its own dimension (like in the ImageJ Hyperstacks).
Note that for ''(a)'' we use an '''ArrayImg''' to hold the data. This means the data is held in one single java basic type array which results in optimal performance. The absolute size of image is, however, limited to 2^31-1 (~2 billion) pixels. The type of '''Img''' to use is defined set by passing an '''ImgFactoryImgOptions'''. The configuration when calling the '''ArrayImgFactoryImgOpener''' in this case has no arguments.
In ''(b)'' we use the a '''CellImg''' instead. It partitions the image data into n-dimensional cells each holding only a part of the data. The size Further, SCIFIO takes care of each cell is defined caching cells in the '''CellImgFactory'''. If you use the maximal cell size and out of 2^31-1 pixels (i.e. a maximally sized java native type array)memory as needed, you can address up greatly reducing the memory requirement to 2^62 pixels (~4 exapixels or 4 billion gigapixels) in one '''Img'''work with very large images.
The Bio-Formats SCIFIO importer also requires '''Types''' that implement '''NativeType''', which means it is able to map the data into an java a Java basic type array. All available '''Types''' until now are implementing '''NativeType''', if you want to work with some self-developed '''Type''' it would be easiest to copy the opened '''Img''' afterwards. Please also note that until now, the only '''Img''' that supports non-native types is the '''ListImg''' which stores every pixel as an individual object!
'''Important''': it does not matter which type of '''Img''' you use to hold the data as we will use '''Iterators''' and '''RandomAccesses''' to access the image content. It might be, however, important if you work on two '''Img''' at the same time using '''Iterators''', see Example2.
Bureaucrat, emailconfirmed, incoming, administrator, uploaders
11,833
edits