Module providing a generator to iterate over the image.

class satsense.generators.BalancedGenerator(image: satsense.image.Image, masks, p=None, samples=None, offset=(0, 0), shape=None)[source]

Bases: object

Balanced window generator.

  • image (Image) – Satellite image
  • masks (1-D array-like) – List of masks, one for each class, to use for generating patches A mask should have a positive value for the array positions that are included in the class
  • p (1-D array-like, optional) – The probabilities associated with each entry in masks. If not given the sample assumes a uniform distribution over all entries in a.
  • samples (int, optional) – The maximum number of samples to generate, otherwise infinite


Using BalancedGenerator

>>> from satsense.generators import BalancedGenerator
>>> BalancedGenerator(image,
                      [class1_mask, class2_mask, class3_mask],
                      [0.33, 0.33, 0.33])
class satsense.generators.FullGenerator(image: satsense.image.Image, step_size: tuple, offset=(0, 0), shape=None)[source]

Bases: object

Window generator that covers the full image.

  • image (Image) – Satellite image
  • step_size (tuple(int, int)) – Size of the steps to use to iterate over the image (in pixels)
  • offset (tuple(int, int)) – Offset from the (0, 0) point (in number of steps).
  • shape (tuple(int, int)) – Shape of the generator (in number of steps)
load_image(itype, windows)[source]

Load image with sufficient additional data to cover windows.

  • itype (str) – Image type
  • windows (list[tuple]) – The list of tuples of window shapes that will be used with this generator

Split processing into chunks.

Parameters:n_chunks (int) – Number of chunks to split the image into