当前位置: 首页>>代码示例>>Java>>正文


Java FileSaver类代码示例

本文整理汇总了Java中ij.io.FileSaver的典型用法代码示例。如果您正苦于以下问题:Java FileSaver类的具体用法?Java FileSaver怎么用?Java FileSaver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileSaver类属于ij.io包,在下文中一共展示了FileSaver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: act

import ij.io.FileSaver; //导入依赖的package包/类
@Override
public < T extends RealType< T > > void act(
		final int iteration,
		final RandomAccessibleInterval< T > matrix,
		final RandomAccessibleInterval< T > scaledMatrix,
		final double[] lut,
		final int[] permutation,
		final int[] inversePermutation,
		final double[] multipliers,
		final RandomAccessibleInterval< double[] > estimatedFit )
{
	final T dummy = scaledMatrix.randomAccess().get().createVariable();
	dummy.setReal( Double.NaN );
	final String path = fileDir( iteration );
	if ( iteration == 0 )
		createParentDirectory( path );
	final LUTRealTransform tf = new LUTRealTransform( lut, 2, 2 );

	final RealTransformRealRandomAccessible< T, InverseRealTransform > transformed = RealViews.transformReal( Views.interpolate( Views.extendValue( scaledMatrix, dummy ), new NLinearInterpolatorFactory<>() ), tf );
	final double s = 1.0 / ( lut[ lut.length - 1 ] - lut[ 0 ] ) * lut.length;
	final double o = -lut[ 0 ];
	final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation( new double[] { s, s }, new double[] { o, o } );
	final IntervalView< T > offset = Views.interval( Views.raster( RealViews.transformReal( transformed, scaleAndTranslation ) ), scaledMatrix );
	final RandomAccessibleInterval< T > strip = MatrixStripConversion.matrixToStrip( offset, range, dummy );
	new FileSaver( ImageJFunctions.wrap( strip, "" ) ).saveAsTiff( path );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:27,代码来源:MatrixVisitor.java

示例2: saveImage

import ij.io.FileSaver; //导入依赖的package包/类
/**
 * Save the image to a TIFF file
 * 
 * @param imp
 */
private void saveImage(ImagePlus imp)
{
	if (!settings.getSaveImage())
		return;
	String[] path = Utils.decodePath(settings.getImageFilename());
	OpenDialog chooser = new OpenDialog("Image_File", path[0], path[1]);
	if (chooser.getFileName() != null)
	{
		settings.setImageFilename(chooser.getDirectory() + chooser.getFileName());
		settings.setImageFilename(Utils.replaceExtension(settings.getImageFilename(), "tiff"));

		FileSaver fs = new FileSaver(imp);
		boolean ok;
		if (imp.getStackSize() > 1)
			ok = fs.saveAsTiffStack(settings.getImageFilename());
		else
			ok = fs.saveAsTiff(settings.getImageFilename());
		// The following call throws a NoSuchMethodError.
		// ok = IJ.saveAsTiff(imp, settings.imageFilename);

		if (!ok)
			IJ.log("Failed to save image to file: " + settings.getImageFilename());
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:30,代码来源:CreateData.java

示例3: handlePathlessImage

import ij.io.FileSaver; //导入依赖的package包/类
/** Returns the path where the imp is saved to: the storage folder plus a name. */
public String handlePathlessImage(final ImagePlus imp) {
	FileInfo fi = imp.getOriginalFileInfo();
	if (null == fi) fi = imp.getFileInfo();
	if (null == fi.fileName || fi.fileName.equals("")) {
		fi.fileName = "img_" + System.currentTimeMillis() + ".tif";
	}
	if (!fi.fileName.endsWith(".tif")) fi.fileName += ".tif";
	fi.directory = dir_storage;
	if (imp.getNSlices() > 1) {
		new FileSaver(imp).saveAsTiffStack(dir_storage + fi.fileName);
	} else {
		new FileSaver(imp).saveAsTiff(dir_storage + fi.fileName);
	}
	Utils.log2("Saved a copy into the storage folder:\n" + dir_storage + fi.fileName);
	return dir_storage + fi.fileName;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:18,代码来源:FSLoader.java

示例4: saveAsImage

import ij.io.FileSaver; //导入依赖的package包/类
/**
 * Save as image.
 *
 * @param path the path
 * @param name the name
 */
public void saveAsImage(String path, String name){
	FileSaver fs = new FileSaver(img);
	if(name == null) return;
	if(depth > 1)
		fs.saveAsTiffStack(path + "/" + name + ".tiff");
	else
		fs.saveAsTiff(path + "/" + name + ".tiff");
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:15,代码来源:SpatialImage.java

示例5: saveAsTiff

import ij.io.FileSaver; //导入依赖的package包/类
/**
 * Save image to a file using image TIFF encoder.
 *
 * @param imp  image.
 * @param file destination file.
 * @throws IOException when image cannot be saved.
 */
public static void saveAsTiff(final ImagePlus imp, final File file) throws IOException {
    final FileSaver fileSaver = new FileSaver(imp);
    final boolean ok;
    if (imp.getStackSize() > 1) {
        ok = fileSaver.saveAsTiffStack(file.getAbsolutePath());
    } else {
        ok = fileSaver.saveAsTiff(file.getAbsolutePath());
    }
    if (!ok) {
        throw new IOException("Error saving image to file: '" + file.getAbsolutePath() + "'.");
    }
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:20,代码来源:IOUtils.java

示例6: convert

import ij.io.FileSaver; //导入依赖的package包/类
public static void convert(File in, File out, Integer size, String toFormat) throws Throwable {
    ImagePlus img = IJ.openImage(in.getAbsolutePath());
    try {
        int w = img.getWidth();
        int h = img.getHeight();
        double ratio = ((double) w) / ((double) h);
        ImageProcessor ip = img.getProcessor();
        if (size != null && size > 0) {
            if (w >= h) {
                if (w > size) {
                    img.setProcessor(ip.resize(size, (int) (size / ratio), true));
                }
            } else {
                if (h > size) {
                    img.setProcessor(ip.resize((int) (ratio * size), size, true));
                }
            }
        }
        FileSaver fs = new FileSaver(img);
        if ("PNG".equalsIgnoreCase(toFormat)) {
            fs.saveAsPng(out.getAbsolutePath());
        } else if ("JPG".equalsIgnoreCase(toFormat) || "JPEG".equalsIgnoreCase(toFormat)) {
            fs.saveAsJpeg(out.getAbsolutePath());
        } else {
            throw new Exception("Unsupported format: " + toFormat);
        }
    } finally {
        img.close();
    }
}
 
开发者ID:uom-daris,项目名称:daris,代码行数:31,代码来源:SvcArchiveContentImageGet.java

示例7: save

import ij.io.FileSaver; //导入依赖的package包/类
private void save(ImageStack stack, int start)
{
	ImagePlus imp = new ImagePlus("", stack);
	String path = new File(out, String.format("image%06d.tif", start)).getPath();
	FileSaver fs = new FileSaver(imp);
	fs.saveAsTiffStack(path);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:8,代码来源:CMOSAnalysis.java

示例8: save

import ij.io.FileSaver; //导入依赖的package包/类
/**
 * Save the camera model. The model will be named in the resources using the filename without the extension or
 * leading path entries.
 *
 * @param cameraModel
 *            the camera model
 * @param filename
 *            the filename
 * @return true, if successful
 */
public static boolean save(PerPixelCameraModel cameraModel, String filename)
{
	if (cameraModel == null || TextUtils.isNullOrEmpty(filename))
		return false;

	// Try to save to file
	//filename = Utils.replaceExtension(filename, ".tif");
	String name = getName(filename);

	ImageStack stack = new ImageStack(cameraModel.getWidth(), cameraModel.getHeight());
	stack.addSlice("Bias", cameraModel.getBias());
	stack.addSlice("Gain", cameraModel.getGain());
	stack.addSlice("Variance", cameraModel.getVariance());
	ImagePlus imp = new ImagePlus(name, stack);
	imp.setIgnoreGlobalCalibration(true);
	Calibration cal = imp.getCalibration();
	cal.xOrigin = cameraModel.getXOrigin();
	cal.yOrigin = cameraModel.getYOrigin();
	imp.setProperty("Info", INFO_TAG);
	// Do this to allow the filename to be something other than .tif
	boolean ok = new FileSaver(imp).saveAsTiffStack(filename);

	if (ok)
		saveResource(cameraModel, filename, name);

	return ok;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:38,代码来源:CameraModelManager.java

示例9: save

import ij.io.FileSaver; //导入依赖的package包/类
/** Save an image in the format specified by {@param fileType}, which can be any of:
 *  "tif", "tiff", "zip", "gif", "jpg", "jpeg", "bmp", "pgm", "png", "raw".
 *  
 *  When saving as TIFF, if the image has more than 2 dimensions, it will be saved
 *  as a stack. 
 * @throws ImgLibException */
public static<T extends RealType<T> & NativeType<T>> boolean save(final Img<T> image, String fileType, final String path) throws ImgLibException {
	// TODO: use LOCI for this
	final ImagePlus imp = wrap(image);
	final FileSaver saver = new FileSaver(imp);
	fileType = fileType.toLowerCase();
	if (fileType.equals("tif") || fileType.equals("tiff")) {
		if (image.numDimensions() > 2) {
			return saver.saveAsTiffStack(path);
		}
		return saver.saveAsTiff(path);
	} else if (fileType.equals("zip"))
		return saver.saveAsZip(path);
	else if (fileType.equals("gif"))
		return saver.saveAsGif(path);
	else if (fileType.equals("jpg") || fileType.equals("jpeg"))
		return saver.saveAsJpeg(path);
	else if (fileType.equals("bmp"))
		return saver.saveAsBmp(path);
	else if (fileType.equals("pgm"))
		return saver.saveAsPgm(path);
	else if (fileType.equals("png"))
		return saver.saveAsPng(path);
	else if (fileType.equals("raw"))
		return saver.saveAsRaw(path);
	else
		throw new RuntimeException("Unknown fileformat: " + fileType);
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:34,代码来源:ImgLib.java

示例10: saveFile

import ij.io.FileSaver; //导入依赖的package包/类
/**
 *
 * Method which save the image in the directory.
 *
 * @param imagePlusInput Image to be save
 * @param pathFile path of directory
 */
public void saveFile ( ImagePlus imagePlusInput, String pathFile)
{
	FileSaver fileSaver = new FileSaver(imagePlusInput);
    File file = new File(pathFile);
    if (file.exists())
    	fileSaver.saveAsTiffStack( pathFile+File.separator+imagePlusInput.getTitle());
    else
    {
      file.mkdir();
      fileSaver.saveAsTiffStack( pathFile+File.separator+imagePlusInput.getTitle());
    }
}
 
开发者ID:PouletAxel,项目名称:NucleusJ_,代码行数:20,代码来源:RunnableImageSegmentation.java

示例11: saveFile

import ij.io.FileSaver; //导入依赖的package包/类
/**
 * saving file method
 * 
 * @param imagePlus imagePus to save 
 * @param pathFile the path where save the image
 */
public void saveFile ( ImagePlus imagePlus, String pathFile)
{
	FileSaver fileSaver = new FileSaver(imagePlus);
    File file = new File(pathFile);
    if (file.exists())
    	fileSaver.saveAsTiffStack( pathFile+File.separator+imagePlus.getTitle());
    else
    {
    	file.mkdir();
    	fileSaver.saveAsTiffStack( pathFile+File.separator+imagePlus.getTitle());
    }
}
 
开发者ID:PouletAxel,项目名称:NucleusJ_,代码行数:19,代码来源:ChromocenterSegmentationBatchPlugin_.java

示例12: createReviewStack

import ij.io.FileSaver; //导入依赖的package包/类
/** The behavior is undefined if @param last is not a descendant of @param first. */
public void createReviewStack(final Node<T> first, final Node<T> last, final Tag tag, final String filepath, final int width, final int height, final double magnification, final int image_type) {
	try {
		final ImagePlus imp = project.getLoader().createLazyFlyThrough(generateRegions(first, last, width, height, magnification), magnification, image_type, this);
		imp.setTitle(imp.getTitle() + tag.toString());
		ij.IJ.redirectErrorMessages();
		new FileSaver(imp).saveAsZip(filepath);
	} catch (final Exception e) {
		IJError.print(e);
		Utils.log("\nERROR: NOT created review stack for " + tag.toString());
		return;
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:14,代码来源:Tree.java

示例13: exportImage

import ij.io.FileSaver; //导入依赖的package包/类
/** Returns the path to the saved image, or null if not saved. */
public String exportImage(final Patch patch, final ImagePlus imp, final String path, final boolean overwrite) {
	// if !overwrite, save only if not there already
	if (null == path || null == imp || (!overwrite && new File(path).exists())) return null;
	try {
		if (imp.getNSlices() > 1) new FileSaver(imp).saveAsTiffStack(path);
		else new FileSaver(imp).saveAsTiff(path);
	} catch (final Exception e) {
		Utils.log("Could not save an image for Patch #" + patch.getId() + " at: " + path);
		IJError.print(e);
		return null;
	}
	return path;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:15,代码来源:Loader.java

示例14: addNewImage

import ij.io.FileSaver; //导入依赖的package包/类
/** Mipmaps for this image are generated asynchronously. */
public Patch addNewImage(final ImagePlus imp, final double x, final double y) {
	String filename = imp.getTitle();
	if (!filename.toLowerCase().endsWith(".tif")) filename += ".tif";
	final String path = getStorageFolder() + "/" + filename;
	new FileSaver(imp).saveAsTiff(path);
	final Patch pa = new Patch(Project.findProject(this), imp.getTitle(), x, y, imp);
	addedPatchFrom(path, pa);
	if (isMipMapsRegenerationEnabled()) regenerateMipMaps(pa);
	return pa;
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:12,代码来源:Loader.java

示例15: saveStack

import ij.io.FileSaver; //导入依赖的package包/类
@Override
public void saveStack(File file) {
    ImagePlus imp = new ImagePlus("stack", stack);
    FileSaver fs = new FileSaver(imp);
    fs.saveAsTiffStack(file.getAbsolutePath());
}
 
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:7,代码来源:AbstractGenerator.java


注:本文中的ij.io.FileSaver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。