First time here? Check out the FAQ!

Ask Your Question
0

min and max values hsv in an image

asked Sep 22 '16

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;
}
Preview: (hide)

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 (Sep 3 '17)edit

1 answer

Sort by » oldest newest most voted
1

answered Sep 22 '16

berak gravatar image

minMaxLoc() will do the trick !

double  minVal, maxVal;
Point minPos, maxPos;

minMaxLoc( channel[0], &minVal, &maxVal, &minPos, &maxPos );
Preview: (hide)

Comments

it works! thanks

zms gravatar imagezms (Sep 22 '16)edit

Question Tools

1 follower

Stats

Asked: Sep 22 '16

Seen: 3,036 times

Last updated: Sep 22 '16