Speed up Android computations using RenderScript
Daniel Zolnai
52

Hi, I would like to move this code from java to renderscript.
Can you please provide me some guidelines.
code : https://pastebin.com/dFYdfxFH

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[] = 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;

}

Show your support

Clapping shows how much you appreciated sujeet.buddiga’s story.