Calculate the k1 scale function for a quantile given a comp. factor.
create_multiband_geotiff(array, out_name, proj, geo, nodata=0, out_format=1, verbose=False)¶
Convert an array to an output georegistered geotiff. :param array: A numpy array with a the shape: [Channels, X, Y] or [X, Y] :type array:
numpy.ndarray:param out_name: The output name and path for your image :type out_name: str :param proj: A projection, can be extracted from an image opened with gdal with
image.GetProjection(). Can be set to None if no georeferencing is required.
gdal.geotransform) – A gdal geotransform which indicates the position of the image on the earth in projection units. Can be set to None if no georeferencing is required. Can be extracted from an image opened with gdal with image.GetGeoTransform()
nodata (int) – A value to set transparent for GIS systems. Can be set to None if the nodata value is not required. Defaults to 0.
out_format (str, gdalconst) – https://gdal.org/python/osgeo.gdalconst-module.html Must be one of the variables listed in the docs above. Defaults to gdal.GDT_Byte.
verbose (bool) – A verbose output, printing all inputs and outputs to the function. Useful for debugging. Default to False
Get the geotransform for a raster image source.
rasterio.DatasetReader, or osgeo.gdal.Dataset) – Path to a raster image with georeferencing data to apply to geom. Alternatively, an opened
osgeo.gdal.Datasetobject can be provided. Required if not using affine_obj.
transform – An affine transformation object to the image’s location in its CRS.
- Return type
get_intensity_quantiles(dataset_dir, percentiles=[0, 100], ext='tif', recursive=False, channels=None, verbose=0)¶
Get approximate dataset pixel intensity percentiles for normalization.
This function reads every image in a dataset directory and gets a rough approximation of pixel intensity percentiles
get_tdigest(data_buffer, tdigest=None, scale_function=<class 'solaris.raster.image.K1ScaleFunction'>, compression_delta=0.01)¶
Create a new t-digest or merge it with an existing digest.
This function is an implementation of Algorithm 1 from https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf
numpy.ndarray) – An array of data to load into a tdigest. This will be flattened into a vector.
TDigest, optional) – An existing
TDigestobject to merge with the new data.
stitch_images(im_arr, idx_refs=None, out_width=None, out_height=None, method='average', use_GPU=True)¶
Stitch together images into a single 2- or 3-channel array.
This function helps combine predictions generated by inferencing tiled pieces of larger images, similar to the pre-existing CosmiQ Works tool, BASISS
numpy.arrays) – A 3- or 4-D
[N, Y, X(, C)]or a list of length N made up of 2- or 3-D tensors with shape
[Y, X(, C)]. These array(s) will be stitched together to produce a single output of shape
[Y, X(, C)].
idx_refs (list, optional) – A list of
(Y, X)indices for each sub-array to define the location of the first corner in the final output. Used for stitching together non-overlapping or partially overlapping tiles into a single output. Note that the index reference output of
solaris.nets.datagen.InferenceTilerprovides the required reference system for stitching here.
out_width (int, optional) – The width of the output array in pixels. If not provided, it is assumed that the width is the same as the width of
out_height (int, optional) – The height of the output array in pixels. If not provided, it is assumed that the height is the same as the height of
method (str, optional) – possible values are
'confidence'. * If
'average', all pixels corresponding to the same location in
[Y, X, C]space are averaged. * If
'first', the value of the first pixel along the
Naxis for a given
[Y, X, C]location is selected. * If
'confidence', it’s assumed that pixel values correspond to probabilities in
[0, 1]. In this case, for a given
[Y, X, C]location, the pixel with the greatest distance from
0.5will be selected (being the value with the highest confidence).
use_GPU (bool, optional) – Should processing be performed on the GPU if a GPU is available? Defaults to yes (
True). If a GPU isn’t available, this argument is ignored.
Falsewill force CPU-located processing.
- Return type
[Y, X(, C)].