Ask Your Question

Minimum mat in an array of mats

asked 2017-09-18 10:09:09 -0500

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


do you want to sort them?

sturkmen gravatar imagesturkmen ( 2017-09-18 10:16:26 -0500 )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 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

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

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) {
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-09-18 10:09:09 -0500

Seen: 284 times

Last updated: Sep 20 '17