码迷,mamicode.com
首页 > 其他好文 > 详细

Getting or Setting Pixels

时间:2016-05-10 23:42:54      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

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];

Getting or Setting Pixels

标签:

原文地址:http://www.cnblogs.com/visionfeng/p/5479663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!