/** Returns a copy of the pixel data as a 2D float array with dimensions [x=0..width-1][y=0..height-1]. */ public float[][] getFloatArray() { float[][] a = new float[width][height]; for(int y=0; y<height; y++) { for(int x=0; x<width; x++) a[x][y]=getf(x,y); } return a; }
private float getAverage(ImageProcessor ip, int x, int y) { float sum = 0; for (int y2=0; y2<yshrink; y2++) { for (int x2=0; x2<xshrink; x2++) sum += ip.getf(x*xshrink+x2, y*yshrink+y2); } return (float)(sum/(xshrink*yshrink)); }
private float getSum(ImageProcessor ip, int x, int y) { float sum = 0; for (int y2=0; y2<yshrink; y2++) { for (int x2=0; x2<xshrink; x2++) sum += ip.getf(x*xshrink+x2, y*yshrink+y2); } if (maxValue>0f && sum>maxValue) sum = maxValue; return sum; }
private float getMin(ImageProcessor ip, int x, int y) { float min = Float.MAX_VALUE; float pixel; for (int y2=0; y2<yshrink; y2++) { for (int x2=0; x2<xshrink; x2++) { pixel = ip.getf(x*xshrink+x2, y*yshrink+y2); if (pixel<min) min = pixel; } } return min; }
/** Returns the pixel values along the horizontal line starting at (x,y). */ public float[] getRow(int x, int y, float[] data, int length) { if (data==null) data = new float[length]; for (int i=0; i<length; i++) data[i] = getf(x++, y); return data; }
private float getMax(ImageProcessor ip, int x, int y) { float max = -Float.MAX_VALUE; float pixel; for (int y2=0; y2<yshrink; y2++) { for (int x2=0; x2<xshrink; x2++) { pixel = ip.getf(x*xshrink+x2, y*yshrink+y2); if (pixel>max) max = pixel; } } return max; }
final boolean isBackground(int x, int y) { return ip.getf(x, y) == background; } }
final boolean selected(int x, int y) { float v = ip.getf(x,y); return v>=min && v<=max; }
private float getMax(ImageProcessor ip, int x, int y) { float max = -Float.MAX_VALUE; float pixel; for (int y2=0; y2<yshrink; y2++) { for (int x2=0; x2<xshrink; x2++) { pixel = ip.getf(x*xshrink+x2, y*yshrink+y2); if (pixel>max) max = pixel; } } return max; }
/** Returns the pixel values along the horizontal line starting at (x,y). */ public float[] getRow(int x, int y, float[] data, int length) { if (data==null) data = new float[length]; for (int i=0; i<length; i++) data[i] = getf(x++, y); return data; }
@Override public float getf(int x, int y) { record("getf", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getf(x, y); }
@Override public float getf(int x, int y) { record("getf", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getf(x, y); }
@Override public float getf(int index) { record("getf", new Integer(index), int.class); return proc.getf(index); }
@Override public void add(int x, int y) { mean += ip.getf(x, y); super.add(x, y); }
@Override public double getDiff(int x, int y) { float c = mean - ip.getf(x, y); return super.getDiff(x, y) + c * c; }
@Override public float getf(int index) { record("getf", new Integer(index), int.class); return proc.getf(index); }
double getColorValue(Color color) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()==24) return color.getRGB()&0xffffff; ImageProcessor ip = imp.getProcessor(); ip.setRoi(0,0,1,1); ip = ip.crop(); ip.setColor(color); ip.drawDot(0,0); return ip.getf(0,0); }