Replacing Colour Of An Image

前端 未结 3 1349
猫巷女王i
猫巷女王i 2020-12-20 10:37

I am trying to replace the black colours of a picture with white, and vice versa. This is actually so my OCR code can read it on white backgrounds better. It\'s currently ge

3条回答
  •  借酒劲吻你
    2020-12-20 11:27

    if your image is B&W, it is very easy in OpenCV:

    // bmp is your bitmap
    var inverted = (255 - bitmap.ToMat()).ToMat().
      .ToBitamp() // or
      .ToWriteableBitmap() // or
      .ToBitmapSource()
    

    OpenCV can be a little overkill if this in your only manipulation in the whole app

提交回复
热议问题