Refine search
/** Copies the calibration of the specified image to this image. */ public void copyScale(ImagePlus imp) { if (imp!=null && globalCalibration==null) setCalibration(imp.getCalibration()); }
/** Copies the calibration of the specified image to this image. */ public void copyScale(ImagePlus imp) { if (imp!=null && globalCalibration==null) setCalibration(imp.getCalibration()); }
public ImagePlus radreslice(ImagePlus imp) { ImagePlus imp2; Roi roi = imp.getRoi(); int roiType = roi!=null?roi.getType():0; Calibration origCal = imp.getCalibration(); imp2 = radslice(imp); imp2.setCalibration(imp.getCalibration()); Calibration cal = imp2.getCalibration(); cal.pixelDepth = origCal.pixelHeight; return imp2; }
private static ImagePlus createMaskImage(final VoltexVolume image) { final ImagePlus maskI = IJ.createImage("Mask", "8-bit white", image.xDim, image.yDim, image.zDim); maskI.setCalibration(image.getImagePlus().getCalibration().copy()); return maskI; }
/** 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); }
/** 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 ImagePlus createResult() { ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { stack.addSlice("", new ColorProcessor(w, h, result[z])); } ImagePlus ret = new ImagePlus("Result", stack); ret.setCalibration(image.getCalibration()); return ret; }
public ImagePlus createMeans() { ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { byte[] means = new byte[wh]; for(int i = 0; i < wh; i++) means[i] = (byte)classes[result[z][i]].mean; stack.addSlice("", new ByteProcessor(w, h, means, null)); } ImagePlus ret = new ImagePlus("Result", stack); ret.setCalibration(image.getCalibration()); return ret; }
public static ImagePlus overlayToImagePlus( ImagePlus a, ImagePlus b ) { ImageStack merged = overlayToStack( a, b ); ImagePlus result = new ImagePlus( "Merged", merged ); Calibration ca = a.getCalibration(); Calibration cb = b.getCalibration(); if( ca == null && cb == null ) { // Then that's fine... } else if( ca != null ) { if( ! ca.equals( cb ) ) { IJ.error("The calibrations of the two images differ"); return null; } result.setCalibration( ca ); } else { IJ.error("Calibration is set in one image but not the other."); return null; } return result; }
/** Creates a hyperstack montage and returns it as an ImagePlus. */ private ImagePlus makeHyperstackMontage(ImagePlus imp, int columns, int rows, double scale, int inc, int borderWidth, boolean labels) { ImagePlus[] channels = ChannelSplitter.split(imp); int n = channels.length; ImagePlus[] montages = new ImagePlus[n]; for (int i=0; i<n; i++) { int last = channels[i].getStackSize(); montages[i] = makeMontage2(channels[i], columns, rows, scale, 1, last, inc, borderWidth, labels); } ImagePlus montage = (new RGBStackMerge()).mergeHyperstacks(montages, false); montage.setCalibration(montages[0].getCalibration()); montage.setTitle("Montage"); return montage; }
public void setCalibration(ImagePlus image) { width = image.getWidth(); height = image.getHeight(); ImageStack stack = image.getStack(); depth = (stack==null?1:stack.getSize()); Calibration cal = image.getCalibration(); if(cal == null) { cal = new Calibration(); image.setCalibration(cal); } setCalibration(cal); } public void setCalibration(Calibration cal) {
/** Creates a hyperstack montage and returns it as an ImagePlus. */ private ImagePlus makeHyperstackMontage(ImagePlus imp, int columns, int rows, double scale, int inc, int borderWidth, boolean labels) { ImagePlus[] channels = ChannelSplitter.split(imp); int n = channels.length; ImagePlus[] montages = new ImagePlus[n]; for (int i=0; i<n; i++) { int last = channels[i].getStackSize(); montages[i] = makeMontage2(channels[i], columns, rows, scale, 1, last, inc, borderWidth, labels); } ImagePlus montage = (new RGBStackMerge()).mergeHyperstacks(montages, false); montage.setCalibration(montages[0].getCalibration()); montage.setTitle("Montage"); return montage; }
/** 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 }
/** 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 }
private void setupFFTSave() { Object obj = imp.getProperty("FHT"); if (obj==null) return; FHT fht = (obj instanceof FHT)?(FHT)obj:null; if (fht==null) return; if (fht.originalColorModel!=null && fht.originalBitDepth!=24) fht.setColorModel(fht.originalColorModel); ImagePlus imp2 = new ImagePlus(imp.getTitle(), fht); imp2.setProperty("Info", imp.getProperty("Info")); imp2.setCalibration(imp.getCalibration()); imp = imp2; fi = imp.getFileInfo(); }
/** Converts this ImagePlus to 16-bit grayscale. */ public void convertToGray16() { if (type==ImagePlus.GRAY16) return; if (!(type==ImagePlus.GRAY8||type==ImagePlus.GRAY32||type==ImagePlus.COLOR_RGB)) throw new IllegalArgumentException("Unsupported conversion"); if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray16(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY32) record(); imp.trimProcessor(); imp.setProcessor(null, ip.convertToShort(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration }
public ImagePlus getResultAsByteImage() { ImageStack stack = new ImageStack(w, h); for(int d = 0; d < z; d++) { int[] p = (int[])result.getStack().getPixels(d+1); byte[] b = new byte[w*h]; for(int i = 0; i < b.length; i++) { if(p[i] == -1) b[i] = (byte)255; else b[i] = (byte)p[i]; } stack.addSlice("", new ByteProcessor(w, h, b, null)); } ImagePlus res = new ImagePlus("Classified", stack); res.setCalibration(image.getCalibration()); return res; }
public void init(ImagePlus imp) { this.image = imp; w = imp.getWidth(); h = imp.getHeight(); d = imp.getStackSize(); data = new byte[d][]; for(int z = 0; z < d; z++) data[z] = (byte[])imp.getStack().getPixels(z+1); minima = new byte[d][w * h]; ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { Arrays.fill(minima[z], (byte)UNLABELLED); stack.addSlice("", minima[z]); } result = new ImagePlus("Minima", stack); result.setCalibration(image.getCalibration()); }
/** Converts this ImagePlus to 16-bit grayscale. */ public void convertToGray16() { if (type==ImagePlus.GRAY16) return; if (!(type==ImagePlus.GRAY8||type==ImagePlus.GRAY32||type==ImagePlus.COLOR_RGB)) throw new IllegalArgumentException("Unsupported conversion"); if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray16(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY32) record(); imp.trimProcessor(); imp.setProcessor(null, ip.convertToShort(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration }
private void setupFFTSave() { Object obj = imp.getProperty("FHT"); if (obj==null) return; FHT fht = (obj instanceof FHT)?(FHT)obj:null; if (fht==null) return; if (fht.originalColorModel!=null && fht.originalBitDepth!=24) fht.setColorModel(fht.originalColorModel); ImagePlus imp2 = new ImagePlus(imp.getTitle(), fht); imp2.setProperty("Info", imp.getProperty("Info")); imp2.setCalibration(imp.getCalibration()); imp = imp2; fi = imp.getFileInfo(); }