private float getEdgeValue(int x, int y) { if (x<=0) x = 0; if (x>=width) x = width-1; if (y<=0) y = 0; if (y>=height) y = height-1; return getPixelValue(x, y); }
private float getEdgeValue(int x, int y) { if (x<=0) x = 0; if (x>=width) x = width-1; if (y<=0) y = 0; if (y>=height) y = height-1; return getPixelValue(x, y); }
private float getPixel(int x, int y) { if (x<0 || x>=width || y<0 || y>=height) return Float.NaN; if (bpixels!=null) return bpixels[y*width + x] & 0xff; else if (spixels!=null) return spixels[y*width + x] & 0xffff; else if (fpixels!=null) return fpixels[y*width + x]; else if (exactPixelValue) //RGB for exact match return cpixels[y*width + x] & 0xffffff; //don't care for upper byte else //gray value of RGB return ip.getPixelValue(x,y); }
@Override public float get(final float x, final float y) { final int i = (int) x; final int j = (int) y; final float fx = x - i; final float fy = y - j; final float v00 = ip.getPixelValue(i, j); final float v01 = ip.getPixelValue(i + 1, j); final float v10 = ip.getPixelValue(i, j + 1); final float v11 = ip.getPixelValue(i + 1, j + 1); return (1 - fx) * (1 - fy) * v00 + fx * (1 - fy) * v01 + (1 - fx) * fy * v10 + fx * fy * v11; } }
@Override public float get(float x, float y) { int i = (int)x; int j = (int)y; float fx = x - i; float fy = y - j; float v00 = ip.getPixelValue(i, j); float v01 = ip.getPixelValue(i + 1, j); float v10 = ip.getPixelValue(i, j + 1); float v11 = ip.getPixelValue(i + 1, j + 1); return (1 - fx) * (1 - fy) * v00 + fx * (1 - fy) * v01 + (1 - fx) * fy * v10 + fx * fy * v11; } }
/** * fills p the values in the original and creates * top and bot with 0 value everywhere */ private void fillArrays(){ this.p = new float[dim[0]][dim[1]]; this.top = new float[dim[0]][dim[1]]; this.bot = new float[dim[0]][dim[1]]; for (int y = 0; y < dim[1] ; y++){ for (int x = 0; x < dim[0]; x++){ p[x][y] = ip.getPixelValue(x,y); }//x loop }//y loop }//fillArrays
final boolean inParticle(int x, int y, double level1, double level2) { if (isFloat) return ip.getPixelValue(x,y)>=level1 && ip.getPixelValue(x,y)<=level2; else { int v = ip.getPixel(x,y); return v>=level1 && v<=level2; } }
final boolean inParticle(int x, int y, double level1, double level2) { if (isFloat) return ip.getPixelValue(x,y)>=level1 && ip.getPixelValue(x,y)<=level2; else { int v = ip.getPixel(x,y); return v>=level1 && v<=level2; } }
@Override public float getPixelValue(int x, int y) { record("getPixelValue", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getPixelValue(x, y); }
@Override public float getPixelValue(int x, int y) { record("getPixelValue", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getPixelValue(x, y); }
public Double call() { double pixelError = 0; for(int x=0; x<image1.getWidth(); x++) for(int y=0; y<image1.getHeight(); y++) { double pix1 = image1.getPixelValue(x, y) > binaryThreshold ? 1 : 0; double pix2 = image2.getPixelValue(x, y) > binaryThreshold ? 1 : 0; pixelError += ( pix1 - pix2 ) * ( pix1 - pix2 ) ; } return pixelError / (image1.getWidth() * image1.getHeight()); } };
public Double call() { double pixelError = 0; for(int x=0; x<image1.getWidth(); x++) for(int y=0; y<image1.getHeight(); y++) { double pix1 = image1.getPixelValue(x, y) > binaryThreshold ? 1 : 0; double pix2 = image2.getPixelValue(x, y) > binaryThreshold ? 1 : 0; pixelError += ( pix1 - pix2 ) * ( pix1 - pix2 ) ; } return pixelError / (image1.getWidth() * image1.getHeight()); } };
public Double call() { double pixelError = 0; for(int x=0; x<image1.getWidth(); x++) { for(int y=0; y<image1.getHeight(); y++) { double pix1 = image1.getPixelValue(x, y); double pix2 = image2.getPixelValue(x, y); pixelError += ( pix1 - pix2 ) * ( pix1 - pix2 ) ; } } return pixelError / (image1.getWidth() * image1.getHeight()); } };
/** tests that the pixels values of a cropped FakeFile are correct */ private void croppedPixelsTest(ImagePlus imp, int ox, int cropSize) { ImageProcessor proc = imp.getProcessor(); for (int ix = 0; ix < cropSize; ix++) for (int iy = 0; iy < cropSize; iy++) assertEquals(ox+ix,proc.getPixelValue(ix, iy),0); }
/** Creates a ResultsTable from an image or image selection. */ public static ResultsTable createTableFromImage(ImageProcessor ip) { ResultsTable rt = new ResultsTable(); Rectangle r = ip.getRoi(); for (int y=r.y; y<r.y+r.height; y++) { rt.incrementCounter(); rt.addLabel(" ", "Y"+y); for (int x=r.x; x<r.x+r.width; x++) rt.addValue("X"+x, ip.getPixelValue(x,y)); } return rt; }
/** Creates a ResultsTable from an image or image selection. */ public static ResultsTable createTableFromImage(ImageProcessor ip) { ResultsTable rt = new ResultsTable(); Rectangle r = ip.getRoi(); for (int y=r.y; y<r.y+r.height; y++) { rt.incrementCounter(); rt.addLabel(" ", "Y"+y); for (int x=r.x; x<r.x+r.width; x++) rt.addValue("X"+x, ip.getPixelValue(x,y)); } return rt; }
/** * bag class for getting the result of the loaded classifier */ private static class LoadedClassifier { private AbstractClassifier newClassifier = null; private Instances newHeader = null; }
/** * bag class for getting the result of the loaded classifier */ private static class LoadedClassifier { private AbstractClassifier newClassifier = null; private Instances newHeader = null; }
private ImageProcessor makeZeroTransparent(ImageProcessor ip, boolean transparent) { if (transparent) { ip.setColorModel(new DirectColorModel(32,0x00ff0000,0x0000ff00,0x000000ff,0xff000000)); for (int x=0; x<width; x++) { for (int y=0; y<height; y++) { double v = ip.getPixelValue(x, y); if (v>1) ip.set(x, y, ip.get(x,y)|0xff000000); // set alpha bits else ip.set(x, y, ip.get(x,y)&0xffffff); // clear alpha bits } } } return ip; }
/** get the actual pixel value (lookup when data is indexed) of the index of a fake image at a given z,c,t */ private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) { //TODO - restore - changed for compositeTest debugging setZctPosition(imp,z,c,t); setCztPosition(imp,z,c,t); int rawValue = (int) (imp.getProcessor().getPixelValue(x, y)); if ((!indexed) || (falseColor)) // TODO - disabling falseColor test here improves 3/1/indexed/falseColor return rawValue; // otherwise indexed - lookup pixel value in LUT LUT lut = getColorTable(imp,c); int value = lut.getRed(rawValue); // since r g and b vals should be the same choose one arbitrarily. // OR Use red in case lut len < 3 and zero fills other channels return value; }