Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

core: inconsistency of addition for multi-channel Mat and Scalar #16739

Open
@alalek

Description

@alalek

OpenCV 3.4.9 / 4.2.0:

arg1 - uint8 matrix with 3 channels:

  • Mat m__1_2_3(Size(2, 2), CV_8UC3, Scalar(1, 2, 3));

arg2:

  • 5
  • Scalar(5) (identical toScalar(5, 0, 0, 0))
  • Scalar(5, 1e-6, 0)
  • Scalar::all(5) (identical toScalar(5, 5, 5, 5))

Result variants:

  1. [6, 2, 3] - modified 1st channel only
  2. [6, 7, 8] - all channels are modified
#C++ codearg1
5
arg2
Scalar(5)
arg3
Scalar
(5, 1e-6, 0)
arg4
Scalar::all(5)
1cv::add(arg1, arg2, res)2112
2MatExpr
res = arg1 + arg2
1
#14738
112
3MatExpr
res = 1.001 * arg1 + arg2
2
#14738
2
#16538
12

Analyse:

  • results withScalar(5, 1e-6, 0)(arg3) andScalar::all(5)(arg4) are consistent and adequate
  • some other cases should be be deprecated / changed / removed?
  • case with numeric scalar (5) may have designed to use withcomplex numbers (emulation through matrices with 2 channels) where5 is interpreted as a real number.
  • current implicit conversion of5 intoScalar (no explicit bug/feature) converts this intoScalar(5, 0, 0, 0). Extra overloads may help to avoid implicit conversions (but may break user code).

Related unclear stuff:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp