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(); }
int c1 = imp.getChannel(); int t1 = imp.getFrame(); int width = imp.getWidth(); int height = imp.getHeight(); ImagePlus imp2 = null; ImageStack stack2 = null; for (int t=1; t<=frames; t++) { imp.setPositionWithoutUpdate(c, z, t); tmp1Stack.addSlice(null, imp.getProcessor()); tmp1.setCalibration(imp.getCalibration()); tmp1.setRoi(roi); ImagePlus tmp2 = reslice(tmp1); int frames2 = tmp2.getStackSize(); if (imp2==null) { imp2 = tmp2.createHyperStack("Reslice of "+imp.getTitle(), channels, 1, frames2, tmp2.getBitDepth()); stack2 = imp2.getStack(); ImageStack tmp2Stack = tmp2.getStack(); for (int t=1; t<=frames2; t++) { imp.setPositionWithoutUpdate(c, z, t);
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); } }
/** * Instructs the Sholl Analysis plugin to analyze the profile sampled by * . */ public void analyzeWithShollAnalysisPlugin(final String exportDir, final double primaryBranches) { final Sholl_Analysis sa = new Sholl_Analysis(); sa.setDescription("Tracings for " + originalImage.getTitle(), false); final Calibration cal = originalImage.getCalibration(); if (cal != null) { final int pX = (int) cal.getRawX(x_start); final int pY = (int) cal.getRawY(y_start, originalImage.getHeight()); final int pZ = (int) (z_start / cal.pixelDepth + cal.zOrigin); sa.setCenter(pX, pY, pZ); sa.setUnit(cal.getUnit()); } sa.setStepRadius(sphereSeparation); sa.setPrimaryBranches(primaryBranches); sa.setExportPath(exportDir); sa.analyzeProfile(sampled_distances, sampled_counts, !twoDimensional); }
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; }
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() ) ); }