lundi 7 août 2017

C++ clamp function for a std::vector

void Clamp(std::vector<double>& input_image, double min_value, double max_value, int width, int height)
{
    for (int j = 0; j < width; j++)
    {
        for (int i = 0; i < height; i++)
        {
            input_image[i*width + j] = std::min(std::max(input_image[i*width + j], min_value), max_value);
        }
    }
}

I am trying to create this functionality of clamping.

Is there a better way to do it using a std::vector?

I can also use C++11

Aucun commentaire:

Enregistrer un commentaire