public int[] getTemplatePixels(int x0, int y0, int x1, int y1) {
		int retPixels[] = new int [735]; /* 21*35 */
		int xLen, yLen, sX, sY, cX, cY, oX, oY;
	    double xInc, yInc, nY, scale;
	    
	    xLen = x1 - x0;
	    yLen = y1 - y0;
	    
	    /* distance between the eyes is 23 pixels from experiences */
	    xInc = (double)xLen / 23d; 
	    yInc = (double)yLen / 23d;
	    
	    /*scale factor */
	    scale = Math.sqrt(Math.pow(xLen,2)+Math.pow(yLen,2))/23d;
	    
	    /* 6 from (35 - 23) / 2 and 8 because the eyes are on the 8 row from experiments */
	    oX = x0 - (int)(6 * xInc) + (int)(8 * yInc);
	    nY = (yLen != 0) ? ((8 * yInc) * xLen / yLen) : (8 * scale);
	    oY = y0 - (int)nY;
	    
        /* rotate the template to a horizontal position */
	    sX = oX;
	    sY = oY; 
	    for (int y = 0; y < 21; y++) {
	    	cX = sX;
	    	cY = sY;
	    	for (int x = 0; x < 35; x++) {
	    		if ((cX >= 0) && (cX < width) && (cY < height) && (cY >= 0)) {
	    			retPixels[y * 35 + x]= pixels[cY * width + cX];
	    		}
	    		cX = sX + (int)((x + 1) * xInc);
	    		cY = sY + (int)((x + 1) * yInc);
	    	}
	    	sX = oX - (int)((y + 1) * yInc);
	    	sY = oY + (int)((y + 1) * xInc);
	    }
	    
		return retPixels;
	}