Ask Your Question
0

min and max values hsv in an image

asked 2016-09-22 03:56:45 -0600

zms gravatar 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;
}
edit retag flag offensive close merge delete

Comments

@berak what is your opinion on deleting this. there is a post a bit more detailed http://answers.opencv.org/question/27...

sturkmen gravatar imagesturkmen ( 2017-09-03 16:31:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-09-22 05:02:22 -0600

berak gravatar image

minMaxLoc() will do the trick !

double  minVal, maxVal;
Point minPos, maxPos;

minMaxLoc( channel[0], &minVal, &maxVal, &minPos, &maxPos );
edit flag offensive delete link more

Comments

it works! thanks

zms gravatar imagezms ( 2016-09-22 07:58:27 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-22 03:56:45 -0600

Seen: 3,011 times

Last updated: Sep 22 '16