本文整理汇总了Java中ij.io.Opener.setSilentMode方法的典型用法代码示例。如果您正苦于以下问题:Java Opener.setSilentMode方法的具体用法?Java Opener.setSilentMode怎么用?Java Opener.setSilentMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.io.Opener
的用法示例。
在下文中一共展示了Opener.setSilentMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import ij.io.Opener; //导入方法依赖的package包/类
/**
* Load image.
*
* @return the image plus
*/
public ImagePlus loadImage()
{
if (!hasImage())
return null;
Opener opener = new Opener();
opener.setSilentMode(true);
// The tifPath may be a system resource or it may be a file
File file = new File(tifPath);
if (file.exists())
{
// Load directly from a file path
return opener.openImage(tifPath);
}
// IJ has support for loading TIFs from an InputStream
Class<ConfigurationTemplate> resourceClass = ConfigurationTemplate.class;
InputStream inputStream = resourceClass.getResourceAsStream(tifPath);
if (inputStream != null)
{
return opener.openTiff(inputStream, Utils.removeExtension(file.getName()));
}
return null;
}
示例2: loadImageProcessor
import ij.io.Opener; //导入方法依赖的package包/类
public static ImageProcessor loadImageProcessor(final String url)
throws IllegalArgumentException {
// openers keep state about the file being opened, so we need to create a new opener for each load
final Opener opener = new Opener();
opener.setSilentMode(true);
final ImagePlus imagePlus = opener.openURL(url);
if (imagePlus == null) {
throw new IllegalArgumentException("failed to create imagePlus instance for '" + url + "'");
}
return imagePlus.getProcessor();
}
示例3: openImage
import ij.io.Opener; //导入方法依赖的package包/类
public static ImagePlus openImage(String directory, String filename)
{
if (filename == null)
return null;
Opener opener = new Opener();
opener.setSilentMode(true);
// TODO - Add support for loading custom channel, slice and frame using a filename suffix, e.g. [cCzZtT]
// If the suffix exists, remove it, load the image then extract the specified slices.
return opener.openImage(directory, filename);
}
示例4: loadImageProcessor
import ij.io.Opener; //导入方法依赖的package包/类
/**
* The core method used to load image processor instances that is called when cache misses occur.
*
* @param url url for the image.
* @param downSampleLevels number of levels to further down sample the image.
* @param isMask indicates whether this image is a mask.
* @param convertTo16Bit indicates whether the loaded image processor should be converted to 16-bit.
*
* @return a newly loaded image processor to be cached.
*
* @throws IllegalArgumentException
* if the image cannot be loaded.
*/
protected ImageProcessor loadImageProcessor(final String url,
final int downSampleLevels,
final boolean isMask,
final boolean convertTo16Bit)
throws IllegalArgumentException {
if (LOG.isDebugEnabled()) {
LOG.debug("loadImageProcessor: entry, url={}, downSampleLevels={}, convertTo16Bit={}", url, downSampleLevels,convertTo16Bit);
}
ImageProcessor imageProcessor = null;
// if we need to down sample, see if source image is already cached before trying to load it
if (downSampleLevels > 0) {
imageProcessor = cache.getIfPresent(new CacheKey(url, 0, isMask,convertTo16Bit));
}
// load the image as needed
if (imageProcessor == null) {
// TODO: use Bio Formats to load strange formats
// openers keep state about the file being opened, so we need to create a new opener for each load
final Opener opener = new S3Opener();
opener.setSilentMode(true);
final ImagePlus imagePlus = opener.openURL(url);
if (imagePlus == null) {
throw new IllegalArgumentException("failed to create imagePlus instance for '" + url + "'");
}
imageProcessor = imagePlus.getProcessor();
// Force images to 16-bit, to allow for testing of mixed 8-bit and 16-bit mipmap levels.
if ((! isMask) && (imageProcessor.getBitDepth() == 8) && convertTo16Bit) {
imageProcessor = imageProcessor.convertToShort(false);
imageProcessor.multiply(256.0);
}
// if we're going to down sample and we're supposed to cache originals, do so here
if (cacheOriginalsForDownSampledImages && (downSampleLevels > 0)) {
if (LOG.isDebugEnabled()) {
LOG.debug("loadImageProcessor: caching level 0 for {}", url);
}
cache.put(new CacheKey(url, 0, isMask,convertTo16Bit), imageProcessor);
}
}
// down sample the image as needed
if (downSampleLevels > 0) {
// NOTE: The down sample methods return a safe copy and leave the source imageProcessor unmodified,
// so we don't need to duplicate a cached source instance before down sampling.
imageProcessor = Downsampler.downsampleImageProcessor(imageProcessor,
downSampleLevels);
}
return imageProcessor;
}