/** Returns the 3 samples for the pixel at (x,y) in an array of int. 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[3]; int c = getPixel(x, y); iArray[0] = (c&0xff0000)>>16; iArray[1] = (c&0xff00)>>8; iArray[2] = c&0xff; return iArray; }
/** Returns the 3 samples for the pixel at (x,y) in an array of int. 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[3]; int c = getPixel(x, y); iArray[0] = (c&0xff0000)>>16; iArray[1] = (c&0xff00)>>8; iArray[2] = c&0xff; return iArray; }
/** Uses bilinear interpolation to find the pixel value at real coordinates (x,y). */ public int getInterpolatedRGBPixel(double x, double y) { if (width==1||height==1) return getPixel((int)x, (int)y); if (x<0.0) x = 0.0; if (x>=width-1.0) x = width-1.001; if (y<0.0) y = 0.0; if (y>=height-1.0) y = height-1.001; return getInterpolatedPixel(x, y, pixels); }
/** Uses bilinear interpolation to find the pixel value at real coordinates (x,y). */ public int getInterpolatedRGBPixel(double x, double y) { if (width==1||height==1) return getPixel((int)x, (int)y); if (x<0.0) x = 0.0; if (x>=width-1.0) x = width-1.001; if (y<0.0) y = 0.0; if (y>=height-1.0) y = height-1.001; return getInterpolatedPixel(x, y, pixels); }
private float[] getOrthoLine(ImageProcessor ip, int x1, int y1, int x2, int y2, float[] data) { int dx = x2-x1; int dy = y2-y1; int n = Math.max(Math.abs(dx), Math.abs(dy)); if (data==null) data = new float[n]; int xinc = dx/n; int yinc = dy/n; int rx = x1; int ry = y1; for (int i=0; i<n; i++) { if (notFloat) data[i] = (float)ip.getPixel(rx, ry); else if (rgb) { int rgbPixel = ((ColorProcessor)ip).getPixel(rx, ry); data[i] = Float.intBitsToFloat(rgbPixel&0xffffff); } else data[i] = (float)ip.getPixelValue(rx, ry); rx += xinc; ry += yinc; } return data; }
public void mouseMoved(final MouseEvent e) { try { final int value = cp.getPixel(e.getX(),e.getY()); r = (value&0xFF0000)>>16; g = (value&0x00FF00)>>8; b = (value&0x0000FF); showRGB(); } catch (Throwable x) { mtrackj.catcher().uncaughtException(Thread.currentThread(),x); } }
private float[] getOrthoLine(ImageProcessor ip, int x1, int y1, int x2, int y2, float[] data) { int dx = x2-x1; int dy = y2-y1; int n = Math.max(Math.abs(dx), Math.abs(dy)); if (data==null) data = new float[n]; int xinc = dx/n; int yinc = dy/n; int rx = x1; int ry = y1; for (int i=0; i<n; i++) { if (notFloat) data[i] = (float)ip.getPixel(rx, ry); else if (rgb) { int rgbPixel = ((ColorProcessor)ip).getPixel(rx, ry); data[i] = Float.intBitsToFloat(rgbPixel&0xffffff); } else data[i] = (float)ip.getPixelValue(rx, ry); rx += xinc; ry += yinc; } return data; }
data[i] = ip.getPixel(rx, ry); else if (rgb) { final int rgbPixel = ((ColorProcessor) ip).getPixel(rx, ry); data[i] = Float.intBitsToFloat(rgbPixel & 0xffffff); } else
for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { int c = proc.getPixel(i, j); pixels[3 * (i + w * j) + 0] = (byte)((c & 0xff0000) >> 16);
for (int j = 0; j < h; j++) for (int i = 0; i < w; i++) { int c = proc.getPixel(i, j); pixels[3 * (i + w * j) + 0] = (byte)((c & 0xff0000) >> 16);
/** * Tests closing can be run on an RGB image. */ @Test public void testClosing_Square_RGB() { String fileName = getClass().getResource("/files/peppers-crop.png").getFile(); ImagePlus imagePlus = IJ.openImage(fileName); assertNotNull(imagePlus); ColorProcessor image = (ColorProcessor) imagePlus.getProcessor(); Strel strel = SquareStrel.fromDiameter(5); ColorProcessor result = (ColorProcessor) Morphology.closing(image, strel); assertNotNull(result); // Check that result is greater than or equal to the original image int width = image.getWidth(); int height = image.getHeight(); int[] rgb0 = new int[3]; int[] rgb = new int[3]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { image.getPixel(x, y, rgb0); result.getPixel(x, y, rgb); for (int c = 0; c < 3; c++) assertTrue(rgb[c] >= rgb0[c]); } } }
/** * Tests closing can be run on an RGB image. */ @Test public void testOpening_Square_RGB() { String fileName = getClass().getResource("/files/peppers-crop.png").getFile(); ImagePlus imagePlus = IJ.openImage(fileName); assertNotNull(imagePlus); ColorProcessor image = (ColorProcessor) imagePlus.getProcessor(); Strel strel = SquareStrel.fromDiameter(5); ColorProcessor result = (ColorProcessor) Morphology.opening(image, strel); assertNotNull(result); // Check that result is lower than or equal to the original image int width = image.getWidth(); int height = image.getHeight(); int[] rgb0 = new int[3]; int[] rgb = new int[3]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { image.getPixel(x, y, rgb0); result.getPixel(x, y, rgb); for (int c = 0; c < 3; c++) assertTrue(rgb[c] <= rgb0[c]); } } }
for (int y = 0; y < montageImageHeight; y++) { final int pos = x + montageImageWidth * y; proc.getPixel(x, y, rgb);
for (int y = 0; y < imp.getHeight(); y++) { final int pos = x + imp.getWidth() * y; proc.getPixel(x, y, rgb);