Finds the global minimum and maximum in an image.
[min_value, max_value, min_value_loc, max_value_loc] = minMaxLoc(img);
Single channel image (Mat).
Minimal value of the image img (double).
Maximal value of the image img (double).
Coordinates of the location of the minimal value (2x1 double).
Coordinates of the location of the maximal value (2x1 double).
The function minMaxLoc
find the minimum and maximum element values and their positions of an image. The function does not work with multi-channel images.
scicv_Init(); img = imread(getSampleImage("puffins.png")); img_template = imread(getSampleImage("puffin_pattern.png")); result = matchTemplate(img, img_template, CV_TM_SQDIFF_NORMED); [min_value, max_value, min_value_loc, max_value_loc] = minMaxLoc(result); match_pt = min_value_loc - 5; match_pt2 = match_pt + [size(img_template, "c"), size(img_template, "r")] + 5; rectangle(img, match_pt, match_pt2, [0, 255, 0], 2, 8, 0); matplot(img); disp("Minimal square difference value between image and template:"); disp(min_value); delete_Mat(img); delete_Mat(img_template); delete_Mat(result); | ![]() | ![]() |