__2017-12-16 如一模式识别研究

如一模式识别研究

OPENCV>>Manipulating pixels with OpenCV

转自:http://www.cnblogs.com/yutenghit/archive/2012/07/03/2574662.html

Scalar intensity = img.at(y, x);

intensity.val[0]contains a value from 0 to 255. Note the ordering ofxandy. Since in OpenCV images are

represented by the same structure as matrices, we use the same convention for both cases - the 0-based row index

(or y-coordinate) goes first and the 0-based column index (or x-coordinate) follows it. Alternatively, you can use the

following notation:

Scalar intensity = img.at(Point(x, y));

Now let us consider a 3 channel image withBGRcolor ordering (the default format returned byimread):

Vec3b intensity = img.at(y, x);

uchar blue = intensity.val[0];

uchar green = intensity.val[1];

uchar red = intensity.val[2];

You can use the same method for floating-point images (for example, you can get such an image by running Sobel on

a 3 channel image):

Vec3f intensity = img.at(y, x);

float blue = intensity.val[0];

float green = intensity.val[1];

float red = intensity.val[2];

The same method can be used to change pixel intensities:

img.at(y, x) = 128;

There are functions in OpenCV, especially from calib3d module, such asprojectPoints, that take an array of 2D or

3D points in the form ofMat. Matrix should contain exactly one column, each row corresponds to a point, matrix type

should be 32FC2 or 32FC3 correspondingly. Such a matrix can be easily constructed fromstd::vector:

vector points;

//... fill the array

Mat pointsMat = Mat(points);

One can access a point in this matrix using the same method texttt{Mat::at}:

Point2f point = pointsMat.at(i, 0);

分类: OpenCV

标签: OpenCV

评论留言区

:
  

作者: 游客 ; *
评论内容: *
带*号为必填项目

如一模式识别更新提示

matlab在图像处理方面的应用有更新

如一模式识别 友情链接

关于本站作者     chinaw3c     mozilla