private void compareFrames() 
    {
        int r, g, b,
            refDataInt, inDataInt,
            ip = 0, op = 0,
            x = 0, y = 0;
        byte result;
        while (ip < refData.length) 
        {
            refDataInt = (int) refData[ip] & 255;
            inDataInt = (int) this.inData[ip++] & 255;
            r = refDataInt - inDataInt;
            
            refDataInt = (int) refData[ip] & 255;
            inDataInt = (int) this.inData[ip++] & 255;
            g = refDataInt - inDataInt;
            
            refDataInt = (int) refData[ip] & 255;
            inDataInt = (int) this.inData[ip++] & 255;
            b = refDataInt - inDataInt;
            
            result = (byte) (Math.sqrt((double) ((r * r) + (g * g) + (b * b)) / 3.0));
            //black/white image now.
            if (result > (byte) this.threshold) 
            {
                if (validateActionSection(x, y))
                {
                    detectionScreen[op++] = (byte) 255;
                    detectionScreen[op++] = (byte) 0;
                    detectionScreen[op++] = (byte) 0;
                }
                else
                {
                    
                    detectionScreen[op++] = (byte) 0;
                    detectionScreen[op++] = (byte) 255;
                    detectionScreen[op++] = (byte) 0;
                }
            } 
            else 
            {
                detectionScreen[op++] = (byte) result;
                detectionScreen[op++] = (byte) result;
                detectionScreen[op++] = (byte) result;
            }
            
            y = x == this.sizeIn.width ? y + 1 : y;
            x = x == this.sizeIn.width ? 0 : x + 1;
        }
    }