Tile

Qualified name: crop_row_detector.orthomosaic_tiler.Tile

class Tile(orthomosaic, Upper_left_corner, position, width, height, overlap=0.0, number=0)[source]

Bases: object

Handle all information of a tile with read and write.

Parameters:
  • orthomosaic (pathlib.Path) – The orthomosaic from where the tile is taken.

  • Upper_left_corner (tuple[int, int]) – The pixel coordinate from the orthomosaic of the upper left corner of the tile in (columns, rows).

  • position (tuple[int, int]) – Tile position in orthomosaic in number of tile in (columns, rows).

  • width (float) – Tile width.

  • height (float) – Tile height.

  • overlap (float) – Overlap as a fraction of width and height.

  • number (int) – Used to identify tiles.

Methods

get_window_pixels

Get pixels from tile without overlap.

get_window_pixels_boundary

Get the tiles boundary without the overlap.

read_tile

Read the tiles image data from the orthomosaic.

save_tile

Save the image of the tile to a tiff file.

set_tile_data_from_orthomosaic

Read data about the tile from the orthomosaic.

Attributes

tile_number

The tile number.

window

Window specifying the region of the orthomosaic for this tile.

window_with_overlap

Window specifying the region of the orthomosaic for this tile with overlap of neighboring tiles.

get_window_pixels(image)[source]

Get pixels from tile without overlap.

Parameters:

image (ndarray)

Return type:

ndarray

get_window_pixels_boundary()[source]

Get the tiles boundary without the overlap.

Returns:

  • start_column (int)

  • stop_column (int)

  • start_row (int)

  • stop_row (int)

Return type:

tuple[int, int, int, int]

read_tile(with_overlap=True)[source]

Read the tiles image data from the orthomosaic. If with_overlap is true a window with a border around the tile is used.

Parameters:

with_overlap (bool)

Return type:

tuple[ndarray, ndarray]

save_tile(image, mask, output_tile_location)[source]

Save the image of the tile to a tiff file. Filename is the tile number.

Parameters:
Return type:

None

set_tile_data_from_orthomosaic()[source]

Read data about the tile from the orthomosaic.

Return type:

tuple[Window, Window]

tile_number

The tile number. Useful for identification.

window: Window

Window specifying the region of the orthomosaic for this tile.

window_with_overlap: Window

Window specifying the region of the orthomosaic for this tile with overlap of neighboring tiles.