Getting or Setting Pixels
Getting or Setting Pixels
The safe (slow) way
- Suppose you are working on an Image<Bgr, Byte>. You can obtain the pixel on the y-th row and x-th column by calling
Bgr color = img[y, x];
- Setting the pixel on the y-th row and x-th column is also simple
img[y,x] = color;
The fast way
The Image pixels values are stored in the Data property, a 3D array. Use this property if you need to iterate through the pixel values of the image.
For example, in an grayscale image (Image<Gray, Byte>), instead of doing this:
Gray byCurrent = imageGray[x, y];
You would do this:
Byte byCurrent = imageGray.Data[x, y, 0];