Can anybody help me debug my plugin?
Posted by junsheng on Jan 23, 2006; 10:28am
URL: http://imagej.273.s1.nabble.com/Can-anybody-help-me-debug-my-plugin-tp3703969.html
Hello,
I want to do the z direction median filter to generate a median value in
different slice for background substraction. I have some problem in
debug the following plugin. Can anybody help me with it.
Thank you very much.
Best wishes,
Junsheng Wang
public class Z_Direction_Median_Filter implements PlugInFilter{
int m = stack.getWidth();
int n = stack.getHeight();
int dimension = m*n;
int nSlices = stack.getSize();
public double[] zPixels;
public double[] xyPixels;
public double zMedian = 0;
public void run() {
if (nSlices==1)
exit("Stack required");
for (j=1; j<=dimension; j++)
for (i=1; i<=nSlices; i++) {
setSlice(i);
zPixels[i]=(double)stack.getPixels(i);
}
zMedian=median(zPixels);
xyPixels[j]=zMedian;
}
run("Duplicate...", "title=zMedian");
run("Select All");
setColor(xyPixels);
run("Fill");
}
private static double median(double array[]){
Arrays.sort(array);
int len = array.length;
if(len%2==0)return((array[(len/2)-1]+array[len/2])/2);
else return array[((len-1)/2)];
}
}