/** * Save the specified sequence in the specified file.<br> * If sequence contains severals images then file is used as a directory<br> * to store all single images. * * @param sequence sequence to save * @param file file where we want to save sequence */ public static void save(Sequence sequence, File file) { save( sequence, file, 0, sequence.getSizeZ() - 1, 0, sequence.getSizeT() - 1, 15, (sequence.getSizeZ() * sequence.getSizeT()) > 1, true); }
/** * Save the specified sequence in the specified file.<br> * When the sequence contains severals image the multiFile flag is used to indicate<br> * if images are saved in severals files (file then specify a directory) or in a single file. * * @param sequence sequence to save * @param file file where we want to save sequence * @param multipleFiles flag to indicate if images are saved in separate file * @param showProgress show progress bar */ public static void save( Sequence sequence, File file, boolean multipleFiles, boolean showProgress) { save( sequence, file, 0, sequence.getSizeZ() - 1, 0, sequence.getSizeT() - 1, 15, multipleFiles, showProgress); }
/** @deprecated Use {@link #save(Sequence, File, boolean, boolean)} instead. */ @Deprecated public static void save(Sequence sequence, File file, boolean multipleFiles) { save( sequence, file, 0, sequence.getSizeZ() - 1, 0, sequence.getSizeT() - 1, 15, multipleFiles, true); }
public void computeData() { computing = true; cancelCompute = false; try { maxData = new double[sequence.getSizeC()]; minData = new double[sequence.getSizeC()]; drawPolygon = new Polygon[sequence.getSizeC()]; if (paintMode == PaintMode.line) { Line2D line = ((ROI2DLine) guideRoi).getLine(); dataCount = (int) line.getP1().distance(line.getP2()); } else { dataCount = sequence.getSizeZ(); } dataArr = new ArrayList<double[]>(); for (int component = 0; component < sequence.getSizeC(); component++) { double[] data = new double[dataCount]; dataArr.add(data); } if (paintMode == PaintMode.line) { Line2D line = ((ROI2DLine) guideRoi).getLine(); dataCount = (int) line.getP1().distance(line.getP2()); ShapeUtil.consumeShapeFromPath( ((ROI2DShape) guideRoi).getPathIterator(null), new ShapeConsumer() { @Override public boolean consume(Shape shape) { if (shape instanceof Line2D) { Line2D line = (Line2D) shape; Point2D Lp; Point2D Rp; if (line.getX2() > line.getX1()) { Lp = line.getP1(); Rp = line.getP2(); } else { Lp = line.getP2(); Rp = line.getP1(); } for (int component = 0; component < sequence.getSizeC(); component++) { // create histo data int distance = dataCount; double vx = (Rp.getX() - Lp.getX()) / distance; double vy = (Rp.getY() - Lp.getY()) / distance; double[] data = dataArr.get(component); double x = Lp.getX(); double y = Lp.getY(); IcyBufferedImage image = canvas.getCurrentImage(); if (image.isInside((int) x, (int) y)) { maxData[component] = Array1DUtil.getValue( image.getDataXY(component), image.getOffset((int) x, (int) y), image.isSignedDataType()); } else { maxData[component] = 0; } minData[component] = maxData[component]; for (int i = 0; i < dataCount; i++) { if (cancelCompute) break; if (image.isInside((int) x, (int) y)) { data[i] = Array1DUtil.getValue( image.getDataXY(component), image.getOffset((int) x, (int) y), image.isSignedDataType()); } else { data[i] = 0; } if (data[i] > maxData[component]) maxData[component] = data[i]; if (data[i] < minData[component]) minData[component] = data[i]; x += vx; y += vy; } Polygon polygon = new Polygon(); polygon.addPoint(0, 0); for (int i = 0; i < dataCount; i++) { polygon.addPoint(i, (int) (data[i] - minData[component])); } polygon.addPoint(dataCount, 0); drawPolygon[component] = polygon; } } return true; // continue } }); } else { for (int component = 0; component < sequence.getSizeC(); component++) { double[] data = dataArr.get(component); if (paintMode == PaintMode.point) { Point p = guideRoi.getPosition(); if (p.x < sequence.getSizeX() && p.y < sequence.getSizeY()) { maxData[component] = sequence.getData(0, 0, component, p.y, p.x); minData[component] = maxData[component]; for (int i = 0; i < dataCount; i++) { if (cancelCompute) break; data[i] = sequence.getData(0, i, component, p.y, p.x); if (data[i] > maxData[component]) maxData[component] = data[i]; if (data[i] < minData[component]) minData[component] = data[i]; } } } else { maxData[component] = ROIUtil.getMeanIntensity(sequence, guideRoi, 0, -1, component); ; minData[component] = maxData[component]; for (int i = 0; i < dataCount; i++) { if (cancelCompute) break; data[i] = ROIUtil.getMeanIntensity(sequence, guideRoi, i, -1, component); if (data[i] > maxData[component]) maxData[component] = data[i]; if (data[i] < minData[component]) minData[component] = data[i]; } } Polygon polygon = new Polygon(); polygon.addPoint(0, 0); for (int i = 0; i < dataCount; i++) // pity polygon does not support this with double... polygon.addPoint(i, (int) (data[i] - minData[component])); polygon.addPoint(dataCount, 0); drawPolygon[component] = polygon; } } } catch (Exception e) { System.out.print(e); } computing = false; }