cv::Mat transparentImage;
cv::cvtColor(image, transparentImage, CV_BGR2BGRA);

// find all white pixel and set alpha value to zero:
for (int y = 0; y < transparentImage.rows; ++y)
{
    for (int x = 0; x < transparentImage.cols; ++x)
    {
        cv::Vec4b & pixel = transparentImage.at<cv::Vec4b>(y, x);
        // if pixel is white
        if (pixel[0] == 255 && pixel[1] == 255 && pixel[2] == 255)
        {
            // set alpha to zero:
            pixel[3] = 0;
        }
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-12-26
  • 2021-12-15
  • 2021-07-11
  • 2021-11-20
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2021-10-20
  • 2021-10-23
  • 2021-09-20
  • 2021-11-20
  • 2021-11-20
  • 2022-01-20
  • 2021-12-15
相关资源
相似解决方案