Java Code Examples for ij.process.ImageProcessor#setPixels()
The following examples show how to use
ij.process.ImageProcessor#setPixels() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Stitching_2D.java From Stitching with GNU General Public License v2.0 | 6 votes |
private ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { int width = image.width; int height = image.height; ImagePlus impResult = IJ.createImage(name, "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] = image.get(x, y); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); impResult.updateAndDraw(); return impResult; }
Example 2
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
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); }
Example 3
Source File: Stitching_3D.java From Stitching with GNU General Public License v2.0 | 5 votes |
private ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; 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] = image.get(x, y, slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
Example 4
Source File: InteractiveMorphologicalReconstruction.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Apply the current filter settings to process the given image. */ public void run( ImageProcessor image ) { if( null == image ) return; long t0 = System.currentTimeMillis(); // Compute geodesic reconstruction result = process( image, imagePlus.getRoi() ); if ( null == result ) { // force preview to be unchecked when processing fails gd.getPreviewCheckbox().setState( false ); pfr.dialogItemChanged( gd, new ActionEvent( gd.getPreviewCheckbox(), ActionEvent.ACTION_PERFORMED, "Preview" ) ); return; } if( previewing ) { // Fill up the values of original image with values of the result image.setPixels( result.getPixels() ); image.resetMinAndMax(); if (image.isInvertedLut()) image.invertLut(); } long t1 = System.currentTimeMillis(); IJUtils.showElapsedTime(operation.toString(), t1 - t0, imagePlus); }
Example 5
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public static ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; 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] = image.get(x,y,slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
Example 6
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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); }
Example 7
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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); }
Example 8
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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(); }
Example 9
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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(); }
Example 10
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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(); }
Example 11
Source File: ExportMultilevelTiles.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
/** Will flush the prior_snapshot. */ private final ImageProcessor strategySnapshot( final ImageProcessor prior_snapshot, final List<Patch> patches, final double scale, final int scale_pow) { // Acquire image of whole srcRect final ImageProcessor snapshot; if (null != prior_snapshot) { snapshot = Downsampler.downsampleImageProcessor(prior_snapshot); prior_snapshot.setPixels(null); // flush } else { snapshot = layer.getProject().getLoader().getFlatImage(layer, srcRect, scale, c_alphas, type, Patch.class, patches, false, Color.black).getProcessor(); } // Iterate tiles final Rectangle tile_src = new Rectangle(0, 0, tileSide, tileSide); for (int i = 0, row = 0; i < snapshot.getHeight(); i += tileSide, ++row) { for (int j = 0, col = 0; j < snapshot.getWidth(); j += tileSide, ++col) { final String path = makeTilePath(directory_structure_type, dir, index, row, col, scale_pow); // The srcRect for the tile tile_src.x = tileSide * col; tile_src.y = tileSide * row; snapshot.setRoi(tile_src); ImageProcessor ip = snapshot.crop(); // Adjust dimensions: necessary for croppings over the edges of the snapshot if (ip.getWidth() < tileSide || ip.getHeight() < tileSide) { ImageProcessor ip2 = ip.createProcessor(tileSide, tileSide); ip2.insert(ip, 0, 0); ip.setPixels(null); // flush ip = ip2; ip2 = null; } if (skip_empty_tiles && isEmptyTile(ip)) continue; ImagePlus imp = new ImagePlus(path.substring(path.lastIndexOf("/")), ip); saver.save(imp, path); imp.flush(); ip = null; imp = null; } } return snapshot; }