Tools for geo-spatial images handling and visualization.


histogram_equalized_lut(hist[, dtype, fill]) Compute a histogram equalized LUT.
linear_lut([vmin, vmax, dtype, fill, omin, omax]) Compute a linear LUT.


BaseStretcher([vmin, vmax, dtype]) Base class for stretcher objects.
LUTStretcher([offset, vmin, vmax, dtype, fill]) Stretch using LUT.
LinearStretcher([scale, offset, vmin, vmax, ...]) Linear stretch.
LogarithmicStretcher([scale, offset, base, ...]) Linear stretch.
class gsdview.imgutils.BaseStretcher(vmin=0, vmax=255, dtype='uint8')[source]

Bases: object

Base class for stretcher objects.

The base implementation of the __call__ method just performs clipping and type conversion (both are optional).


outout extrema (min and max) have to be compatible with the data type (dtype) set.


data = np.arange(.10, 300.)
stretch = BaseStretch(0, 255, 'uint8')
data = stretch(data)
dtype = None

data type for output data

max = None

the maximum value for output data

min = None

the minimum value for output data

stretchtype = 'clip'
class gsdview.imgutils.LUTStretcher(offset=0, vmin=0, vmax=255, dtype='uint8', fill=True)[source]

Bases: gsdview.imgutils.BaseStretcher

Stretch using LUT.

Perform an arbitrary scaling on unsigned data using a look-up table (LUT).

An optional offset is applied before LUT application.

set_range(imin, imax, fill=None)[source]
stretchtype = 'lut'
class gsdview.imgutils.LinearStretcher(scale=1.0, offset=0, vmin=0, vmax=255, dtype='uint8')[source]

Bases: gsdview.imgutils.BaseStretcher

Linear stretch.

Perform linear scaling (including offest application) and clipping.


offset is applyed before scaling:

output = scale \cdot (data - offset)

set_range(imin, imax)[source]
stretchtype = 'linear'
class gsdview.imgutils.LogarithmicStretcher(scale=10, offset=0, base=10, vmin=0, vmax=255, dtype='uint8')[source]

Bases: gsdview.imgutils.BaseStretcher

Linear stretch.

Perform logarithmic stretching and clipping:

output = scale \cdot log_{base}(data - offset)


both base and scale default to 10 while the default value for offset is 0 so the strecher returns values expressed in dB: output = 10 \cdot log_{10}(data)

stretchtype = 'logarithmic'
gsdview.imgutils.histogram_equalized_lut(hist, dtype='uint8', fill=False)[source]

Compute a histogram equalized LUT.

  • hist (ndarray) – histogram to be equalized
  • dtype (np.dtype (uint8 or uint16)) – numpy data type of the output LUT (default uint8)
  • fill (bool) – if False (default) the returned LUT has length = len(hist). Otherwise the LUT length has a lenght of 2**nbits with nbits bein 8 or 16 depending on dtype and LUT indices greater than the last histogram max value are filled with the maximum value itself.

the llok up table (LUT)

gsdview.imgutils.linear_lut(vmin=0, vmax=None, dtype='uint8', fill=False, omin=0, omax=None)[source]

Compute a linear LUT.

The returned LUT maps the imput domain (vmin, vmax) onto the output one (0, vout) using a linear low. The value of vout depends on dtype: 2**8-1 if dtype=’uint8’, 2**16-1 dtype=’uint16’

The fill parameter can be used to controll the length of returned LUT (see below).

  • vmin (int or float) – minimum value (positive or null). Default 0
  • vmax (int or float) – maximum value (positive) Default 2**nbits depending on dtype
  • dtype (np.dtype (uint8 or uint16)) – numpy data type of the output LUT (default uint8)
  • fill (bool or int) –

    the length of the returned lut is:

    • vmax + 1 if bool(fill) == False
    • max(vmax + 1, 2**nbits) if fill == True
    • max(vmax + 1, fill) id fille is an number
  • omin – @TBW
  • omax – @TBW

the look up tabe (LUT)


Get GSDView at Fast, secure and Free Open Source software downloads

Previous topic


Next topic

This Page