subtract<T> method

Mat subtract<T>(
  1. T val, {
  2. bool inplace = false,
})

subtract

Implementation

Mat subtract<T>(T val, {bool inplace = false}) {
  return switch (val) {
    Mat() => subtractMat(val as Mat, inplace: inplace),
    int() => switch (type.depth) {
        MatType.CV_8U => subtractU8(val as int, inplace: inplace),
        MatType.CV_8S => subtractI8(val as int, inplace: inplace),
        MatType.CV_16U => subtractU16(val as int, inplace: inplace),
        MatType.CV_16S => subtractI16(val as int, inplace: inplace),
        MatType.CV_32S => subtractI32(val as int, inplace: inplace),
        _ => throw UnsupportedError("subtract int to ${type.asString()} is not supported!"),
      },
    double() => switch (type.depth) {
        MatType.CV_32F => subtractF32(val as double, inplace: inplace),
        MatType.CV_64F => subtractF64(val as double, inplace: inplace),
        // MatType.CV_16F => subtractF16(val as double, inplace: inplace), // TODO
        _ => throw UnsupportedError("subtract double to ${type.asString()} is not supported!"),
      },
    _ => throw UnsupportedError("Type $T is not supported"),
  };
}