public boolean dimensionsIdentical(final ImagePlus a, final ImagePlus b) { return a.getWidth() == b.getWidth() && a.getHeight() == b.getHeight() && a.getStackSize() == b.getStackSize(); }
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]; } }
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); }
/** * Checks if input image is color. * * @param imagePlus * input instance of ImagePlus * @return true if input image contains color processor(s) */ private boolean isColorImage(ImagePlus imagePlus) { if (imagePlus.getStackSize() == 1) { return imagePlus.getProcessor() instanceof ColorProcessor; } else { return imagePlus.getStack().getProcessor(1) instanceof ColorProcessor; } }
/** Converts this ImagePlus to RGB. */ public void convertToRGB() { if (imp.getBitDepth()==24) return; if (imp.getStackSize()>1) { new StackConverter(imp).convertToRGB(); return; } ImageProcessor ip = imp.getProcessor(); imp.setProcessor(null, ip.convertToRGB()); imp.setCalibration(imp.getCalibration()); //update calibration }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (!showDialog(imp)) return; if (imp.getStackSize()==1) Undo.setup(Undo.TYPE_CONVERSION, imp); imp.startTiming(); ImagePlus imp2 = shrink(imp, xshrink, yshrink, zshrink, method); IJ.showTime(imp, imp.getStartTime(), "", imp.getStackSize()); imp.setStack(imp2.getStack()); imp.setCalibration(imp2.getCalibration()); if (zshrink>1) imp.setSlice(1); }
public int setup(String arg, ImagePlus imp) { if (imp!=null) { virtualStack = imp.getStack().isVirtual(); if (virtualStack) useOverlay = true; baseOverlay = imp.getOverlay(); flags += virtualStack?0:DOES_STACKS; firstFrame=1; lastFrame=defaultLastFrame=imp.getStackSize(); } this.imp = imp; return flags; }
public void run(String arg) { OpenDialog od = new OpenDialog("Open Analyze...", arg); String directory = od.getDirectory(); String name = od.getFileName(); if (name==null) return; IJ.showStatus("Opening: " + directory + name); FileInfo fi = load(directory, name); FileOpener fo = new FileOpener(fi); ImagePlus imp = fo.open(false); if (imp==null) return; ImageStack stack = imp.getStack(); for (int i=1; i<=stack.getSize(); i++) { ImageProcessor ip = stack.getProcessor(i); ip.flipVertical(); } if (imp.getStackSize()>1) setStack(name, stack); else setProcessor(name, imp.getProcessor()); setCalibration(imp.getCalibration()); setFileInfo(fi); // needed for revert if (arg.equals("")) show(); }
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
public static final ImagePlus geodesicDistanceMap(ImagePlus markerPlus, ImagePlus maskPlus) { ImagePlus result = null; String newName = markerPlus.getShortTitle() + "-distMap"; if (markerPlus.getStackSize() == 1 && maskPlus.getStackSize() == 1) { ImageProcessor distMap = geodesicDistanceMap(markerPlus.getProcessor(), maskPlus.getProcessor()); result = new ImagePlus(newName, distMap); } result.copyScale(markerPlus); return result; }
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;
private static final int getAutoThreshold(final ImagePlus imp) { final int[] histo = new int[256]; final int d = imp.getStackSize(); for (int z = 0; z < d; z++) { final byte[] p = (byte[]) imp.getStack().getPixels(z + 1); for (int i = 0; i < p.length; i++) { histo[(p[i] & 0xff)]++; } } return imp.getProcessor().getAutoThreshold(histo); }
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"); }
/** Converts this ImagePlus to RGB. */ public void convertToRGB() { if (imp.getBitDepth()==24) return; if (imp.getStackSize()>1) { new StackConverter(imp).convertToRGB(); return; } ImageProcessor ip = imp.getProcessor(); imp.setProcessor(null, ip.convertToRGB()); imp.setCalibration(imp.getCalibration()); //update calibration }
public void run(String arg) { ImagePlus imp = IJ.getImage(); if (!showDialog(imp)) return; if (imp.getStackSize()==1) Undo.setup(Undo.TYPE_CONVERSION, imp); imp.startTiming(); ImagePlus imp2 = shrink(imp, xshrink, yshrink, zshrink, method); IJ.showTime(imp, imp.getStartTime(), "", imp.getStackSize()); imp.setStack(imp2.getStack()); imp.setCalibration(imp2.getCalibration()); if (zshrink>1) imp.setSlice(1); }
private void findLabelledSlices() { //we go through every slice looking for a pixel with the same label //this will fill labelledSlices with the indexes of all labelled slices for (int i = 1; i <= labelsData.getStackSize(); i++) { byte[] pixels = (byte[]) labelsData.getStack().getProcessor(i).getPixels(); for (int j = 0; j < pixels.length; j++) { byte pixel = pixels[j]; if (pixel == label) { labelledSlices.add(i); break; } } } }
/** Constructs an ImagePlus from a TIFF, BMP, DICOM, FITS, PGM, GIF or JPRG specified by a path or from a TIFF, DICOM, GIF or JPEG specified by a URL. */ public ImagePlus(String pathOrURL) { Opener opener = new Opener(); ImagePlus imp = null; boolean isURL = pathOrURL.indexOf("://")>0; if (isURL) imp = opener.openURL(pathOrURL); else imp = opener.openImage(pathOrURL); if (imp!=null) { if (imp.getStackSize()>1) setStack(imp.getTitle(), imp.getStack()); else setProcessor(imp.getTitle(), imp.getProcessor()); setCalibration(imp.getCalibration()); properties = imp.getProperties(); setFileInfo(imp.getOriginalFileInfo()); setDimensions(imp.getNChannels(), imp.getNSlices(), imp.getNFrames()); setOverlay(imp.getOverlay()); setRoi(imp.getRoi()); if (isURL) this.url = pathOrURL; setID(); } }
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); }
/** Converts a Lab stack to RGB. */ public void convertLabToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 32-bit stack required"); ColorSpaceConverter converter = new ColorSpaceConverter(); ImagePlus imp2 = converter.LabToRGB(imp); imp2.setCalibration(imp.getCalibration()); imp.setImage(imp2); }
public void run(String arg) { convertToMask = arg.equals("mask"); if (arg.equals("skip") || convertToMask) showLegacyDialog = false; ImagePlus imp = IJ.getImage(); if (imp.getStackSize()==1) { if (!convertToMask && imp.getProcessor().isBinary()) { setThreshold(imp); return; } Undo.setup(Undo.TRANSFORM, imp); applyThreshold(imp, false); } else convertStack(imp); }