Update on the compare lines method.
authorDaniel Angelov <dani_angelov@yahoo.com>
Wed, 4 Sep 2013 21:02:24 +0000 (00:02 +0300)
committerDaniel Angelov <dani_angelov@yahoo.com>
Wed, 4 Sep 2013 21:02:24 +0000 (00:02 +0300)
modules/imgproc/doc/feature_detection.rst
modules/imgproc/src/lsd.cpp

index ef44c05..a6d5817 100644 (file)
@@ -598,7 +598,7 @@ Draws two groups of lines in blue and red, counting the non overlapping (mismatc
 
     :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.
 
 
 
index 9b57a34..b860751 100644 (file)
@@ -1220,12 +1220,9 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1
 
     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)
         {
@@ -1233,11 +1230,12 @@ int LineSegmentDetectorImpl::compareSegments(const Size& size, InputArray lines1
             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;
             }
         }
     }