Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, it mostly depends on how you'll use your matrices. If you're doing a lot of "jumping" anyways - it won't make much difference, but in 'continuous' use cases, it will matter a few dozens of percents.</p> <p>The following example (which simply shifts the matrices values) gives me an output:</p> <pre><code>image.isContinuous() = 1 roi.isContinuous() = 0 image: 0.0162504 s roi: 0.0219723 s Sanity check: OK </code></pre> <p>Which is about 30% difference. Your millage will vary depending on the hardware and actual use cases.</p> <p>Source (notice how the first loop is much simpler in that case):</p> <pre><code>#include &lt;opencv2/core/core.hpp&gt; #include &lt;iostream&gt; using namespace cv; using namespace std; int main( int argc, char** argv ) { int cols = 4096; int rows = 4096; int scale = 2; Mat image(rows, cols, CV_8UC1); Mat image_big(rows * scale, cols * scale, CV_8UC1); Mat roi = image_big(Rect(0, 0, cols, rows)); randu(image, 0, 255); image.copyTo(roi); cout &lt;&lt; "image.isContinuous() = " &lt;&lt; image.isContinuous() &lt;&lt; "\n" &lt;&lt; "roi.isContinuous() = " &lt;&lt; roi.isContinuous() &lt;&lt; endl; { cout &lt;&lt; "image: "; double start = getTickCount(); for (int i = 1; i &lt; image.total(); i++) { image.data[i - 1] = image.data[i]; } cout &lt;&lt; (getTickCount() - start)/getTickFrequency() &lt;&lt; " s" &lt;&lt; endl; } { cout &lt;&lt; "roi: "; double start = getTickCount(); for (int y = 0; y &lt; roi.cols; y++) { if (y != 0) { roi.ptr&lt;char&gt;(y-1)[roi.cols-1] = roi.ptr&lt;char&gt;(y)[0]; } for (int x = 1; x &lt; roi.rows; x++) { roi.ptr&lt;char&gt;(y)[x - 1] = roi.ptr&lt;char&gt;(y)[x]; } } cout &lt;&lt; (getTickCount() - start)/getTickFrequency() &lt;&lt; " s" &lt;&lt; endl; } cout &lt;&lt; "Sanity check: " &lt;&lt; (countNonZero(image - roi) ? "FAIL" : "OK") &lt;&lt; endl; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload