/** Returns an ImageProcessor for the specified slice, were 1<=n<=nslices. Returns null if the stack is empty. */ public ImageProcessor getProcessor(int n) { byte[] bytes = (byte[])plots.get(n-1); if (bytes!=null) { try { Plot plot = new Plot(null, new ByteArrayInputStream(bytes)); ImageProcessor ip = plot.getProcessor(); if (bitDepth==24) ip = ip.convertToRGB(); else if (bitDepth==8) ip = ip.convertToByte(false); return ip; } catch (Exception e) { IJ.handleException(e); } } return null; }
/** Draws a new plot in this window. */ public void drawPlot(Plot plot) { this.plot = plot; if (imp!=null) { if (ic instanceof PlotCanvas) ((PlotCanvas)ic).setPlot(plot); imp.setProcessor(null, plot.getProcessor()); plot.setImagePlus(imp); //also adjusts the calibration of imp } }
/** Returns an ImageProcessor for the specified slice, were 1<=n<=nslices. Returns null if the stack is empty. */ public ImageProcessor getProcessor(int n) { byte[] bytes = (byte[])plots.get(n-1); if (bytes!=null) { try { Plot plot = new Plot(null, new ByteArrayInputStream(bytes)); ImageProcessor ip = plot.getProcessor(); if (bitDepth==24) ip = ip.convertToRGB(); else if (bitDepth==8) ip = ip.convertToByte(false); return ip; } catch (Exception e) { IJ.handleException(e); } } return null; }
/** Draws a new plot in this window. */ public void drawPlot(Plot plot) { this.plot = plot; if (imp!=null) { if (ic instanceof PlotCanvas) ((PlotCanvas)ic).setPlot(plot); imp.setProcessor(null, plot.getProcessor()); plot.setImagePlus(imp); //also adjusts the calibration of imp } }
plot.setFrameSize(850, 400); plot.setLimits(0, maxX, minT / pi2, maxT / pi2); final ImageProcessor ip = plot.getProcessor(); if (stack == null) stack = new ImageStack(ip.getWidth(), ip.getHeight());
/** Constructs a new plot from an InputStream and closes the stream. If the ImagePlus is * non-null, its title and ImageProcessor are used, but the image displayed is not modified. */ public Plot(ImagePlus imp, InputStream is) throws IOException, ClassNotFoundException { ObjectInputStream in = new ObjectInputStream(is); pp = (PlotProperties)in.readObject(); allPlotObjects = (Vector<PlotObject>)in.readObject(); in.close(); if (pp.xLabel.type==8) { pp.xLabel.updateType(); //convert old (pre-1.52i) type codes for the PlotObjects pp.yLabel.updateType(); pp.frame.updateType(); if (pp.legend != null) pp.legend.updateType(); for (PlotObject plotObject : allPlotObjects) plotObject.updateType(); } defaultMinMax = pp.rangeMinMax; currentFont = nonNullFont(pp.frame.getFont(), currentFont); // best guess in case we want to add a legend getProcessor(); //prepares scale, calibration etc, but does not plot it yet this.title = imp != null ? imp.getTitle() : "Untitled Plot"; if (imp != null) { this.imp = imp; ip = imp.getProcessor(); imp.setIgnoreGlobalCalibration(true); adjustCalibration(imp.getCalibration()); imp.setProperty(PROPERTY_KEY, this); } }
/** Constructs a new plot from an InputStream and closes the stream. If the ImagePlus is * non-null, its title and ImageProcessor are used, but the image displayed is not modified. */ public Plot(ImagePlus imp, InputStream is) throws IOException, ClassNotFoundException { ObjectInputStream in = new ObjectInputStream(is); pp = (PlotProperties)in.readObject(); allPlotObjects = (Vector<PlotObject>)in.readObject(); in.close(); if (pp.xLabel.type==8) { pp.xLabel.updateType(); //convert old (pre-1.52i) type codes for the PlotObjects pp.yLabel.updateType(); pp.frame.updateType(); if (pp.legend != null) pp.legend.updateType(); for (PlotObject plotObject : allPlotObjects) plotObject.updateType(); } defaultMinMax = pp.rangeMinMax; currentFont = nonNullFont(pp.frame.getFont(), currentFont); // best guess in case we want to add a legend getProcessor(); //prepares scale, calibration etc, but does not plot it yet this.title = imp != null ? imp.getTitle() : "Untitled Plot"; if (imp != null) { this.imp = imp; ip = imp.getProcessor(); imp.setIgnoreGlobalCalibration(true); adjustCalibration(imp.getCalibration()); imp.setProperty(PROPERTY_KEY, this); } }
public void run() { while (true) { IJ.wait(50); //delay to make sure the roi has been updated Plot plot = plotMaker!=null?plotMaker.getPlot():null; if (doUpdate && plot!=null && plot.getNumPlotObjects()>0) { plot.useTemplate(this.plot, this.plot.templateFlags); plot.setPlotMaker(plotMaker); this.plot = plot; ((PlotCanvas)ic).setPlot(plot); ImageProcessor ip = plot.getProcessor(); if (ip!=null && imp!=null) { imp.setProcessor(null, ip); plot.setImagePlus(imp); } } synchronized(this) { if (doUpdate) { doUpdate = false; //and loop again } else { try {wait();} //notify wakes up the thread catch(InterruptedException e) { //interrupted tells the thread to exit return; } } } } }
public void run() { while (true) { IJ.wait(50); //delay to make sure the roi has been updated Plot plot = plotMaker!=null?plotMaker.getPlot():null; if (doUpdate && plot!=null && plot.getNumPlotObjects()>0) { plot.useTemplate(this.plot, this.plot.templateFlags); plot.setPlotMaker(plotMaker); this.plot = plot; ((PlotCanvas)ic).setPlot(plot); ImageProcessor ip = plot.getProcessor(); if (ip!=null && imp!=null) { imp.setProcessor(null, ip); plot.setImagePlus(imp); } } synchronized(this) { if (doUpdate) { doUpdate = false; //and loop again } else { try {wait();} //notify wakes up the thread catch(InterruptedException e) { //interrupted tells the thread to exit return; } } } } }
/** Creates a new high-resolution plot by scaling it and displays that plot if showIt is true. * <code>title</code> may be null, then a default title is used. */ public ImagePlus makeHighResolution(String title, float scale, boolean antialiasedText, boolean showIt) { Plot hiresPlot = null; try { hiresPlot = (Plot)clone(); //shallow clone, thus arrays&objects are not cloned } catch (Exception e) {return null;} hiresPlot.ip = null; hiresPlot.imp = null; hiresPlot.pp = pp.clone(); if (!plotDrawn) hiresPlot.getInitialMinAndMax(); hiresPlot.setScale(scale); hiresPlot.setAntialiasedText(antialiasedText); hiresPlot.defaultMinMax = currentMinMax.clone(); ImageProcessor hiresIp = hiresPlot.getProcessor(); if (title == null || title.length() == 0) title = getTitle()+"_HiRes"; title = WindowManager.makeUniqueName(title); ImagePlus hiresImp = new ImagePlus(title, hiresIp); Calibration cal = hiresImp.getCalibration(); hiresPlot.adjustCalibration(cal); if (showIt) { hiresImp.setIgnoreGlobalCalibration(true); hiresImp.show(); } hiresPlot.dispose(); //after drawing, we don't need the plot of the high-resolution image any more return hiresImp; }
plot.addPoints(range(0, median[t].length, pixelSpacing), divide(median[t], pi2), Plot.LINE); final ImageProcessor ip = plot.getProcessor(); if (imageStack == null) imageStack = new ImageStack(ip.getWidth(), ip.getHeight()); imageStack.addSlice("t=" + t, ip);
/** Creates a new high-resolution plot by scaling it and displays that plot if showIt is true. * <code>title</code> may be null, then a default title is used. */ public ImagePlus makeHighResolution(String title, float scale, boolean antialiasedText, boolean showIt) { Plot hiresPlot = null; try { hiresPlot = (Plot)clone(); //shallow clone, thus arrays&objects are not cloned } catch (Exception e) {return null;} hiresPlot.ip = null; hiresPlot.imp = null; hiresPlot.pp = pp.clone(); if (!plotDrawn) hiresPlot.getInitialMinAndMax(); hiresPlot.setScale(scale); hiresPlot.setAntialiasedText(antialiasedText); hiresPlot.defaultMinMax = currentMinMax.clone(); ImageProcessor hiresIp = hiresPlot.getProcessor(); if (title == null || title.length() == 0) title = getTitle()+"_HiRes"; title = WindowManager.makeUniqueName(title); ImagePlus hiresImp = new ImagePlus(title, hiresIp); Calibration cal = hiresImp.getCalibration(); hiresPlot.adjustCalibration(cal); if (showIt) { hiresImp.setIgnoreGlobalCalibration(true); hiresImp.show(); } hiresPlot.dispose(); //after drawing, we don't need the plot of the high-resolution image any more return hiresImp; }
pack(); ImageProcessor ip = plot.getProcessor(); boolean ipIsColor = ip instanceof ColorProcessor; boolean impIsColor = imp.getProcessor() instanceof ColorProcessor;
pack(); ImageProcessor ip = plot.getProcessor(); boolean ipIsColor = ip instanceof ColorProcessor; boolean impIsColor = imp.getProcessor() instanceof ColorProcessor;
Plot plot = new Plot("Slice " + (i + 1), "distance", "intensity", xValues, values); plot.setLimits(xMin, xMax, yMin, yMax); ImageProcessor ip = plot.getProcessor(); if (plots == null) plots = new ImageStack(ip.getWidth(), ip.getHeight());
for (int i=0; i< length; i++) { plot = pPlot[i].getPlot(); stack.addSlice(plot.getProcessor());
for (int i=0; i< length; i++) { plot = pPlot[i].getPlot(); stack.addSlice(plot.getProcessor());