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


Java FormatException类代码示例

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


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

示例1: getRealResolutionCount

import loci.formats.FormatException; //导入依赖的package包/类
@Deprecated
private int getRealResolutionCount(IFormatReader imageReader) throws IOException, FormatException {
    ImageReader ir = new ImageReader();
    ir.setFlattenedResolutions(false);
    ir.setId(imageReader.getCurrentFile());
    ir.setSeries(imageReader.getSeries());
    int numRes = 1;
    for (int lev=imageReader.getResolutionCount()-1; lev>=0; lev--) {
        numRes = lev;
        ir.setResolution(lev);
        int thumbW = ir.getSizeX();
        int thumbH = ir.getSizeY();
        double diff = Math.abs((thumbW/(double)thumbH) - (imageReader.getSizeX()/(double)imageReader.getSizeY()));
        System.out.println("diff: "+diff);
        if (diff<0.001) break;
    }
    ir.close();
    return numRes;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:20,代码来源:OrbitImageBioformats.java

示例2: identify

import loci.formats.FormatException; //导入依赖的package包/类
@Override
public ImageInput identify(ImageInput ii) throws IOException {
    ImageReader reader = new ImageReader();
    try {
        reader.setId(ii.getFile().getAbsolutePath());
    } catch (FormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    int width = reader.getSizeX();
    int height = reader.getSizeY();
    String fmt = reader.getFormat();

    String mt = "";
    if (fmt.equalsIgnoreCase("Tagged Image File Format")) {
        mt = "image/tiff";
    } else if (fmt.equalsIgnoreCase("JPEG")) {
        mt = "image/jpeg";
    }

    logger.debug("BioFormats identify: width=" + width + " height=" + height + " format=" + fmt + " mimetype=" + mt);
    ii.setSize(new ImageSize(width, height));
    ii.setMimetype(mt);
    return ii;
}
 
开发者ID:robcast,项目名称:digilib,代码行数:26,代码来源:BioFormatsDocuImage.java

示例3: openImage

import loci.formats.FormatException; //导入依赖的package包/类
@Override
public BufferedImage openImage(int no, int x, int y, int w, int h) throws FormatException, IOException {
    int[] zct = getZCTCoords(no);
    int z = zct[0];
    int chan = zct[1];
    int t = zct[2];
    RectZT rect = new RectZT(x,y,w,h,z,t);
    if (currentRect==null || !currentRect.equals(rect)) {
        logger.trace("cache failed - loading");
        openUnmixedImages(no,x,y,w,h); // unmix all channels at once
    }
    return unmixedChannels[chan];
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:14,代码来源:MultiplexImageReader.java

示例4: getNumPagesInZVI

import loci.formats.FormatException; //导入依赖的package包/类
public static int getNumPagesInZVI(String filename) throws IOException, FormatException {

        ImageProcessorReader r = new ImageProcessorReader(
                new ChannelSeparator(new ZeissZVIReader())); // LociPrefs.makeImageReader()
        r.setId(filename);
        int num = r.getImageCount();
        //int width = r.getSizeX();
        //int height = r.getSizeY();
        // howto color conversion: http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/loci-plugins/utils/Read_Image.java
        r.close();
        return num;
    }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:13,代码来源:TiffConverter.java

示例5: getNumPagesInLIF

import loci.formats.FormatException; //导入依赖的package包/类
public static int getNumPagesInLIF(String filename) throws IOException, FormatException {

        ImageProcessorReader r = new ImageProcessorReader(
                new ChannelSeparator(new LIFReader()));
        r.setId(filename);
        int num = r.getImageCount();
        r.close();
        return num;
    }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:10,代码来源:TiffConverter.java

示例6: getZVIPage

import loci.formats.FormatException; //导入依赖的package包/类
public static PlanarImage getZVIPage(String filename, int num) throws IOException, FormatException {
    ImageProcessorReader r = new ImageProcessorReader(
            new ChannelSeparator(new ZeissZVIReader())); // LociPrefs.makeImageReader()
    r.setId(filename);
    ImageProcessor ip = r.openProcessors(num)[0]; // (page)[0]
    return PlanarImage.wrapRenderedImage(ip.getBufferedImage());
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:8,代码来源:TiffConverter.java

示例7: getLIFPage

import loci.formats.FormatException; //导入依赖的package包/类
public static PlanarImage getLIFPage(String filename, int num) throws IOException, FormatException {
    ImageProcessorReader r = new ImageProcessorReader(
            new ChannelSeparator(new LIFReader()));
    r.setId(filename);
    ImageProcessor ip = r.openProcessors(num)[0]; // (page)[0]
    return PlanarImage.wrapRenderedImage(ip.getBufferedImage());
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:8,代码来源:TiffConverter.java

示例8: testImageReaderInstantiation

import loci.formats.FormatException; //导入依赖的package包/类
@Test
public void testImageReaderInstantiation()
        throws URISyntaxException, FormatException, IOException {
    URL resource = this.getClass().getClassLoader().getResource(
            "org/cellprofiler/imageset/omexml.xml");
    Path path = Paths.get(resource.toURI());

    ImageReader reader = new ImageReader();
    try {
        reader.setId(path.toString());
        assertEquals(4, reader.getSeriesCount());
    } finally {
        reader.close();
    }
}
 
开发者ID:CellProfiler,项目名称:prokaryote,代码行数:16,代码来源:TestBioFormats.java

示例9: main

import loci.formats.FormatException; //导入依赖的package包/类
public static void main(String... args) throws IOException, FormatException {
	final String bucketName = "dpwr";
	final String key = "s3test/bus.tif";
	final Regions regions = Regions.US_EAST_1;

	final String id = AmazonS3Handle.makeId(bucketName, key, regions);

	final ImagePlus[] imps = BF.openImagePlus(id);
	new ImageJ();
	for (final ImagePlus imp : imps)
		imp.show();
}
 
开发者ID:dpwrussell,项目名称:bfs3,代码行数:13,代码来源:Main.java

示例10: waitForInput

import loci.formats.FormatException; //导入依赖的package包/类
/** Enters an input loop, waiting for commands, until EOF is reached. */
public boolean waitForInput() throws FormatException, IOException {
	in =
		new BufferedReader(new InputStreamReader(System.in, Constants.ENCODING));
	boolean ret = true;
	while (true) {
		final String line = in.readLine(); // blocks until a line is read
		if (line == null) break; // eof
		ret = ret && executeCommand(line);
	}
	in.close();
	return ret;
}
 
开发者ID:scifio,项目名称:scifio-itk-bridge,代码行数:14,代码来源:SCIFIOITKBridge.java

示例11: executeCommand

import loci.formats.FormatException; //导入依赖的package包/类
/**
 * Executes the given command line. The following commands are supported:
 * <ul>
 * <li>info - Dumps image metadata</li>
 * <li>read - Dumps image pixels</li>
 * <li>canRead - Tests whether the given file path can be parsed</li>
 * </ul>
 *
 * @throws FormatException
 */
public boolean executeCommand(final String commandLine) throws IOException,
	FormatException
{
	final String[] args = commandLine.split("\t");

	for (int i = 0; i < args.length; i++) {
		args[i] = args[i].trim();
	}

	return executeCommand(args);
}
 
开发者ID:scifio,项目名称:scifio-itk-bridge,代码行数:22,代码来源:SCIFIOITKBridge.java

示例12: createReader

import loci.formats.FormatException; //导入依赖的package包/类
private IFormatReader createReader(final String filePath)
	throws FormatException, IOException
{
	if (readerPath != null && readerPath.equals(filePath)) {
		// just use the existing reader
		return reader;
	}

	if (reader != null) {
		reader.close();
	}
	System.err.println("Creating new reader for " + filePath);
	// initialize a fresh reader
	final ChannelFiller cf = new ChannelFiller(new ImageReader());
	cf.setFilled(true);
	reader = cf;
	readerPath = filePath;

	reader.setMetadataFiltered(true);
	reader.setOriginalMetadataPopulated(true);
	final MetadataStore store = MetadataTools.createOMEXMLMetadata();
	if (store == null) System.err.println("OME-Java library not found.");
	else reader.setMetadataStore(store);

	// avoid grouping all the .lsm when a .mdb is there
	reader.setGroupFiles(false);

	if (filePath != null) {
		reader.setId(filePath);
		reader.setSeries(0);
	}

	return reader;
}
 
开发者ID:scifio,项目名称:scifio-itk-bridge,代码行数:35,代码来源:SCIFIOITKBridge.java

示例13: openUnmixedImages

import loci.formats.FormatException; //导入依赖的package包/类
public BufferedImage[] openUnmixedImages(int no, int x, int y, int w, int h) throws FormatException, IOException {
    int[] zct = getZCTCoords(no);
    int z = zct[0];
    int chan = zct[1];
    int t = zct[2];
    // load all channels for current rect
    BufferedImage[] channels = new BufferedImage[sizeC];
    for (int c=0; c<sizeC; c++) {
        int no2 = getIndex(z,c,t);
        channels[c] = super.openImage(no2,x,y,w,h);
    }

    BufferedImage ori = channels[0];
    BufferedImage[] bi = new BufferedImage[sizeC];
    WritableRaster[] raster = new WritableRaster[sizeC];
    for (int c=0; c<sizeC; c++) {
        if (!channelIndependent[c]) {
            bi[c] = new BufferedImage(ori.getColorModel(), ori.getRaster().createCompatibleWritableRaster(0, 0, w, h), ori.isAlphaPremultiplied(), null);
            raster[c] = bi[c].getRaster();
        } else {
            bi[c] = channels[c];   // original image, independent channel
            raster[c] = bi[c].getRaster();
        }
    }
    double[] measurements = new double[sizeDependend];
    double[] out = new double[sizeDependend];
    for (int ix=ori.getMinX(); ix<ori.getMinX()+ori.getWidth(); ix++)
        for (int iy=ori.getMinY(); iy<ori.getMinY()+ori.getHeight(); iy++) {
            for (int c=0; c<sizeDependend; c++) {
                measurements[c] = channels[channelMap[c]].getRaster().getSampleDouble(ix,iy,0); // only 1 banded rasters allowed here
            }
            fastMultiply(invMatrix,measurements,out);   // here the real unmixing takes place
            for (int c=0; c<sizeDependend; c++) {
                if (out[c]>255) out[c] = 255d;        // TODO: adjust for 16bit!!!
                if (out[c]<0) out[c] = 0d;
                raster[channelMap[c]].setSample(ix, iy, 0, out[c]);
            }
        }
    unmixedChannels = bi;
    currentRect = new RectZT(x,y,w,h,z,t);

    return bi;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:44,代码来源:MultiplexImageReader.java

示例14: main

import loci.formats.FormatException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, FormatException {
    NDPISReaderOrbit r = new NDPISReaderOrbit();
    r.setId("D:\\pic\\Hamamatsu\\Scan_Manuel\\Staining-DAPI-Cy5.5-FITC-scan all channels fix.ndpis");
    System.out.println(Arrays.toString(getExposureTimesGain(r)));
    r.close();
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:7,代码来源:NDPIUtils.java

示例15: savePixelsTo

import loci.formats.FormatException; //导入依赖的package包/类
private void savePixelsTo(VirtualSlide slide, Path destinationPath, IMetadata metadata, SaveProgressReporter progress) throws IOException, UncheckedInterruptedException
{
	reportTotalBytesToSave(slide, progress);
	
	// TODO Maybe generating resolution pyramid from scratch would be good idea, especially when original image does not have one
	//      or it's too sparse, as in .svs in which shrink factor of each edge is 4 causing a lot more power required to view it than
	//      if it had shrink factor equal to 2.
	//      The downside is that the saving will be probably a lot longer.
	
	// TODO Copying without recompression when the source file and destination has the same tile size and the same compression method
	//      would be A LOT faster.
	//      It would be good especially when saving the file in place to not trigger full, long save when user only changes image name
	//      of file already in OME-TIFF format.
	//      The problem is that Bioformats does not allow to do it directly:
	//      - bypassing compression should be easy - just override IFD.getCompression()
	//      - reading compressed data in raw format is impossible with bioformats for all formats, but for OME-TIFF
	//        using TiffParser.getSample(IFD) and overriding IFD.getCompression() possibly can work
	//        - if not, you can still parse the IFDs with TiffParser and read the data directly
	
	AtomicLong totalBytesWritten = new AtomicLong(0);
	
	try(OMETiffWriter writer = new OMETiffWriter())
	{
  		writer.setBigTiff(true);
      writer.setInterleaved(true);
      writer.setValidBitsPerPixel(8);
      writer.setMetadataRetrieve(metadata);
      writer.setCompression(OMETiffWriter.COMPRESSION_JPEG);
      
		writer.setId(destinationPath.toString());
		
		int seriesIndex = 0;
		for(VirtualSlideImage image : slide.getImageList())
		{
			for(int resIndex = image.getResolutionCount() - 1; resIndex >= 0 ;--resIndex)
			{
				writer.setSeries(seriesIndex);

				for(int c = 0; c < image.getChannelCount() ;++c)
				{
					for(int z = 0; z < image.getZPlaneCount() ;++z)
					{
						for(int t = 0; t < image.getTimePointCount() ;++t)
						{
							saveImagePixels(writer, image, new ImageIndex(resIndex, c, z, t), progress, totalBytesWritten);
						}
					}
				}
     
				seriesIndex++;
			}
		}
	}
	catch(FormatException e)
	{
		throw new IOException(e);
	}
}
 
开发者ID:Strachu,项目名称:VirtualSlideViewer,代码行数:59,代码来源:OmeTiffSavingService.java


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