Learn Python OpenCV cv2.minMaxLoc() by Examples – OpenCV Tutorial

By | October 14, 2020

OpenCV cv2.minMaxLoc() is often used to find the maximum and minimum value in a numpy array. In this tutorial, we will use an example to show you how to use this function.

Look at this example:

import numpy as np
import cv2

We have created a numpy array a, which is 2*4.

In order to find the maximum and minimum value in a, we can do like this:



cv2.minMaxLoc() will return four values:

min_val: the minimum value

max_val: the maximum value

min_index: the index of minimum value in a

max_indx: the index of maximum value in a

Run this code, you will get:

1.0 67.0 (0, 0) (1, 1)