Java Code Examples for ij.measure.Calibration#copy()
The following examples show how to use
ij.measure.Calibration#copy() .
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: Turn.java From 3Dscript with BSD 2-Clause "Simplified" License | 5 votes |
public static ImagePlus toZY(ImagePlus image) { int w = image.getWidth(); int h = image.getHeight(); int d = image.getNSlices(); ImageProcessor[] slices = new ImageProcessor[d]; for(int z = 0; z < d; z++) { int idx = image.getStackIndex(image.getC(), z + 1, image.getT()); slices[z] = image.getStack().getProcessor(idx); } // x = z, y = y, z = -x int neww = d, newh = h, newd = w; ImageStack stack = new ImageStack(neww, newh); for(int z = 0; z < newd; z++) { int oldX = newd - z - 1; ImageProcessor ip = image.getProcessor().createProcessor(neww, newh); for(int y = 0; y < newh; y++) { int oldY = y; for(int x = 0; x < neww; x++) { int oldZ = x; ip.setf(x, y, slices[oldZ].getf(oldX, oldY)); } } stack.addSlice(ip); } ImagePlus ret = new ImagePlus(image.getTitle(), stack); Calibration cal0 = image.getCalibration(); Calibration cal1 = cal0.copy(); cal1.pixelWidth = cal0.pixelDepth; cal1.pixelHeight = cal0.pixelHeight; cal1.pixelDepth = cal0.pixelWidth; ret.setCalibration(cal1); return ret; }
Example 2
Source File: Turn.java From 3Dscript with BSD 2-Clause "Simplified" License | 5 votes |
public static ImagePlus toXZ(ImagePlus image) { int w = image.getWidth(); int h = image.getHeight(); int d = image.getNSlices(); ImageProcessor[] slices = new ImageProcessor[d]; for(int z = 0; z < d; z++) { int idx = image.getStackIndex(image.getC(), z + 1, image.getT()); slices[z] = image.getStack().getProcessor(idx); } // x = x, y = z, z = -y int neww = w, newh = d, newd = h; ImageStack stack = new ImageStack(neww, newh); for(int z = 0; z < newd; z++) { int oldY = newd - z - 1; ImageProcessor ip = image.getProcessor().createProcessor(neww, newh); for(int y = 0; y < newh; y++) { int oldZ = y; for(int x = 0; x < neww; x++) { int oldX = x; ip.setf(x, y, slices[oldZ].getf(oldX, oldY)); } } stack.addSlice(ip); } ImagePlus ret = new ImagePlus(image.getTitle(), stack); Calibration cal0 = image.getCalibration(); Calibration cal1 = cal0.copy(); cal1.pixelWidth = cal0.pixelWidth; cal1.pixelHeight = cal0.pixelDepth; cal1.pixelDepth = cal0.pixelHeight; ret.setCalibration(cal1); return ret; }
Example 3
Source File: Stitch_Image_Collection.java From Stitching with GNU General Public License v2.0 | 5 votes |
protected static Calibration updateCalibration( Calibration cal, Calibration newOne ) { if ( cal == null ) cal = newOne.copy(); else if ( !cal.equals(newOne) ) { Log.error( "Calibration mismatch: " ); Log.error( " First image: " + cal.toString() ); Log.error( " Current image: " + newOne.toString() ); } return cal; }