de.unihalle.informatik.MiToBo.core.datatypes.images
Class MTBImageTileAdapter

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.images.MTBImageTileAdapter
All Implemented Interfaces:
Iterable<MTBImage>

public class MTBImageTileAdapter
extends Object
implements Iterable<MTBImage>

Adapter class to support tile-wise processing of images.

The class performs lazy evalutation, i.e. only actually instantiates a tile image upon request. However, the tiles are not cached, i.e. on each call to getTile(int, int) or getAllTiles() new images are generated.

Author:
moeller

Nested Class Summary
 class MTBImageTileAdapter.TileIterator
          Iterates from top-left to bottom-right over the tiles of an image.
 
Field Summary
protected  MTBImage inImg
          Image to process.
protected  int shiftX
          Offset of the tiles in x dimension.
protected  int shiftY
          Offset of the tiles in y dimension.
protected  int tileColumns
          Number of tile columns.
protected  int tileRows
          Number of tile rows.
protected  int tileSizeX
          Size of a tile in x-dimension.
protected  int tileSizeY
          Size of a tile in y-dimension.
 
Constructor Summary
MTBImageTileAdapter(MTBImage img, int sizeX, int sizeY)
          Default constructor.
MTBImageTileAdapter(MTBImage img, int sizeX, int sizeY, int shiftInX, int shiftInY)
          Default constructor.
 
Method Summary
 MTBImage[][] getAllTiles()
          Generates and returns array of all tiles.
 MTBImage getTile(int idX, int idY)
          Returns tile with given indices.
 int getTileCols()
          Returns number of tiles and colums, respectively, in x-dimension.
 int getTileRows()
          Returns number of tiles and rows, respectively, in y-dimension.
 Iterator<MTBImage> iterator()
           
 void saveTilesToFiles(String prefix)
          Saves all tiles to the given path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tileSizeX

@Parameter(label="Size X",
           required=true,
           dataIOOrder=1,
           direction=IN,
           description="Size X")
protected int tileSizeX
Size of a tile in x-dimension.

Note that the last tile might be smaller if the image size in x is not dividable by the tile size without remainder.


tileSizeY

@Parameter(label="Size Y",
           required=true,
           dataIOOrder=1,
           direction=IN,
           description="Size Y")
protected int tileSizeY
Size of a tile in y-dimension.

Note that the last tile might be smaller if the image size in y is not dividable by the tile size without remainder.


shiftX

@Parameter(label="Shift X",
           required=true,
           dataIOOrder=1,
           direction=IN,
           description="Shift X")
protected int shiftX
Offset of the tiles in x dimension.

If the offset is smaller than the specified tileSizeX, tiles are overlapping. If it is larger, gaps result.


shiftY

@Parameter(label="Shift Y",
           required=true,
           dataIOOrder=1,
           direction=IN,
           description="Shift Y")
protected int shiftY
Offset of the tiles in y dimension.

If the offset is smaller than the specified tileSizeY, tiles are overlapping. If it is larger, gaps result.


inImg

@Parameter(label="Input Image",
           required=true,
           direction=IN,
           description="Input Image")
protected MTBImage inImg
Image to process.


tileRows

protected int tileRows
Number of tile rows.


tileColumns

protected int tileColumns
Number of tile columns.

Constructor Detail

MTBImageTileAdapter

public MTBImageTileAdapter(MTBImage img,
                           int sizeX,
                           int sizeY,
                           int shiftInX,
                           int shiftInY)
Default constructor.

Parameters:
img - Image to be tiled.
sizeX - Tile size in x dimension.
sizeY - Tile size in y dimension.
shiftInX - Tile offset in x dimension.
shiftInY - Tile offset in y dimension.

MTBImageTileAdapter

public MTBImageTileAdapter(MTBImage img,
                           int sizeX,
                           int sizeY)
Default constructor.

Parameters:
img - Image to be tiled.
sizeX - Tile size in x dimension.
sizeY - Tile size in y dimension.
Method Detail

getTileRows

public int getTileRows()
Returns number of tiles and rows, respectively, in y-dimension.

Returns:
Number of y-tiles.

getTileCols

public int getTileCols()
Returns number of tiles and colums, respectively, in x-dimension.

Returns:
Number of x-tiles.

getTile

public MTBImage getTile(int idX,
                        int idY)
Returns tile with given indices.

Parameters:
idX - Column index.
idY - Row index.
Returns:
Tile image.

getAllTiles

public MTBImage[][] getAllTiles()
Generates and returns array of all tiles.

The tiles are arranged in the same order like in the image, i.e. the first index refers to the column and the second index to the row.

Returns:
All tiles of image.

saveTilesToFiles

public void saveTilesToFiles(String prefix)
Saves all tiles to the given path.

The tiles are saved in .tiff format. The file names are formed by the prefix followed by '-' with suffix '.tif'. Note that internally the operator ImageWriterMTB is used, however, the calls are not documented in the processing history.

Parameters:
prefix - Path or filename where to save the images.

iterator

public Iterator<MTBImage> iterator()
Specified by:
iterator in interface Iterable<MTBImage>


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.