Use std::min() and std::max() in getPixelStat()