Assigining a negative value to a pixel

后端 未结 2 1607
野趣味
野趣味 2021-01-16 17:39

Using some criterion, there are some pixels in the image which I\'m not interested in. So, I would like to neglect them. I just want to ask if the approach I have followed i

2条回答
  •  情话喂你
    2021-01-16 17:54

    If your data type allows it, like signed integer (CV_32S) or floating point (CV_32F or CV_64F), it makes perfect sense to use negative values and it is a very common way to specify ignored pixels. In this case there is no special meaning to a negative value except your interpretation of it.

    On the other hand, if you use 8-bit unsigned images (CV_8U), this may lead to errors : it may either be truncated to zero or converted to [0,255] using modulo-256 addition, depending on your version of opencv. In the worst case, it may also overflow to neighbor pixels and modify their values, if you access pixel data in a very bad way. So if you work with 8-bit images, you should rather use a mask to specify ignored pixels, as phyrox explained.

提交回复
热议问题