threshold

Clip slice values by a given threshold value.

If any slice element has value in range between lower and upper threshold value, its output value is set to upper clipping value, otherwise to 0. If output value type is a floating point, upper clipping value is 1.0, otherwise its the maximal value for that type (e.g. for ubyte its 255, for float and double its 1.0).

If lower threshold bound is of the same value as higher, then values are clipped from given value to 0.

Thresholding is supported for 1D, 2D and 3D slices.

  1. Slice!(Contiguous, packs, OutputType*) threshold(Slice!(kind, packs, InputType*) input, InputType lowThresh, InputType highThresh, Slice!(Contiguous, packs, OutputType*) prealloc = emptySlice!(packs, OutputType))
    nothrow
    Slice!(Contiguous, packs, OutputType*)
    threshold
    (
    OutputType
    InputType
    SliceKind kind
    size_t[] packs
    )
    (
    Slice!(kind, packs, InputType*) input
    ,
    InputType lowThresh
    ,
    InputType highThresh
    ,
    Slice!(Contiguous, packs, OutputType*) prealloc = emptySlice!(packs, OutputType)
    )
    in { assert (lowThresh <= highThresh); assert (!input.empty); }
  2. Slice!(Contiguous, packs, OutputType*) threshold(Slice!(kind, packs, InputType*) input, InputType thresh, Slice!(Contiguous, packs, OutputType*) prealloc = emptySlice!(packs, OutputType))

Parameters

input
Type: Slice!(kind, packs, InputType*)

Input slice.

lowThresh
Type: InputType

Lower threshold value.

highThresh
Type: InputType

Higher threshold value.

prealloc
Type: Slice!(Contiguous, packs, OutputType*)

Optional pre-allocated slice buffer for output.

Note: Input and pre-allocated buffer slice, should be of same structure (i.e. have same strides). If prealloc buffer is not given, and is allocated anew, input slice memory must be contiguous.

Meta