Calculating Histogram Using Rsatomicinc In Renderscript Only Returns Address Instead Of The Count
I am trying to write a program for histogram calculation. So i have created a random array of 10 numbers treating it as the image array in 1D. The following is my renderscript and
Solution 1:
-1- I tested your code on API 19 and Nexus 5 and I see that difference[] prints are coming out correctly. My Java code is the same as yours, below is the script code with some minor differences.
#pragma version(1)#pragma rs java_package_name(com.clearvision.androidapps.clearview)#pragma rs_fp_fullvolatileint32_t *gOutarray;
rs_allocation gIn;
rs_allocation gOut;
rs_script gScript;
voidroot(constint32_t *v_in, int32_t *v_out, constvoid *usrData, uint32_t x, uint32_t y){
int32_t lum=*v_in;
rsDebug("present value:", *v_in);
volatileint32_t* addr=gOutarray + lum;
//rsDebug("present gOutarray address:", *gOutarray);rsDebug("present address:", *addr);
rsAtomicInc(addr);
}
voidincrement(){
rsForEach(gScript, gIn, gOut);
}
-2- I was previously incorrect. Below code is fine.
volatileint32_t* addr=gOutarray + lum;
-3- Your logcat probably shows error because of the following
for(int i=0;i<10;i++){
log("generated histogram counts:"+difference[i]);
}
difference array is defined with 6 int elements, while you are looping till 10. This is a problem.
Can you recheck?
Post a Comment for "Calculating Histogram Using Rsatomicinc In Renderscript Only Returns Address Instead Of The Count"