:param lines2: The second group of lines. They visualized in red color.
- :param image: Optional image, where the lines will be drawn. The image is converted to grayscale before displaying, leaving lines1 and lines2 in the above mentioned colors.
+ :param image: Optional image, where the lines will be drawn. The image should be color in order for lines1 and lines2 to be drawn in the above mentioned colors.
if (_image.needed())
{
- Mat Ig;
- if (_image.channels() == 1)
- {
- cvtColor(_image, _image, CV_GRAY2BGR);
- }
- CV_Assert(_image.getMatRef().isContinuous() && I1.isContinuous() && I2.isContinuous());
+ CV_Assert(_image.channels() == 3);
+ Mat img = _image.getMatRef();
+ CV_Assert(img.isContinuous() && I1.isContinuous() && I2.isContinuous());
for (unsigned int i = 0; i < I1.total(); ++i)
{
uchar i2 = I2.data[i];
if (i1 || i2)
{
- _image.getMatRef().data[3*i + 1] = 0;
- if (i1) _image.getMatRef().data[3*i] = 255;
- else _image.getMatRef().data[3*i] = 0;
- if (i2) _image.getMatRef().data[3*i + 2] = 255;
- else _image.getMatRef().data[3*i + 2] = 0;
+ unsigned int base_idx = i * 3;
+ if (i1) img.data[base_idx] = 255;
+ else img.data[base_idx] = 0;
+ img.data[base_idx + 1] = 0;
+ if (i2) img.data[base_idx + 2] = 255;
+ else img.data[base_idx + 2] = 0;
}
}
}