Skip to content

Fix a bug in cv :: merge when array of 3-channel mat is input - #13544

Merged
alalek merged 3 commits into
opencv:3.4from
eightco:bugfix
Jan 4, 2019
Merged

alalek merged 3 commits into
opencv:3.4from
eightco:bugfix

Conversation

@eightco

@eightco eightco commented Dec 29, 2018 •

Copy link
Copy Markdown
Contributor

Fix a bug in cv::merge() when array of 3-channel Mat is input

The merge of the array of 3channel mat gives the wrong result on a particular input.

When an array of mat entering as input type If each Mat is not a single channel, but array of three or four Mat's of the three channels is input, the ipp_merge() call will result in an incorrect merge.

ipp_merge () seems to have been implemented assuming that the Mat channels are all 1 channel.
Therefore, we must move the ipp_merge() call below the if (! Allch1) branch to work properly.

simple test

Mat src1(2, 2, CV_8UC3, Scalar::all(1));
Mat src2(2, 2, CV_8UC3, Scalar::all(2));
Mat src3(2, 2, CV_8UC3, Scalar::all(3));
Mat src_arr[] = { src1, src2, src3 };
Mat dst;
merge(src_arr, 3, dst);
cout << dst << endl;

@alalek

alalek commented Dec 30, 2018

Copy link
Copy Markdown
Member

Please add simple test for the issue.

eightco added a commit to eightco/opencv that referenced this pull request Dec 31, 2018
eightco added a commit to eightco/opencv that referenced this pull request Dec 31, 2018
@eightco

eightco commented Dec 31, 2018

Copy link
Copy Markdown
Contributor Author

Ok I added a simple test code for this issue.

@eightco eightco changed the title Mat merge function bug fix - Bug fix of merge function of 3-channel v.. Fix a bug in cv :: merge when array of 3-channel mat is input Jan 1, 2019

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alalek
alalek merged commit 71aee66 into opencv:3.4 Jan 4, 2019
@alalek alalek mentioned this pull request Jan 10, 2019
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Fix a bug in cv :: merge when array of 3-channel mat is input (opencv#13544)

* Mat merge function bug fix - Bug fix of merge function of 3-channel vector <Mat> of 3 or 4 matrices

* Add Core_merge test for opencv#13544

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants