Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

min and max values hsv in an image

Hi, Im trying to get the value for the max for S and V inside an image. In this example, the mean of the value can be obtained, but how to get the max and min?

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>

using namespace cv;

int main(void)
    vector<Mat> channels;
    Mat img = imread("Documents/forest.jpg");
    cvtColor(img, img, CV_BGR2HSV);
    split(img, channels);
    Scalar m = mean(channels[0]);
    printf("%f\n", m[0]);

    return 0;