Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you use Opencv 3.0 I would prefer extractChannel(input, output, channel) instead of split(). I don't now if this function exists in OpenCV 2.X. But instead of extracting a COI you can directly access to a pixel by using:

int pixelValue = (int)(img.at<vec3b>(Point(x, y))[channel]);

Where channel is the channel you like to read between 0 and 2 for a 3channel image. Consider that Vec3b is for 3 channel byte Mat, if you have an int Mat use Vec3i and so on.

If you use Opencv 3.0 I would prefer extractChannel(input, output, channel) instead of split(). I don't now if this function exists in OpenCV 2.X. But instead of extracting a COI you can directly access to a pixel by using:

int uchar pixelValue = (int)(img.at<vec3b>(Point(x, y))[channel]);img.at<vec3b>(Point(x, y))[channel];

Where channel is the channel you like to read between 0 and 2 for a 3channel image. Consider that Vec3b is for 3 channel byte Mat, if you have an int Mat use Vec3i and so on.