Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you wish to do this using SDL (which your tag indicates) you would want to access the pixels of the frames and iterate over them manually. You can do this with code similar to this (assuming your images are 32-bit surfaces):</p> <pre><code>Uint32 *pixelBuffer = (Uint32 *)surface-&gt;pixels; Uint32 pixel pixelBuffer[ ( y * surface-&gt;w ) + x ]; </code></pre> <p>Where x and y is the position you want to access. You can set pixels in a similar manner:</p> <pre><code>Uint32 pixel = SDL_MapRGB(surface-&gt;format, r, g, b); Uint32 *pixelBuffer = (Uint32 *)surface-&gt;pixels; pixelBuffer[ ( y * surface-&gt;w ) + x ] = pixel; </code></pre> <p>You would have to implement the "difference" for each pixel yourself, as well as the normalization.</p> <p>If you don't have to do this in SDL there are other image libraries better suited for this, such as OpenCV or OpenIL.</p> <p>Part two of your question is really very simple in SDL, just make a window (SDL_SetVideoMode) that is twice the width and height of you frame, and render the different screens at an offset. If you are a newcomer to SDL, I recommend that you look trough <a href="http://lazyfoo.net/SDL_tutorials/index.php" rel="nofollow">this tutorial</a>. It is good for reference if nothing else.</p> <p>EDIT: Difference... is just the difference between images I would assume? Some pseudocode:</p> <pre><code>for each pixel at coordinate (x,y) in surface residual: residual(x,y) = abs(target(x,y) - reference(x,y)) </code></pre> <p>For normalization, simply find the darkest value and lightest value in the residual surface (by brute force iteration for example). We shall call these <code>minVal</code> and <code>maxVal</code>, and the entire light range <code>scale = maxVal - minVal</code>:</p> <pre><code>residual(x,y) = (diff(x,y) - minVal) / scale </code></pre> <p>This will normalize each pixel to a range between 0 and 1. You will have to multiply it by whatever you want your lightest color to be (make sure not to lose precision through integer conversions here).</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.
 

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