1 | initial version |
I think you can try like this
Mat im(50,50,CV_32FC2);
Point pt1(10,10),pt2(20,30);
for (int i = 0; i<im.rows; i++)
for (int j = 0; j<im.cols; j++)
im.at<Vec2f>(i,j) = Vec2f(i,j);
cv::LineIterator it(im, pt1, pt2, 8);
for (int i = 0; i < it.count; i++, ++it)
{
cv::Point p = it.pos();
Vec2f pixelValue = im.at<Vec2f>(p.y, p.x);
cout<<pixelValue<<endl;
}
2 | No.2 Revision |
I think you can try like this
Mat im(50,50,CV_32FC2);
Point pt1(10,10),pt2(20,30);
for (int i = 0; i<im.rows; i++)
for (int j = 0; j<im.cols; j++)
im.at<Vec2f>(i,j) = Vec2f(i,j);
cv::LineIterator it(im, pt1, pt2, 8);
for (int i = 0; i < it.count; i++, ++it)
{
cv::Point p = it.pos();
Vec2f pixelValue = im.at<Vec2f>(p.y, p.x);
im.at<Vec2f>(p);
cout<<pixelValue<<endl;
}
3 | No.3 Revision |
I think you can try like this
Mat im(50,50,CV_32FC2);
Point pt1(10,10),pt2(20,30);
for (int i = 0; i<im.rows; i++)
for (int j = 0; j<im.cols; j++)
im.at<Vec2f>(i,j) = Vec2f(i,j);
cv::LineIterator it(im, pt1, pt2, 8);
for (int i = 0; i < it.count; i++, ++it)
{
cv::Point p = it.pos();
Vec2f pixelValue = im.at<Vec2f>(p);
cout<<pixelValue<<endl;
cout<<"pixel "<<p<<" = "<<pixelValue<<endl;
}