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
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.