有人可以为我提供一些关于如何将此代码移植到渲染脚本以获得更好性能的指南。
private void someMethod() {
for (int i = 0; i < src.rows(); i++) {
for (int j = 0; j < src.cols(); j++) {
double hsv[] = src.get(i, j);
double modifedHSV[] = this.modifyHSV(new Scalar(hsv), selectedRepaintColor, mean);
res.put(i, j, modifedHSV);
}
}
}
private double[] modifyHSV(Scalar hsvImage, Scalar selectedHsv, Scalar mean) {
Double h_final = hsvImage.val[0] - mean.val[0] + selectedHsv.val[0];
Double s_final = hsvImage.val[1] - mean.val[1] + selectedHsv.val[1];
Double v_final = hsvImage.val[2] - mean.val[2] + selectedHsv.val[2];
h_final = (h_final <= 0) ? h_final + 180 : h_final;
s_final = (s_final <= 0) ? 0 : s_final;
v_final = (v_final <= 0) ? 0 : v_final;
double[] final_hsv = new double[3];
final_hsv[0] = h_final;
final_hsv[1] = s_final;
final_hsv[2] = v_final;
return final_hsv;
}