/** Returns the pixel values along the horizontal line starting at (x,y). */ public void getRow(int x, int y, int[] data, int length) { for (int i=0; i<length; i++) data[i] = getPixel(x++, y); }
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; } }
/** Returns the pixel values along the horizontal line starting at (x,y). */ public void getRow(int x, int y, int[] data, int length) { for (int i=0; i<length; i++) data[i] = getPixel(x++, y); }
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; } }
/** Returns the samples for the pixel at (x,y) in an int array. RGB pixels have three samples, all others have one. Returns zeros if the the coordinates are not in bounds. iArray is an optional preallocated array. */ public int[] getPixel(int x, int y, int[] iArray) { if (iArray==null) iArray = new int[1]; iArray[0] = getPixel(x, y); return iArray; }
/** Returns the pixel values down the column starting at (x,y). */ public void getColumn(int x, int y, int[] data, int length) { for (int i=0; i<length; i++) data[i] = getPixel(x, y++); }
/** Returns the pixel values down the column starting at (x,y). */ public void getColumn(int x, int y, int[] data, int length) { for (int i=0; i<length; i++) data[i] = getPixel(x, y++); }
/** Returns the samples for the pixel at (x,y) in an int array. RGB pixels have three samples, all others have one. Returns zeros if the the coordinates are not in bounds. iArray is an optional preallocated array. */ public int[] getPixel(int x, int y, int[] iArray) { if (iArray==null) iArray = new int[1]; iArray[0] = getPixel(x, y); return iArray; }
@Override public int getPixel(int x, int y) { record("getPixel", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getPixel(x, y); }
@Override public int[] getPixel(int x, int y, int[] iArray) { record("getPixel", new Object[] {new Integer(x), new Integer(y), iArray}, new Class[] {int.class, int.class, int[].class}); return proc.getPixel(x, y, iArray); }
@Override public int getPixel(int x, int y) { record("getPixel", new Object[] {new Integer(x), new Integer(y)}, new Class[] {int.class, int.class}); return proc.getPixel(x, y); }
ImagePlus im = IJ.getImage(); ImageProcessor imp = im.getProcessor(); int[] rgb = new int[3]; imp.getPixel(X,Y,rgb); IJ.log(Arrays.toString(rgb));
@Override public int[] getPixel(int x, int y, int[] iArray) { record("getPixel", new Object[] {new Integer(x), new Integer(y), iArray}, new Class[] {int.class, int.class, int[].class}); return proc.getPixel(x, y, iArray); }
protected boolean withinBoundsAndThreshold(final int x, final int y) { return withinXYbounds(x, y) && withinThreshold(ip.getPixel(x, y)); }
ImageProcessor trimPlot(ImageProcessor plot, int maxTrim) { int background = plot.getPixel(0, 0); int width = plot.getWidth(); int height = plot.getHeight(); int trim = maxTrim-5; a: for (int y=0; y<(maxTrim-5); y++) for (int x=0; x<width; x++) if (plot.getPixel(x,y)!=background) {trim = y-5; break a;} if (trim>10) { plot.setRoi(0, trim, width, height-trim); plot = plot.crop(); } return plot; }
ImageProcessor trimPlot(ImageProcessor plot, int maxTrim) { int background = plot.getPixel(0, 0); int width = plot.getWidth(); int height = plot.getHeight(); int trim = maxTrim-5; a: for (int y=0; y<(maxTrim-5); y++) for (int x=0; x<width; x++) if (plot.getPixel(x,y)!=background) {trim = y-5; break a;} if (trim>10) { plot.setRoi(0, trim, width, height-trim); plot = plot.crop(); } return plot; }
ImageProcessor shrink(ImageProcessor ip, ImageProcessor ip2, boolean hasEdgePixels) { if (hasEdgePixels) { int width = ip.getWidth(); int height = ip.getHeight(); for (int y=0; y<height; y++) for (int x=0; x<width; x++) ip.putPixel(x, y, ip2.getPixel(x+1, y+1)); } return ip; }
ImageProcessor shrink(ImageProcessor ip, ImageProcessor ip2, boolean hasEdgePixels) { if (hasEdgePixels) { int width = ip.getWidth(); int height = ip.getHeight(); for (int y=0; y<height; y++) for (int x=0; x<width; x++) ip.putPixel(x, y, ip2.getPixel(x+1, y+1)); } return ip; }
final static protected void transform( final CoordinateTransform transform, final ImageProcessor source, final ImageProcessor target ) { for ( int y = 0; y < target.getHeight(); ++y ) { for ( int x = 0; x < target.getWidth(); ++x ) { final double[] t = new double[]{ x, y }; transform.applyInPlace( t ); target.putPixel( x, y, source.getPixel( ( int )t[ 0 ], ( int )t[ 1 ] ) ); } } }
final static protected void transform( final CoordinateTransform transform, final ImageProcessor source, final ImageProcessor target ) { for ( int y = 0; y < target.getHeight(); ++y ) { for ( int x = 0; x < target.getWidth(); ++x ) { final double[] t = new double[]{ x, y }; transform.applyInPlace( t ); target.putPixel( x, y, source.getPixel( ( int )t[ 0 ], ( int )t[ 1 ] ) ); } } }