1 | initial version |
Mat img = imread("sparks.png"); // bgr image
Point p1(20, 20); // start & end points
Point p2(80, 50);
LineIterator it(img, p1, p2, 8); // get a line iterator
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90;
(*it)[1] = 210;
(*it)[2] = 240;
}
}
imshow("img", img);
waitKey();
2 | No.2 Revision |
This simple code colours the line in yellow:
Mat img = imread("sparks.png"); // bgr image
imread("sparks.png");
Point p1(20, 20); // start & end points
20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8); // get a line iterator
8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90;
(*it)[1] = 210;
(*it)[2] = 240;
}
}
imshow("img", img);
waitKey();
3 | No.3 Revision |
This simple code colours the line in yellow:
Mat img = imread("sparks.png");
Point p1(20, 20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90;
(*it)[1] = 210;
(*it)[2] = 240;
}
}
imshow("img", img);
waitKey();
4 | No.4 Revision |
This code colours the line in yellow:
Mat img = imread("sparks.png");
if (img.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
Point p1(20, 20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90;
(*it)[1] = 210;
(*it)[2] = 240;
}
}
imshow("img", img);
waitKey();
5 | No.5 Revision |
This code colours the line in yellow:
Mat img = imread("sparks.png");
if (img.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
Point p1(20, 20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90;
90; // Blue
(*it)[1] = 210;
210; // Green
(*it)[2] = 240;
240; // Red
}
}
imshow("img", img);
waitKey();
6 | No.6 Revision |
This code colours the line in yellow:
Mat img = imread("sparks.png");
if (img.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
Point p1(20, 20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90; // Blue
(*it)[1] = 210; // Green
(*it)[2] = 240; // Red
}
}
imshow("img", img);
waitKey();
If you find that this code is helpful, please mark this answer as correct! :)
7 | No.7 Revision |
This code colours the line in yellow:yellow. If you find that this code is helpful, please mark this answer as correct! :)
Mat img = imread("sparks.png");
if (img.empty())
{
cout << "Error loading image file" << endl;
return -1;
}
Point p1(20, 20);
Point p2(80, 50);
LineIterator it(img, p1, p2, 8);
for (int i = 0; i < it.count; i++, it++)
{
if (i % 5 != 0)
{
// Yellow
(*it)[0] = 90; // Blue
(*it)[1] = 210; // Green
(*it)[2] = 240; // Red
}
}
imshow("img", img);
waitKey();
If you find that this code is helpful, please mark this answer as correct! :)