boolean validDialogValues() { Calibration cal = imp.getCalibration(); double pw=cal.pixelWidth, ph=cal.pixelHeight; if (width/pw<1 || height/ph<1) return false; if (xRoi/pw>imp.getWidth() || yRoi/ph>imp.getHeight()) return false; return true; }
public boolean dimensionsIdentical(final ImagePlus a, final ImagePlus b) { return a.getWidth() == b.getWidth() && a.getHeight() == b.getHeight() && a.getStackSize() == b.getStackSize(); }
import io.scif.gui.AWTImageTools; ... final ImagePlus imp = IJ.openImage("http://imagej.net/images/ct.dcm.zip"); // get pixels array reference final short[] pix = (short[]) imp.getProcessor().getPixels(); final int w = imp.getWidth(); final int h = imp.getHeight(); final boolean signed = imp.getCalibration().isSigned16Bit(); if (signed) { // adjust raw pixel values for (int i=0; i<pix.length; i++) { pix[i] -= 32768; } } // convert to BufferedImage final BufferedImage image = AWTImageTools.makeImage(pix, w, h, signed);
protected void setSurfacePlotMaskImage(ImagePlus imp){ widthMaskImage = imp.getWidth(); heightMaskImage = imp.getHeight(); pixelsMaskImage = (byte []) imp.getProcessor().getPixels(); }
public ShortImagePlus( final ImagePlus imp ) { super( imp.getWidth(), imp.getHeight(), imp.getNSlices(), imp.getNFrames(), imp.getNChannels(), 1 ); this.imp = imp; mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new ShortArray( ( short[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); }
public static void duplicateFrames(ImagePlus imp, int slice, int num) { ImageStack stack = imp.getStack(); int w = imp.getWidth(), h = imp.getHeight(); ImageProcessor frame = stack.getProcessor(slice).duplicate(); for(int n = 0; n < num; n++) stack.addSlice("", frame, slice + n); // causes the change from image window to stack window imp.setStack(null, stack); } }
protected ByteImage(final ImagePlus imp) { final ImageStack stack = imp.getStack(); w = imp.getWidth(); final int d = imp.getStackSize(); fData = new byte[d][]; for (int z = 0; z < d; z++) fData[z] = (byte[]) stack.getPixels(z + 1); }
public TestData(ImagePlus imp) { w = imp.getWidth(); h = imp.getHeight(); d = imp.getStackSize(); wh = w * h; re = new float[d][]; im = new float[d][]; for(int z = 0; z < d; z++) { re[z] = (float[])imp.getStack().getPixels(z+1); im[z] = new float[wh]; } }
void packrgb(ImagePlus image){ int len = image.getWidth()*image.getHeight(); ImageProcessor imp = image.getProcessor(); int[] pix = (int[]) imp.getPixels(); pixels = new byte[len*3]; //pack pixels for(int i=0; i<len; i++){ int k=i*3; pixels[k+2] = (byte)((pix[i] & 0xff0000)>>16); //red pixels[k+1] = (byte)((pix[i] & 0x00ff00)>>8); //green pixels[k] = (byte)(pix[i] & 0x0000ff); //blue } }
public ProgressWindow(ImagePlus imp) { super(imp); width = imp.getWidth(); height = imp.getHeight(); depth = imp.getStackSize(); scoreFormatter = new DecimalFormat("0.0000"); distanceFormatter = new DecimalFormat("0.00"); }
public IntImagePlus( final ImagePlus imp ) { super( imp.getWidth(), imp.getHeight(), imp.getNSlices(), imp.getNFrames(), imp.getNChannels(), 1 ); this.imp = imp; mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new IntArray( ( int[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); }
public static void addFrames(ImagePlus imp, int slice, int num) { ImageStack stack = imp.getStack(); int w = imp.getWidth(), h = imp.getHeight(); ImageProcessor frame = stack.getProcessor(slice). createProcessor(w, h); frame.setValue(0); frame.fill(); for(int n = 0; n < num; n++) stack.addSlice("", frame, slice + n); // causes the change from image window to stack window imp.setStack(null, stack); } }
boolean validDialogValues() { Calibration cal = imp.getCalibration(); double pw=cal.pixelWidth, ph=cal.pixelHeight; if (width/pw<1 || height/ph<1) return false; if (xRoi/pw>imp.getWidth() || yRoi/ph>imp.getHeight()) return false; return true; }
protected IntImage(final ImagePlus imp) { final ImageStack stack = imp.getStack(); w = imp.getWidth(); final int d = imp.getStackSize(); fData = new int[d][]; for (int z = 0; z < d; z++) fData[z] = (int[]) stack.getPixels(z + 1); }
public ShellsCanvas(ImagePlus imagePlus, double centre_x, double centre_y, double centre_z) { super(imagePlus); this.imagePlus = imagePlus; this.centre_x = centre_x; this.centre_y = centre_y; this.centre_z = centre_z; System.out.println("Creating canvas with shells centred around: " + centre_x + "," + centre_y + "," + centre_z); radii = new ArrayList<Double>(); Calibration c = imagePlus.getCalibration(); x_spacing = c.pixelWidth; y_spacing = c.pixelHeight; z_spacing = c.pixelDepth; width = imagePlus.getWidth(); height = imagePlus.getHeight(); depth = imagePlus.getStackSize(); } private double x_spacing;
void packrgb(ImagePlus image){ int len = image.getWidth()*image.getHeight(); ImageProcessor imp = image.getProcessor(); int[] pix = (int[]) imp.getPixels(); pixels = new byte[len*3]; //pack pixels for(int i=0; i<len; i++){ int k=i*3; pixels[k+2] = (byte)((pix[i] & 0xff0000)>>16); //red pixels[k+1] = (byte)((pix[i] & 0x00ff00)>>8); //green pixels[k] = (byte)(pix[i] & 0x0000ff); //blue } }
/** Returns the size of this image in bytes. */ public double getSizeInBytes() { double size = ((double)getWidth()*getHeight()*getStackSize()); int type = getType(); switch (type) { case ImagePlus.GRAY16: size *= 2.0; break; case ImagePlus.GRAY32: size *= 4.0; break; case ImagePlus.COLOR_RGB: size *= 4.0; break; } return size; }
public FloatImagePlus( final ImagePlus imp ) { super( imp.getWidth(), imp.getHeight(), imp.getNSlices(), imp.getNFrames(), imp.getNChannels(), 1 ); this.imp = imp; mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new FloatArray( ( float[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); }