Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems to me you aren't counting different pixels, not even pixels at all.<br> You are counting how often a color channel of one pixel in the first image matches the channel of the corresponding pixel in the other image.</p> <p>You probably meant to do something along the lines of:</p> <pre><code>... //in the inner for loop if(row[x] != row2[x] || row[x+1] != row2[x+1] || row[x+2] != row2[x+2]) count++; ... </code></pre> <p>This will however not account for the alpha channel (if present) and will fail on grayscale images as you might read out of bounds of the data array.</p> <p><strong>EDIT:</strong> As long as you don't release the old image it should be fine. However, it might be better to do something like:</p> <pre><code>//make sure size and channels are correct. //If unsure, load the image first and then create with the parameters taken from the loaded image. cvCreateImage(cvSize(640, 480), 8, 3); //use cvCopy to copy the contents and proceed as normal cvCopy(fIplImageHeader , lastFIplImageHeader); </code></pre> <p>Alternatively, instead of copying, you could just hold a pointer to the old image and use that, as long as you don't release it.</p> <pre><code>lastFIplImageHeader = fIplImageHeader; fIplImageHeader = cvLoadImage( filePath.c_str() ); </code></pre> <p><strong>EDIT2:</strong> If the difference is all you want, you could have a look at <a href="http://opencv.willowgarage.com/documentation/operations_on_arrays.html#cvSub" rel="nofollow">cvSub</a> (with both images loaded as grayscale), followed by <a href="http://opencv.willowgarage.com/documentation/operations_on_arrays.html#cvCountNonZero" rel="nofollow">cvCountNonZero</a></p>
    singulars
    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