public static void ArrayToByteProcessor(ImageProcessor ip, float[][] pixels) { byte[] data = new byte[pixels.length * pixels[0].length]; int count = 0; for (int y = 0; y < pixels[0].length; y++) for (int x = 0; x < pixels.length; x++) data[count++] = (byte)(((int)pixels[x][y]) & 0xff); ip.setPixels(data); }
public static void ArrayToByteProcessor(ImageProcessor ip, int[][] pixels) { byte[] data = new byte[pixels.length * pixels[0].length]; int count = 0; for (int y = 0; y < pixels[0].length; y++) for (int x = 0; x < pixels.length; x++) data[count++] = (byte)(pixels[x][y] & 0xff); ip.setPixels(data); }
public static void ArrayToFloatProcessor(ImageProcessor ip, double[] pixels, int width, int height) { float[] data = new float[width * height]; int count = 0; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) data[count] = (float)pixels[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
public static void ArrayToFloatProcessor(ImageProcessor ip, float[] pixels, int width, int height) { float[] data = new float[width * height]; int count = 0; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) data[count] = (float)pixels[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
public static void FloatArrayToFloatProcessor(ImageProcessor ip, FloatArray2D pixels) { float[] data = new float[pixels.width * pixels.height]; int count = 0; for (int y = 0; y < pixels.height; y++) for (int x = 0; x < pixels.width; x++) data[count] = pixels.data[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
public void setPixels(int channelNumber, FloatProcessor fp) { record("setPixels", new Object[] {new Integer(channelNumber), fp}, new Class[] {int.class, FloatProcessor.class}); proc.setPixels(channelNumber, fp); }
public void setPixels(int channelNumber, FloatProcessor fp) { record("setPixels", new Object[] {new Integer(channelNumber), fp}, new Class[] {int.class, FloatProcessor.class}); proc.setPixels(channelNumber, fp); }
public void setPixels(Object pixels) { record("setPixels", pixels, Object.class); proc.setPixels(pixels); }
public void setPixels(Object pixels) { record("setPixels", pixels, Object.class); proc.setPixels(pixels); }
/** * This method converts my FloatArray2D to an ImageJ ImageProcessor * * @param ip ImageProcessor; will be overwritten with the data from the FloatArray2D * @param pixels The image as FloatArray2D */ public static void FloatArrayToFloatProcessor(ImageProcessor ip, FloatArray2D pixels) { float[] data = new float[pixels.width * pixels.height]; int count = 0; for (int y = 0; y < pixels.height; y++) for (int x = 0; x < pixels.width; x++) data[count] = pixels.data[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
/** Converts a binary image into a 8-bit grayscale Euclidean Distance Map * (EDM). Each foreground (nonzero) pixel in the binary image is * assigned a value equal to its distance from the nearest * background (zero) pixel. */ public void toEDM (ImageProcessor ip) { ip.setPixels(0, makeFloatEDM(ip, 0, false)); ip.resetMinAndMax(); }
/** * Adds a slice with the given pixels to the end of the stack. * @param name The name of the slice. This parameter exists only for * compatibility reasons with ImageStack, but is not used * here. * @param pixels The pixel array for the new slice. */ public void addSlice(String name, Object pixels) { ImageProcessor ip = template.duplicate(); ip.setPixels(pixels); addSlice(name, ip); }
/** Converts a binary image into a 8-bit grayscale Euclidean Distance Map * (EDM). Each foreground (nonzero) pixel in the binary image is * assigned a value equal to its distance from the nearest * background (zero) pixel. */ public void toEDM (ImageProcessor ip) { ip.setPixels(0, makeFloatEDM(ip, 0, false)); ip.resetMinAndMax(); }
/** Converts a binary image into a 8-bit grayscale Euclidean Distance Map * (ImageJ_EDM). Each foreground (nonzero) pixel in the binary image is * assigned a value equal to its distance from the nearest * background (zero) pixel. */ public void toEDM (ImageProcessor ip) { ip.setPixels(0, makeFloatEDM(ip, 0, false)); ip.resetMinAndMax(); }
public void setPixels(Object pixels, int n) { if (n<1 || n>patch.length) throw new IllegalArgumentException("PatchStack: out of range " + n); if (null == pixels) throw new IllegalArgumentException("PatchStack: 'pixels' is null!"); ImagePlus imp = patch[n-1].getProject().getLoader().fetchImagePlus(patch[n-1]); imp.getProcessor().setPixels(pixels); patch[n-1].updateInDatabase("tiff_working"); //patch[n-1].getProject().getLoader().vacuum(); }
/** * Assigns a pixel array to the specified slice. * @param pixels The pixel array to be assigned. * @param n The slice index, where 1 <= n <= nslices. */ public void setPixels(Object pixels, int n) { ImageProcessor ip = getProcessor(n); if(ip == null) return; ip.setPixels(pixels); IJ.save(new ImagePlus("", ip), dir + "/" + getFileName(n)); }
public static void flush(ImagePlus imp) { if (null == imp) return; imp.flush(); if (null != imp.getProcessor() && null != imp.getProcessor().getPixels()) { imp.getProcessor().setPixels(null); } }
public static ImagePlus DoubleArrayToStack(double[] image, int width, int height, int nstacks, String name, float min, float max) { ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = (float)image[x + width * (y + slice * height)]; ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
static boolean swapImages(ImagePlus imp1, ImagePlus imp2) { if (imp1.getWidth()!=imp2.getWidth() || imp1.getHeight()!=imp2.getHeight() || imp1.getBitDepth()!=imp2.getBitDepth() || IJ.macroRunning()) return false; ImageProcessor ip1 = imp1.getProcessor(); ImageProcessor ip2 = imp2.getProcessor(); double min1 = ip1.getMin(); double max1 = ip1.getMax(); double min2 = ip2.getMin(); double max2 = ip2.getMax(); ip2.setSnapshotPixels(ip1.getPixels()); ip2.swapPixelArrays(); ip1.setPixels(ip2.getSnapshotPixels()); ip2.setSnapshotPixels(null); ip1.setMinAndMax(min2, max2); ip2.setMinAndMax(min1, max1); return true; }
static boolean swapImages(ImagePlus imp1, ImagePlus imp2) { if (imp1.getWidth()!=imp2.getWidth() || imp1.getHeight()!=imp2.getHeight() || imp1.getBitDepth()!=imp2.getBitDepth() || IJ.macroRunning()) return false; ImageProcessor ip1 = imp1.getProcessor(); ImageProcessor ip2 = imp2.getProcessor(); double min1 = ip1.getMin(); double max1 = ip1.getMax(); double min2 = ip2.getMin(); double max2 = ip2.getMax(); ip2.setSnapshotPixels(ip1.getPixels()); ip2.swapPixelArrays(); ip1.setPixels(ip2.getSnapshotPixels()); ip2.setSnapshotPixels(null); ip1.setMinAndMax(min2, max2); ip2.setMinAndMax(min1, max1); return true; }