# Matlab min equivalent in OpenCV

I'm looking for an equivalent for the `min`

function of Matlab in OpenCV, with this particular functionality (taken from the official Matlab documentation):

[M,I] = min(___) finds the indices of the minimum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. If the minimum value occurs more than once, then min returns the index corresponding to the first occurrence.

In my specific case, I have 2 images. I want to create a new image with the minimum value of each pixel (wrt those 2 images), and I need to store a map (i.e a `Mat`

object or something similar with a similar size) where each pixel of the map tells me whether the minimum value was taken from he first or the second image
(You can consider them as n*m*2 image where I want to take the minimum value channel-wise, and want to be able to tell from which channel I got this value).

Is there an easy way to do this in OpenCV?

btw, It's for an Android app, so Java answers are preferred over C++. thanks.