histogram: how to find bins values for certain range of data(at Y-axis)?
Hello,
I'm not very familar with math, not sure what exactly shoud to search (peaks not exactly what I need).
I have some histogram and I have set certain ranges of Y-axis data (values), yellow on picture:
for (int i = 0; i < bins; i++)
{
int px_qty = cvRound(hist.at<float>(i)*h / 255.0);
if (i == 0) // white
{
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(255, 255, 255), FILLED);
}
else if (i < 12 && i != 0) //red
{
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(0, 0, 255), FILLED);
}
else if (i >= 12 && i < 60)//green
{
if (px_qty > 120) // px intencity is high enough, paint in YELLOW
{
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(0, 255, 255), FILLED);
}
else // paint green
{
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(0, 255, 0), FILLED);
}
}
else if (i >= 60 && i < 100) //blue
{
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(255, 0, 0), FILLED);
}
else
{
//white
rectangle(histImg, Point(i*bin_w, h), Point((i + 1)*bin_w, h - px_qty),
Scalar(255, 255, 255), FILLED);
}
}
I know how to find "begining" of yellow range (just first match with condifition px_qty > 120 ).
But how about "end" ?
I need to know both X1 and X2:
Just want to note, that during whole predefined range its possible to get some nadirs of data:
But still I would like to get "last" one sample.
Regards!
Any ways for solution of this problem?