normalize histogram in c++

I need to normalize the histogram of an image f which mean to applicated an transformation of histogram from image in order to extend the range of value of f to all available values. the norm(fmin) = Vmin ( minimal value we want to reach) and normal(fmin) = Vmax ( maximal value we want to reach)

I have this formula too

the goal is to have the same result that the function normalize which openCV gives.

Mat normalize(Mat image, float minValue, float maxValue)
{
  Mat res = image.clone();
  assert(minValue <= maxValue);
 float Fmax = 0; 
 float Fmin = 0;

for(int i = 0; i < res.rows; i++)
{
    for(int j = 0; j < res.cols; j++)
    {
        float x = res.at<float>(i,j);
        if(i < minValue)
        {
            Fmin = i;
        }
        if( i > maxValue)
        {
            Fmax = i;
        }
        res.at<float>(i,j) = (x - Fmin) * ((maxValue - minValue) / (Fmax - Fmin)) + minValue; 

    }
}
     return res;
}

I have this error : !!! Warning, saved image values not between 0 and 1. !!! Warning, saved image values not between 0 and 1.

I think I didn't understand how to calculate fmin/ fmax

链接地址: http://www.djcxy.com/p/89794.html

上一篇: OpenCV错误声明在某些Pixal值上失败

下一篇: 在c ++中规格化直方图