Calculate sum of absolute difference per pixel I am trying to implement a research paper just to verify my results. I have shared the code (written by me) and the description of the process given in the research paper. Unfortunately my results are a bit different from his results that means I am doing something wrong. Kindly guide me in the right direction.

Here is the link to the paper: A parametric model for perceptual video quality estimation.

I have tried for mobile video sequence which can be downloaded from the following link: Yuv video sequences.

He gets 3.600 as SAD/pixel value while I am getting around 1.

Code:

fileName = 'mobile_cif.yuv';
    width=352;
    height=288;
    numFrames=30;
    SAD=0;

    %for loop to traverse &amp; process from frame '1' to 'last' frames
    for t = 1 : numFrames
    if t &lt; numFrames %(Need to traverse to n-1 frames)
    result=loadFileYuv(fileName,width,height,t);
    currFrame = result.cdata;    %reading Current frame
    result=loadFileYuv(fileName,width,height,t+1);
    nextFrame = result.cdata;    %reading Next frame
    % First, take the absolute value of the difference at each pixel
    myAbsDiff = abs(double(currFrame) - double(nextFrame));
    % Then, sum over all pixels
    out = sum(myAbsDiff(:));
    out=out/(width*height); %(Taking Average with respect to pixel)
    out=out/64;%(Dividing By Block size to normalize)
    disp(out);
    SAD=SAD+out;
    else
        continue;
    end

    end
    disp(SAD/numFrames);  %(Taking Average with respect to Frames)


Process Description

Sum of absolute difference (SAD) is a simple video quality metric used for block comparison and for moving vectors calculations. Each frame is divided into small blocks (i.e. $8 \times 8$ pixels) and for every block in one frame the most similar (minimum SAD) block in next frame is find. This minimum sum of absolutes differences is assigned as the SAD for each block in each frame (up to the $n − 1$ frame). Then all the SAD values are averaged for each frame and for all the frames in the clip, and divided by the block area, for normalization.
I think there are multiple things to consider here:

1) Where are you dividing the image into 8x8 blocks? If you don't divide like this, then normalization by 64 is meaningless, and you are just computing SAD over all pixels. Maybe I'm seeing something wrong? You should do the normalized SAD in those small windows and then sum and normalize. And since 3600 is not a normalized value, I don't think that he normalizes.

2) Have you considered that your function for loading the video or the codec you use is actually giving you slightly different values than the one he uses? If your input is different, you will obviously get different results.