|
Hello every body,
I am working with ImageJ for segmentation and i met a problem during calculating the sum of all gaussian kernel. This problem is TIME of Processing.
I must calculate the gaussian kernel of each pixel with all the others and so on. So, a great time spent to calculate this.
i wonder if there is a method to reduce this processing time ??
I need your help
Thank you
public double Ma(int [] pixels){
int i,j,a;
double Ma=0,var=0;
double sigma=0.2;
double sig=sigma*sigma;
double var1=1/(Math.PI*0.08);
double v,noyau;
for(i=0; i<pixels.length; i++){
for(a=0; a<pixels.length; a++){
int c = pixels[a];
double r = (c & 0xff0000)>>16;
double g = (c & 0x00ff00)>>8;
double b = (c & 0x0000ff);
int c1 = pixels[i];
double r1 = (c1 & 0xff0000)>>16;
double g1 = (c1 & 0x00ff00)>>8;
double b1 = (c1 & 0x0000ff);
v=distance(r1/255,g1/255,b1/255,r/255,g/255,b/255);
var=Math.exp((v*v)/(-0.08));
noyau= var1*var;
Ma=Ma+noyau;
}
}
return Ma;
}
|