opencv-saturate_cast防溢出函数

函数功能:当数据超过数据类型最大值时取最大值, 当数据小于数据类型最小值时取最小值

    uchar i=200;
    qDebug()<<i<<Qt::endl;  //i输出200
    i=cv::saturate_cast<uchar>(255);
    qDebug()<<i<<Qt::endl;  //i输出255
    i=cv::saturate_cast<uchar>(400);
    //返回值255,因为400超出uchar最大值255,所以取255
    qDebug()<<i<<Qt::endl;  //i输出255
    i=cv::saturate_cast<uchar>(-10);
    //返回值0,因为-10超出uchar最小值0,所以取0
    qDebug()<<i<<Qt::endl;  //i输出0

 

 

 

 

 

opencv-saturate_cast防溢出函数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2021-10-18
  • 2021-10-05
  • 2021-11-05
  • 2021-05-25
  • 2021-11-05
相关资源
相似解决方案