gsdview.imgutils

Tools for geo-spatial images handling and visualization.

Functions

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

Classes

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).

Note

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

Example:

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.

range[source]
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.

Note

offset is applyed before scaling:

output = scale \cdot (data - offset)

range[source]
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)

Note

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.

Parameters:
  • 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.
Returns:

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).

Parameters:
  • 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
Returns:

the look up tabe (LUT)

gsdview.imgutils.log_lut(dtype='uint8')[source]
gsdview.imgutils.root(dtype='uint8')[source]
gsdview.imgutils.square(dtype='uint8')[source]

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

Previous topic

gsdview.graphicsview

Next topic

gsdview.info

This Page