// final double adjustedRMSE = (1-prevOutlierRatio)*RMSE;
Parallel.loop(0, hessianGradientTransformerData.length, settings.numThreads, new Looper() {
public void loop(int from, int to, int looperID) {
for (int i = 0; i < n; i++) {
Data d = hessianGradientTransformerData[looperID][i];
d.srcImg = template [pyramidLevel];
d.subImg = transformed[pyramidLevel];
d.srcDotImg = residual [pyramidLevel];
d.transImg = d.dstImg = null;
d.mask = roiMask[pyramidLevel];
d.zeroThreshold = /*adjustedRMSE**/settings.zeroThresholds [Math.min(settings.zeroThresholds .length-1, pyramidLevel)];
d.outlierThreshold = /*adjustedRMSE**/settings.outlierThresholds[Math.min(settings.outlierThresholds.length-1, pyramidLevel)];
d.pyramidLevel = pyramidLevel;
}
int y1 = roi.y() + looperID *roi.height()/hessianGradientTransformerData.length;
int y2 = roi.y() + (looperID+1)*roi.height()/hessianGradientTransformerData.length;
subroi[looperID].x (roi.x());
subroi[looperID].y (y1);
subroi[looperID].width (roi.width());
subroi[looperID].height(y2-y1);
transformer.transform(hessianGradientTransformerData[looperID], subroi[looperID], tempParameters, null);
}});
double dstCount = 0;
double dstCountZero = 0;
double dstCountOutlier = 0;
for (Data[] data : hessianGradientTransformerData) {
dstCount += data[0].dstCount;
dstCountZero += data[0].dstCountZero;
dstCountOutlier += data[0].dstCountOutlier;
for (int i = 0; i < n; i++) {
Data d = (Data)data[i];
gradient.put(i, gradient.get(i) - d.srcDstDot);
for (int j = 0; j < n; j++) {
hessian.put(i, j, hessian.get(i, j) + d.dstDstDot[j]);
}
}