<< convertScaleAbs | Image operations | normalize >>

scicv >> Image operations > minMaxLoc

# minMaxLoc

Finds the global minimum and maximum in an image.

### Syntax

    [min_value, max_value, min_value_loc, max_value_loc] = minMaxLoc(img);

### Parameters

img

  Single channel image (Mat).

min_value

  Minimal value of the image img (double).

max_value

  Maximal value of the image img (double).

min_value_loc

  Coordinates of the location of the minimal value (2x1 double).

max_value_loc

  Coordinates of the location of the maximal value (2x1 double).

### Description

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.

### Examples

    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);

### See also

- minMaxLoc

Report an issue
<< convertScaleAbs | Image operations | normalize >>