Ask Your Question
0

Minimum mat in an array of mats

asked 2017-09-18 10:09:09 -0600

harmodym gravatar image

Say I have an array of 15 Mats that I have read in from 15 bitmap files. I want one Mat produced from those 15 that is the minimum at each element through the array of 15. At (1,1), the smallest value of any (1,1) of the 15 Mats, the same at (1,2), etc.

Thanks in advance!

edit retag flag offensive close merge delete

Comments

do you want to sort them?

sturkmen gravatar imagesturkmen ( 2017-09-18 10:16:26 -0600 )edit

Nope! I just want 1 Mat produced, with that Mat being the element by element minimum across the array of Mats. Ideally without doing the min function a ton of times

harmodym gravatar imageharmodym ( 2017-09-18 10:21:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-09-20 07:16:34 -0600

berak gravatar image

well, you need at least 1 loop:

vector<Mat> img = ...
Mat m(img[0].size(), img[0].type(), Scalar::all(255)); // all on "max"
for (auto i:img) {
       cv::min(m,i,m);
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-09-18 10:09:09 -0600

Seen: 416 times

Last updated: Sep 20 '17