private long calcSSD (int[] org, int[] dec, int width, int height) {
        long ssd = 0;
        for (int y = 0; y < height; y++) {
           for (int x = 0; x < width; x++) {
                int diff = org[y * width + x] - dec[y * width + x];
                ssd += diff * diff; 
            } 
        }
        return ssd;
    }