Java Code Examples for ij.measure.Calibration#setUnit()

The following examples show how to use ij.measure.Calibration#setUnit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderingThread.java    From 3Dscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public RenderingThread(Renderer3D raycaster) {
	this.raycaster = raycaster;
	final ExtendedRenderingState rs = raycaster.getRenderingState();
	rs.setNonChannelProperty(ExtendedRenderingState.TIMEPOINT, raycaster.getImage().getT() - 1);
	this.event = new Event(rs);
	out = new ImagePlus("3D Animation", raycaster.render(rs));
	// TODO
	Calibration cal = out.getCalibration();
	cal.setUnit(raycaster.getImage().getCalibration().getUnit());
	rs.getFwdTransform().adjustOutputCalibration(cal);
	out.show();

	thread = new Thread("3D-Animation rendering thread") {
		@Override
		public void run() {
			loop(rs);
		}
	};
	thread.start();
}
 
Example 2
Source File: AbstractRendering.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
protected AbstractRendering(AbstractBuilder builder) {
    this.xmin = builder.xmin;
    this.xmax = builder.xmax;
    this.ymin = builder.ymin;
    this.ymax = builder.ymax;
    this.resolution = builder.resolution;
    this.imSizeX = builder.imSizeX;
    this.imSizeY = builder.imSizeY;
    this.forceDefaultDX = builder.forceDefaultDX;
    this.forceDefaultDZ = builder.forceDefaultDZ;
    this.defaultDX = builder.defaultDX;
    this.defaultDZ = builder.defaultDZ;
    this.zFrom = builder.zFrom;
    this.zSlices = builder.zSlices;
    this.zStep = builder.zStep;
    this.zTo = builder.zTo;
    this.threeDimensions = builder.threeDimensions;
    this.colorize = builder.colorize;
    this.colorizationLut = builder.colorizationLut;
    slices = new ImageProcessor[zSlices];
    stack = new ImageStack(imSizeX, imSizeY);
    for(int i = 0; i < zSlices; i++) {
        slices[i] = new FloatProcessor(imSizeX, imSizeY);
        stack.addSlice((i * zStep + zFrom) + " to " + ((i + 1) * zStep + zFrom), slices[i]);
    }
    image = new ImagePlus(getRendererName(), stack);
    Calibration calibration = new Calibration();
    double pixelSize = resolution * CameraSetupPlugIn.getPixelSize() / 1000;
    calibration.pixelHeight = pixelSize;
    calibration.pixelWidth = pixelSize;
    if(threeDimensions) {
        calibration.pixelDepth = zStep / 1000;
    }
    calibration.setUnit("um");
    image.setCalibration(calibration);
    if(colorize) {
        image.setDimensions(zSlices, 1, 1);
        CompositeImage image2 = new CompositeImage(image);
        image = image2;
        setupLuts();
    }
}
 
Example 3
Source File: DataGeneratorPlugIn.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
private void runGenerator() throws InterruptedException {
    IJ.showStatus("ThunderSTORM is generating your image sequence...");
    IJ.showProgress(0.0);
    //
    IJGroundTruthTable gt = IJGroundTruthTable.getGroundTruthTable();
    gt.reset();
    ImageStack stack = new ImageStack(width, height);
    //FloatProcessor bkg = new DataGenerator().generateBackground(width, height, drift);
    //
    int numThreads = Math.min(Prefs.getThreads(), frames);
    GeneratorWorker[] generators = new GeneratorWorker[numThreads];
    Thread[] threads = new Thread[numThreads];
    processing_frame = 0;
    // prepare the workers and allocate resources for all the threads
    for(int c = 0, f_start = 0, f_end, f_inc = frames / numThreads; c < numThreads; c++) {
        if((c + 1) < numThreads) {
            f_end = f_start + f_inc - 1;
        } else {
            f_end = frames - 1;
        }
        generators[c] = new GeneratorWorker(f_start, f_end/*, bkg*/);
        threads[c] = new Thread(generators[c]);
        f_start = f_end + 1;
    }
    // start all the workers
    for(int c = 0; c < numThreads; c++) {
        threads[c].start();
    }
    // wait for all the workers to finish
    int wait = 1000 / numThreads;    // max 1s
    boolean finished = false;
    while(!finished) {
        finished = true;
        for(int c = 0; c < numThreads; c++) {
            threads[c].join(wait);
            finished &= !threads[c].isAlive();   // all threads must not be alive to finish!
        }
        if(IJ.escapePressed()) {    // abort?
            // stop the workers
            for(int ci = 0; ci < numThreads; ci++) {
                threads[ci].interrupt();
            }
            // wait so the message below is not overwritten by any of the threads
            for(int ci = 0; ci < numThreads; ci++) {
                threads[ci].join();
            }
            // show info and exit the plugin
            IJ.showProgress(1.0);
            IJ.showStatus("Operation has been aborted by user!");
            return;
        }
    }
    processing_frame = 0;
    gt.setOriginalState();
    for(int c = 0; c < numThreads; c++) {
        generators[c].fillResults(stack, gt);   // and generate stack and table of ground-truth data
    }
    gt.insertIdColumn();
    gt.copyOriginalToActual();
    gt.setActualState();
    gt.convertAllColumnsToAnalogUnits();
    //
    ImagePlus imp = IJ.createImage("Artificial dataset", "16-bit", width, height, frames);
    imp.setStack(stack);
    Calibration cal = new Calibration();
    cal.setUnit("um");
    cal.pixelWidth = cal.pixelHeight = Units.NANOMETER.convertTo(Units.MICROMETER, CameraSetupPlugIn.getPixelSize());
    imp.setCalibration(cal);
    imp.show();
    gt.show();
    //
    IJ.showProgress(1.0);
    IJ.showStatus("ThunderSTORM has finished generating your image sequence.");
}