IImageOps

Description

interface Tinman.Terrain.Imaging.IImageOps<T ref>

Extended by

IImage
IImageReader

Base interface that declares image operations that can be performed on IImage and IImageReader objects.

Image operations can be performed on IImage objects and IImageReader object.

Public / Methods

Adjust


[OwnerReturn] [OwnerThis]
public method Adjust → (2)

brightness in : int32

[-1000..1000]
The adjustment factor for image brightness.

saturation opt : int32 = 0

[-1000..1000]
The adjustment factor for image saturation.

returns → T

The resulting image.

Adjust the brightness and saturation of this image.

See also

Colors.Adjust

Alpha​To​Coverage


[OwnerReturn] [OwnerThis]
public method AlphaToCoverage → ()

returns → T

The resulting image.

Converts the alpha channel (see PixelChannel.Alpha) of this image to a coverage layer (see PixelChannel.Void).

Background


[OwnerReturn] [OwnerThis]
public method Background → ()

returns → T

The resulting IImageReader object.

The image scanlines will be read using a background thread.

Channel​To​Intensity


[OwnerReturn] [OwnerThis]
public method ChannelToIntensity → (1)

channel in : PixelChannel

The pixel channel.

returns → T

The resulting image.

Returns an opaque grayscale image which pixel values are equal to the given pixel channel of this image.

Void pixels in this image will also be void in the resulting image.

Clip


[OwnerReturn] [OwnerThis]
public method Clip → (4)

in : int32

[>=0]
X-coordinate of top-left corner of rectangle.

in : int32

[>=0]
Y-coordinate of top-left corner of rectangle.

width in : int32

[>0]
Width of rectangle.

height in : int32

[>0]
Height of rectangle.

returns → T

The resulting image.

Returns an image that represents a sub rectangle of this image.

Crop


[OwnerReturn] [OwnerThis]
public method Crop → (2)

color opt : int64 = Colors.Black

The padding pixel color (see Colors).

skip opt : int32 = 1

The maximum length (in pixels) of a run surrounded by void pixels that will be interpreted as void, too.

returns → T

The resulting image.

Assumes the image holds a non-rectangular shape that is padded with a uniform color and replaces all padding pixels with void.

Since the source image is read scanline after scanline, cropping is performed locally for each scanline: Beginning at the left and right image borders, all pixels having the same color as the color opt parameter are replaced with void until a consecutive run of pixels having different colors is found (see skip opt). The following figures illustrates this: Pixels that have the same color as the color opt parameter are shown as '.' characters, all others are indicated with X:

+-----------------------------------------------------------------------+
|.......................................................................|
|.......................................................................|
|............................XXX........................................|
|...........................XXXXX.......................................|
|.........................XXXXXXX.......................................|
|.......................XXXXXXXXX.......................................|
|.....................XXXXXXXXXXX.......................................|
|...................XXXXXXXXXXXXXX......................................|
|.................XXXXXXXXXXXXXXXX......................................|
|................XXXXXXXXXXXXXXXXX......................................|
|...............XXXXXXXXXXXXXXXXXXX.....................................|
|................XXXXXXXXXXXXXXXXXXX....................................|
|.................XXXXXXXXXXXXXXXXXXXXX.................................|
|...................XXXXXXXXXXXXXXXXXXXXXXX.....X.......................|
|...............XXXXXXXXXX..XXXXXXXXXXXXXXXXXXXXXXXXXXX.................|
|..........XXXXXXXXXXXX.......XXXXXXXXXXXXXXXXXXXXXXXXXXX...............|
|.............XXXXXXX..........XXXXXXXXXXXXXXXXXXXXXXXXXX...............|
|...............XXX.............XXXXXXXXXXXXXXXXXXXXXXXX................|
|................................XXXXXXXXXXXXXXXXXXXXX..................|
|................................XXXXXXXXXXXXXXXXX......................|
|...................................XXXXXXX.............................|
|.......................................................................|
|.......................................................................|
|.......................................................................|
|.......................................................................|
+-----------------------------------------------------------------------+

The cropped image will look like this (whitespace represents void pixels):

+-----------------------------------------------------------------------+
|                                                                       |
|                                                                       |
|                            XXX                                        |
|                           XXXXX                                       |
|                         XXXXXXX                                       |
|                       XXXXXXXXX                                       |
|                     XXXXXXXXXXX                                       |
|                   XXXXXXXXXXXXXX                                      |
|                 XXXXXXXXXXXXXXXX                                      |
|                XXXXXXXXXXXXXXXXX              cropped because         |
|               XXXXXXXXXXXXXXXXXXX             of skipped pixels       |
|                XXXXXXXXXXXXXXXXXXX            |                       |
|                 XXXXXXXXXXXXXXXXXXXXX         V                       |
|                   XXXXXXXXXXXXXXXXXXXXXXX                             |
|               XXXXXXXXXX..XXXXXXXXXXXXXXXXXXXXXXXXXXX                 |
|          XXXXXXXXXXXX.......XXXXXXXXXXXXXXXXXXXXXXXXXXX               |
|             XXXXXXX..........XXXXXXXXXXXXXXXXXXXXXXXXXX               |
|               XXX.............XXXXXXXXXXXXXXXXXXXXXXXX                |
|                         ^      XXXXXXXXXXXXXXXXXXXXX                  |
|                         |      XXXXXXXXXXXXXXXXX                      |
|                  not reachable    XXXXXXX                             |
|                  from left or                                         |
|                  right border                                         |
|                                                                       |
|                                                                       |
+-----------------------------------------------------------------------+

Cropping will not change the image size or modify the geo-reference.

Function


[OwnerReturn] [OwnerThis]
public method Function → (2)

function in : string

[not-null]
A function expression (see ConfigScript.GrammarRuleExpression) that consumes input linear pixel values in the range [0..1] and returns output linear pixel value in the range [0..1]. Output values are clamped (including infinities), not-a-number output values produce void pixels (see Scanline.Void).

channel opt : PixelChannel = PixelChannel.Intensity

The pixel channel the function shall be applied to. If PixelChannel.Void, no transformation will be performed.

returns → T

The resulting image or this if channel opt is PixelChannel.Void.

Transform linear pixel values using a custom function.

The given function is evaluated on linear pixel values, that is after raw pixels have been translated to normalized pixel values (see SetRange) and after gamma correction has been applied (see SetGamma). The expression may use all members of the default Tinman script (see ConfigScript.Tinman). The following arguments are available to the function expression:

  • raw
    The input pixel value (raw).

  • lin
    The input pixel value (linear) in the range [0..1].

  • A, B, C, D, E, F
    Coefficients that can be used to transform between raw and linear pixel values:

    lin = pow(raw * A + B, C)
    raw = pow(lin, D) * E + F
    D   = 1 / C
    E   = 1 / A
    F   = -B / A

    where raw is the raw pixel value that is actually stored in the source image (e.g. [0..255] for 8-bit images) and lin is the linear pixel value that is stored in the image scanline buffer (see Scanline). A and B represent the transformation from raw pixel values to normalized pixel values (see SetRange); C is the exponent that best approximates the performed gamma correction (see SetGamma).

Intensity​To​Channel

2 overloads


[OwnerReturn] [OwnerThis]
public method IntensityToChannel1 → (1)

channel in : PixelChannel

The pixel channel.

returns → T

The resulting image.

Returns an image that has a single pixel channel (see channel in parameter), initialized to the grayscale intensities of this image. All other pixel channels are initialized to their respective default values (see PixelChannel).

Void pixels in this image will also be void in the resulting image.


[OwnerReturn] [OwnerThis]
public method IntensityToChannel2 → (2)

channel in : PixelChannel

The pixel channel to replace.

image in : T own

[not-null]
The image which pixel channel is to be replaced.

returns → T

The resulting image.

Replaces a pixel channel of the given image in with the grayscale intensities of this image.

Void pixels in the other image are ignored (i.e. the original pixel remains unchanged). Void pixels in this image are preserved (i.e. the other pixel is ignored).

See also

PixelChannel

Invert


[OwnerReturn] [OwnerThis]
public method Invert → (1)

channel in : PixelChannel

The pixel channel.

returns → T

The resulting image.

Inverts the given pixel channel.

The PixelChannel.Void pixel channel cannot be inverted. The method will do nothing in this case.

Op


[OwnerReturn] [OwnerThis]
public method Op → (2)

other in : T own

[not-null]
The other image.

colorOp in : ColorOp

The color operation to apply.

returns → T

The resulting image.

Combines this image (first) with the given one (second) using the specified color operation (see ColorOp).

Pad


[OwnerReturn] [OwnerThis]
public method Pad → (1)

amount opt : int32 = 1

[>=-1]
The amount in pixels to use for regular padding or -1 for special padding. A padding amount of zero does not perform any image modification.

returns → T

The resulting image.

Pads this image by adding pixels at the borders, using either regular or special padding.

Regular padding duplicates pixels at all four image borders. It can be used to reduce (but not eliminate) seams that will occur when tiled geodata is imported incrementally using on-the-fly projection. The correct solution would be to merge all geodata tiles into a dataset and then perform the projection on the whole geodata.

Special padding adds a new pixel column at the right border, using the pixels of the column at the left border. It can be used to restore the missing pixel column of a pixel-is-point grid that wraps around the X-axis.

Scale


[OwnerReturn] [OwnerThis]
public method Scale → (3)

width in : int32

[>0]
Width of the scaled image.

height in : int32

[>0]
Height of the scaled image.

mode opt : InterpolationMode = InterpolationMode.UniformB

The interpolation mode to use for magnification.

returns → T

The resulting image.

Returns an image that represents a scaled version of this image.

Set​Coverage


[OwnerReturn] [OwnerThis]
public method SetCoverage → (1)

coverage in : PixelCoverage

The pixel coverage.

returns → T

The resulting image.

Updates the value of IImageInfo.Coverage, without modifying the image content.

To perform resampling between pixel-is-area and pixel-is point, use ToCoverage.

Set​Gamma


[OwnerReturn] [OwnerThis]
public method SetGamma → (1)

gamma in : float64

The gamma correction.

returns → T

The resulting image.

Updates the value of IImageInfo.Gamma.

Set​Georef


[OwnerReturn] [OwnerThis]
public method SetGeoref → (1)

georef in : Raster

The geo-referencing information or null.

returns → T

The resulting image.

Updates the value of IGeorefInfo.Georef, without modifying the image content.

Set​Layer


[OwnerReturn] [OwnerThis]
public method SetLayer → (2)

layer in : HeightmapLayer

The heightmap layer.

format opt : PixelFormat = PixelFormat.Unknown

The pixel format to use for choosing the heightmap format (see HeightmapFormat.For2). If PixelFormat.Unknown, the pixel format of this image will be used. Defaults to PixelFormat.Unknown.

returns → T

The resulting image.

Updates the value of IImageInfo.Layer, without modifying the image content.

Set​No​Data


[OwnerReturn] [OwnerThis]
public method SetNoData → (1)

noData in : float64

The raw pixel value to map to void pixels (see IImageInfo.NoData).

returns → T

The resulting image.

Updates the value of IImageInfo.NoData.

Set​Range


[OwnerReturn] [OwnerThis]
public method SetRange → (2)

range in : PixelRange

The pixel value ranges to use for translating raw pixel values to normalized pixel values (see IImageInfo.Range).

reinterpret opt : bool = false

true to leave raw pixels values unchanged and reinterpret them according to range in, false to normalize raw pixel values to range in.

returns → T

The resulting image.

Updates the value of IImageInfo.Range.

Set​Values


[OwnerReturn] [OwnerThis]
public method SetValues → (1)

values in : RangeD

The raw pixel value range to use.

returns → T

The resulting image.

Updates the value of IImageInfo.Values

Using this method does not modify the image data in any way. However, it may be used to avoid the additional pass over the image data when using ReadImageFlags.Range, if the calling code has up-front knowledge about the value range.

Smooth


[OwnerReturn] [OwnerThis]
public method Smooth → ()

returns → T

The resulting image.

Performs smoothing on this image.

Image smoothing is performed using an Uniform-B spline.

To​Coverage


[OwnerReturn] [OwnerThis]
public method ToCoverage → (2)

target in : PixelCoverage

The pixel coverage semantic of the resulting image.

wrapX opt : bool = false

Is this image wrapped around the X-axis?

returns → T

The resulting image.

Transforms this image from the given pixel coverage semantic to the given one.

If this image already has the given pixel coverage semantic, no transformation will be performed.