July 2015
Intermediate to advanced
174 pages
3h 45m
English
Pixel manipulation is often required for one to access pixels in an image. There are several ways to do this and each one has its advantages and disadvantages. A straightforward method to do this is the put(row, col, value) method. For instance, in order to fill our preceding matrix with values {1, 2, 3}, we will use the following code:
for(int i=0;i<image.rows();i++){ for(int j=0;j<image.cols();j++){ image.put(i, j, new byte[]{1,2,3}); } }
Note that in the array of bytes {1, 2, 3}, for our matrix, 1 stands for the blue channel, 2 for the green, and 3 for the red channel, as OpenCV stores its matrix internally in the
BGR (blue, green, and red) format.
It is okay to access pixels this way for small matrices. The only problem ...
Read now
Unlock full access