Skip to content

Uniform empty image handling #8300

Open

Description

@StevenPuttemans

Vote: Please use GitHub emoji/reaction for next two comments below to provide your opinion.

As suggested by @sovrasov in PR #8288 we definitely need to unify the way that empty images are handled inside the imgproc module.

  • 1️⃣ OPTION 1: generate an assertion (exception) from the moment an empty input is given
  • 2️⃣ OPTION 2: do not fail, just silently copy with empty data and make output also empty

The second option will require the user to do all the checking on data validity himself.


Update 2020-03-01: option 1 - 15, option 2 - 5
Update 2020-04-30: option 1 - 16, option 2 - 6

Activity

  1. alalek commented on Mar 1, 2017

    @alalek
    Member

    1️⃣ Comment for collecting "Option 1" votes (please use GitHub emoji)

  2. alalek commented on Mar 1, 2017

    @alalek
    Member

    2️⃣ Comment for collecting "Option 2" votes (please use GitHub emoji)

  3. darbedar commented on Aug 13, 2017

    @darbedar

    Why not use the empty image and assert a warning?

  4. StevenPuttemans commented on Aug 14, 2017

    @StevenPuttemans
    Author

    Why not use the empty image and assert a warning?

    Thats actually what option 1 suggests :P

  5. mpolicki commented on Nov 3, 2021

    @mpolicki

    @StevenPuttemans Both options require the user to check the validity of input data; it would be nice if you updated your OP to say so.

    But actually, the second option only requires validation in some cases since working with empty images has legitimate uses; therefore the second option is strictly better.

    Also, look at it from an algebraic point of view. The equivalent of option 1 would be if mathematics threw an exception if you tried to perform set union with an empty set. In the matrix world, an empty matrix is the equivalent of 0, and it's a perfectly legitimate value.

  6. vrabaud commented on Nov 18, 2021

    @vrabaud
    Contributor

    BTW, why limit this to imgproc ? Why isn't it possible right to fill an empty matrix with random numbers ?

    CV_Assert(!_mat.empty());

    And it is possible to randShuffle a cv::Mat(0,0,CV_8U) but not a cv::Mat() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    futurevote

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions