Ask Your Question

Revision history [back]

click to hide/show revision 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();

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();

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();

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();

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();

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! :)

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! :)