<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 3.2.0</li>
<li>Operating System / Platform =&gt; Windows 10 64-bit / Python</li>
<li>Compiler =&gt; MSC v.1900 64 bit (AMD64)</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">Using the VNG demosaicing in cvtColor( ) results in edge artifacts for edges running at orientations of 315 degrees (roughly NW -&gt; SE).  You can see these artifacts in the image below created with the OpenCV VNG algorithm (top row), but not in an image created using a reference implementation of the VNG algorithm (in attached code vng.py) (bottom row).  Some color artifacts along edges are expected due to the nature of the interpolation, but the artifacts shown here on edges running from upper left to lower right are more severe than expected, and worse than the reference output.  Displaying a single channel (such as just the red channel shown on the right) makes it easier to see that pixels far from the edge are being modified in the OpenCV version.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/47040981/60977391-66679200-a2fd-11e9-8e16-ab784eb6d64f.PNG"><img width="702" alt="edges315" src="https://user-images.githubusercontent.com/47040981/60977391-66679200-a2fd-11e9-8e16-ab784eb6d64f.PNG" style="max-width: 100%;"></a></p>
<p dir="auto">For edges running along different orientations, such as 45 degrees (roughly SW -&gt; NE), the OpenCV VNG implementation does not show artifacts, and appears to match the reference VNG implementation, as shown below.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/47040981/60977435-75e6db00-a2fd-11e9-9993-4b32097a91d5.PNG"><img width="705" alt="edges45" src="https://user-images.githubusercontent.com/47040981/60977435-75e6db00-a2fd-11e9-9993-4b32097a91d5.PNG" style="max-width: 100%;"></a></p>
<p dir="auto">Since the VNG algorithm computes gradients in the eight compass directions and there are separate blocks of code for processing each gradient direction, is it possible that there is a pointer error in the code for one of the gradient directions ?</p>
<h5 dir="auto">Steps to reproduce</h5>

<p dir="auto">The examples above were generated by calling OpenCV from Python inside a Jupyter Notebook.<br>
The input and output images for the examples above are attached, and can be duplicated by running the attached notebook "VNG_bug.ipynb"</p>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/3378154/VNG_bug.zip">VNG_bug.zip</a></p>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.3</li>
<li>Operating System / Platform =&gt; Ubuntu 16.04 x86-64</li>
<li>Compiler =&gt; g++ 5.4.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto"><code class="notranslate">CascadeClassifier::detectMultiScale</code> (<a href="https://docs.opencv.org/3.3.0/d1/de5/classcv_1_1CascadeClassifier.html#aaf8181cb63968136476ec4204ffca498" rel="nofollow">https://docs.opencv.org/3.3.0/d1/de5/classcv_1_1CascadeClassifier.html#aaf8181cb63968136476ec4204ffca498</a>) is not <code class="notranslate">const</code>, but it should be, in my opinion.</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">In my opinion, it should be possible to build a function like the following, since detection should not alter the internal state of the cascade (as no training is happening):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="static void FindFaces(const Mat &amp;image, /*const*/ CascadeClassifier &amp;classifier, vector&lt;Rect&gt; &amp;faces) //detectMultiScale should be const, but is not
{
  classifier.detectMultiScale(image, faces /* optional parameters here */);
}"><pre class="notranslate"><code class="notranslate">static void FindFaces(const Mat &amp;image, /*const*/ CascadeClassifier &amp;classifier, vector&lt;Rect&gt; &amp;faces) //detectMultiScale should be const, but is not
{
  classifier.detectMultiScale(image, faces /* optional parameters here */);
}
</code></pre></div>
<p dir="auto">Maybe the method can even be made <code class="notranslate">const</code> even in the base class, <code class="notranslate">BaseCascadeClassifier</code> (<a href="https://docs.opencv.org/3.3.0/da/dd5/classcv_1_1BaseCascadeClassifier.html#a68623391e16daa264f089af99d8d4bbb" rel="nofollow">https://docs.opencv.org/3.3.0/da/dd5/classcv_1_1BaseCascadeClassifier.html#a68623391e16daa264f089af99d8d4bbb</a>)</p>