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


Java FileOpener类代码示例

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


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

示例1: loadFromRawData

import ij.io.FileOpener; //导入依赖的package包/类
/**
 * Method to load a Grid from raw data.
 * @param fileInfo describes the file format
 * @param filename the file location
 * @return the grid
 */
public static NumericGrid loadFromRawData(FileInfo fileInfo, String filename){
	String sep = System.getProperty("file.separator");
	String [] fileSplit = filename.split("\\"+ sep);
	String file = fileSplit[fileSplit.length-1];
	String path = fileSplit[0];
	for (int i = 1; i < fileSplit.length-1;i++){
		path += sep + fileSplit[i];
	}
	fileInfo.fileName = file;
	fileInfo.directory = path;
	FileOpener fO = new FileOpener(fileInfo);
	ImagePlus image = fO.open(false);
	
	if (!(image.getProcessor() instanceof FloatProcessor)) {
		ImageConverter converter = new ImageConverter(image);
		converter.convertToGray32();
	}
	NumericGrid grid = null;
	if (fileInfo.nImages>1){
		 grid = ImageUtil.wrapImagePlus(image);
	} else {
		grid = ImageUtil.wrapFloatProcessor((FloatProcessor) image.getProcessor());
	}
	return grid;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:32,代码来源:GridRawIOUtil.java

示例2: getAlphaMask

import ij.io.FileOpener; //导入依赖的package包/类
/**
 * Return a new {@link ByteProcessor} representing the alpha mask, if any, over the pixel data.
 * @return null if there isn't one, or if the mask image could not be loaded.*/
public synchronized ByteProcessor getAlphaMask() {
	if (0 == alpha_mask_id) return null;

	final String path = createAlphaMaskFilePath(alpha_mask_id);

	// Expects a zip file containing one single TIFF file entry
	ZipInputStream zis = null;
	try {
		zis = new ZipInputStream(new FileInputStream(path));
		final ZipEntry ze = zis.getNextEntry(); // prepares the entry for reading
		// Assume the first entry is the mask
		final ImageProcessor mask = new FileOpener(new TiffDecoder(zis, ze.getName()).getTiffInfo()[0]).open(false).getProcessor();
		if (mask.getWidth() != o_width || mask.getHeight() != o_height) {
			Utils.log2("Mask has improper dimensions: " + mask.getWidth() + " x " + mask.getHeight() + " for patch #" + this.id + " which is of " + o_width + " x " + o_height);
			return null;
		}
		return (ByteProcessor) (mask.getClass() == ByteProcessor.class ? mask : mask.convertToByte(false));
	} catch (final Throwable t) {
		Utils.log2("Could not load alpha mask for patch #" + this.id + " from file " + path);
		IJError.print(t);
		return null;
	} finally {
		try { if (null != zis) zis.close(); } catch (final Exception e) { IJError.print(e); }
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:29,代码来源:Patch.java

示例3: main

import ij.io.FileOpener; //导入依赖的package包/类
public static void main(String[] args) {
	new ImageJ();
	FileInfo fI = new FileInfo();
	fI.fileFormat = FileInfo.RAW;
	fI.fileType = FileInfo.GRAY16_UNSIGNED;
	fI.height = 256;
	fI.width = 256;
	fI.nImages = 256;
	fI.intelByteOrder = true;
	
	fI.directory = args[0];
	fI.fileName = args[1];		
	
	FileOpener fO = new FileOpener(fI);
			
	Grid3D grid = ImageUtil.wrapImagePlus(fO.open(false));
	
	NumericPointwiseIteratorND pIter = new NumericPointwiseIteratorND(grid);
	while (pIter.hasNext())
	{
		if ( pIter.get() == 0 )
		{
			pIter.getNext();
		} else {
			pIter.setNext(1000+pIter.get());
		}
			
	}
	grid.show("Skull");
   
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:32,代码来源:ReadImageDataFromFileExample.java

示例4: load

import ij.io.FileOpener; //导入依赖的package包/类
public ImagePlus load(String directory, String fileName) {    

		if (!directory.endsWith(File.separator)) directory += File.separator;
		if ((fileName == null) || (fileName == "")) return null;
		
//		imagePath=fi.directory+fi.fileName;
//		headerPath=fi.directory+fi.fileName;
		
		NrrdFileInfo fi;
		try {
			fi=getHeaderInfo(directory, fileName);
		}
		catch (IOException e) { 
			CONRAD.log("readHeader: "+ e.getMessage()); 
			return null;
		}
		if (IJ.debugMode) CONRAD.log("fi:"+fi);
		
		IJ.showStatus("Loading Nrrd File: " + directory + fileName);
		
		ImagePlus imp; FlexibleFileOpener gzfo;
		
		if(fi.encoding.equals("gzip") && detachedHeader) {
			// call my nice gzip opener plugin which has had the 
			// createInputStream method overloaded.
			gzfo = new FlexibleFileOpener(fi,FlexibleFileOpener.GZIP);
			imp = gzfo.open(false);
		} else if(fi.encoding.equals("gzip")) {
			long preOffset=fi.longOffset>0?fi.longOffset:fi.offset;
			fi.offset=0;fi.longOffset=0;
			gzfo= new FlexibleFileOpener(fi,FlexibleFileOpener.GZIP,preOffset);
			if (IJ.debugMode) CONRAD.log("gzfo:"+gzfo);
			imp = gzfo.open(false);			
		} else {
			FileOpener fo = new FileOpener(fi);
			imp = fo.open(false);
		}
		if(imp==null) return null;
		
		// Copy over the spatial scale info which we found in readHeader
		// nb the first we don't just overwrite the current calibration 
		// because this may have density calibration for signed images 
		Calibration cal = imp.getCalibration();
		Calibration spatialCal = this.getCalibration();
		cal.pixelWidth=spatialCal.pixelWidth;
		cal.pixelHeight=spatialCal.pixelHeight;        
		cal.pixelDepth=spatialCal.pixelDepth;
		cal.setUnit(spatialCal.getUnit());
		cal.xOrigin=spatialCal.xOrigin;		
		cal.yOrigin=spatialCal.yOrigin;		
		cal.zOrigin=spatialCal.zOrigin;
		imp.setCalibration(cal);		

		return imp; 
	}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:56,代码来源:NrrdFileReader.java

示例5: openImage

import ij.io.FileOpener; //导入依赖的package包/类
public ImagePlus openImage(File file, FileInfo fi){
	fi.directory = file.getParent();
	fi.fileName = file.getName();
	FileOpener open = new FileOpener(fi);
	return open.open(false);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:7,代码来源:RawDataOpener.java


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