本文整理汇总了Java中ij.io.Opener类的典型用法代码示例。如果您正苦于以下问题:Java Opener类的具体用法?Java Opener怎么用?Java Opener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Opener类属于ij.io包,在下文中一共展示了Opener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpBeforeClass
import ij.io.Opener; //导入依赖的package包/类
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
final File testDir = new File(testDirPath);
testDir.mkdirs();
if (!(testDir.exists() && testDir.isDirectory()))
throw new IOException("Could not create benchmark directory for HDF5Utils benchmark.");
data = new short[64 * 64 * 64];
final ImagePlus imp = new Opener().openURL("https://imagej.nih.gov/ij/images/t1-head-raw.zip");
final ImagePlusImg<UnsignedShortType, ?> img = (ImagePlusImg<UnsignedShortType, ?>)(Object)ImagePlusImgs.from(imp);
final Cursor<UnsignedShortType> cursor = Views.flatIterable(Views.interval(img, new long[]{100, 100, 30}, new long[]{163, 163, 93})).cursor();
for (int i = 0; i < data.length; ++i)
data[i] = (short)cursor.next().get();
n5 = new N5FSWriter(testDirPath);
}
示例2: main
import ij.io.Opener; //导入依赖的package包/类
/** Main methods for test runs from comamnd line. */
public static void main( String [] args ) throws Exception {
if (args.length != 1) {
System.out.println("Provide a TIFF file");
System.exit(-1);
}
// open a tiff stack
InputStream img = new FileInputStream(args[0]);
Opener op = new Opener();
ImagePlus ip = op.openTiff( img, args[0] );
if (ip == null) {
System.out.println("Failed to open: "+args[0]);
System.exit(-1);
}
ip.show();
// run an ESI analysis on it
ESI_Analysis es = new ESI_Analysis();
//TraceStack ptr = new TraceStack( ip.getStack());
es.run("");
}
示例3: extractSinogram
import ij.io.Opener; //导入依赖的package包/类
static Grid2D extractSinogram(String filename, Trajectory traj, boolean showData, String name)
{
Opener op = new Opener();
Grid3D projData = ImageUtil.wrapImagePlus(op.openZip(filename));
if (showData)
projData.show(name);
// extract sinogram out of cone beam projection data (central detector line in v direction)
Grid2D Sinogram = new Grid2D(projData.getSize()[0], projData.getSize()[2]);
for (int i=0; i < projData.getSize()[2]; ++i)
{
NumericPointwiseOperators.copy(Sinogram.getSubGrid(i),
projData.getSubGrid(i).getSubGrid(traj.getDetectorHeight()/2));
}
Sinogram.setSpacing(traj.getPixelDimensionX(), traj.getAverageAngularIncrement());
return Sinogram;
}
示例4: isTiffSeries
import ij.io.Opener; //导入依赖的package包/类
private boolean isTiffSeries(String[] filenames)
{
// Create this as it is needed for XStream serialisation
images = new ArrayList<String>();
for (int i = 0; i < filenames.length; i++)
{
int fileType = getFileType(filenames[i]);
if (fileType != Opener.TIFF)
// Only support TIFF images
return false;
}
// All images are TIFF so store the filenames
for (int i = 0; i < filenames.length; i++)
{
images.add(filenames[i]);
}
return true;
}
示例5: loadImage
import ij.io.Opener; //导入依赖的package包/类
public static ImagePlus loadImage(String directory, String file, int seriesNumber, String rgb)
{
ImagePlus imp = null;
String smallFile = file.toLowerCase();
if (smallFile.endsWith("tif") || smallFile.endsWith("tiff") || smallFile.endsWith("jpg") || smallFile.endsWith("png") || smallFile.endsWith("bmp") ||
smallFile.endsWith("gif") || smallFile.endsWith("jpeg"))
{
imp = new Opener().openImage((new File(directory, file)).getPath());
}
else
{
imp = openLOCIImagePlus(directory, file, seriesNumber, rgb);
if (imp == null)
imp = new Opener().openImage((new File(directory, file)).getPath());
}
return imp;
}
示例6: getImageForPath
import ij.io.Opener; //导入依赖的package包/类
private static ImagePlus getImageForPath(String absolutePathName, int frameNo) {
try {
absolutePathName = S.fixPath(absolutePathName);
log.debug("getImageForPath: loading " + absolutePathName);
ImagePlus ip = (new Opener()).openImage(absolutePathName);
ip.setTitle("Frame:" + frameNo);
//return new ImagePlus(, ImageIO.read(new File(absolutePathName)));
return ip;
} catch (Exception e) {
log.error("getImageForPath absolutePathName = " + absolutePathName, e);
e.printStackTrace();
}
return null;
}
示例7: CrossCorrelation2D
import ij.io.Opener; //导入依赖的package包/类
public CrossCorrelation2D(String image1, String image2, boolean showImages)
{
// load images
ImagePlus img1 = new Opener().openImage(image1);
ImagePlus img2 = new Opener().openImage(image2);
if (showImages)
{
img1.show();
img2.show();
}
ImageProcessor ip1 = img1.getProcessor();
ImageProcessor ip2 = img2.getProcessor();
this.img1 = ImageToFloatArray2D(ip1);
this.img2 = ImageToFloatArray2D(ip2);
this.showImages = showImages;
//computeCrossCorrelation(ImageToFloatArray2D(ip1), ImageToFloatArray2D(ip2), showImages);
}
示例8: loadFile
import ij.io.Opener; //导入依赖的package包/类
/**
* Load the selected tif stack
* @param file tif stack file
*/
private void loadFile(File file) {
Opener o = new Opener();
ImagePlus win = o.openTiff(file.getParent().concat(File.separator),file.getName());
ImageStack stack = win.getImageStack();
ImageProcessor ip = stack.getProcessor(1);
FloatProcessor fp = ip.convertToFloatProcessor();
this.pixels = fp.getFloatArray();
}
示例9: loadFile
import ij.io.Opener; //导入依赖的package包/类
/**
* Load selected tif stack
* @param file tif stack file
*/
private void loadFile(File file) {
Opener o = new Opener();
ImagePlus win = o.openTiff(file.getParent().concat(File.separator),file.getName());
ImageStack stack = win.getImageStack();
ImageProcessor ip = stack.getProcessor(1);
FloatProcessor fp = ip.convertToFloatProcessor();
pixels = fp.getFloatArray();
}
示例10: loadGeneralTiff
import ij.io.Opener; //导入依赖的package包/类
/**
* Loads a tiff stack from a file on disk into RAM
* @param file tiff file to be loaded
* @return loaded image stack
*/
public final ImageStack loadGeneralTiff(File file) {
// Open the tiff via ImageJ
Logger.getLogger(TiffParser.class.getName()).log(Level.INFO, "Trying to open general tiff.");
Opener o = new Opener();
ImagePlus win = o.openTiff(file.getParent().concat("\\"),file.getName());
ImageStack stack = win.getImageStack();
// load dimensions and check bit depth
int width = stack.getWidth();
int height = stack.getHeight();
int bytesPerPixel;
if(stack.getPixels(win.getSlice()) instanceof short[]) {
Logger.getLogger(TiffParser.class.getName()).log(Level.INFO, "Array is instance of short[]");
bytesPerPixel = 2;
} else {
throw new ArrayStoreException("Wrong image bit depth.");
}
// initialize ImageStack in RAM
ram_stack = new ImageStack(width, height);
// load slices into new stack
for (int i=1; i<=stack.getSize(); i++) {
ram_stack.addSlice(String.valueOf(i), stack.getPixels(i));
// Log the process
if (i%100==0) {
System.out.format("Loaded %d images from general tiff stack.\n",i);
}
}
return ram_stack;
}
示例11: openImage
import ij.io.Opener; //导入依赖的package包/类
/**
* Open an image using ImageJ image reader.
*
* @param file image file.
* @return read image
* @throws IOException when image cannot be open.
*/
public static ImagePlus openImage(final File file) throws IOException {
if (!file.exists()) {
throw new IOException("Image does not exist: '" + file.getAbsolutePath() + "'.");
}
final Opener opener = new Opener();
final ImagePlus imp = opener.openImage(file.getAbsolutePath());
if (imp == null) {
throw new IOException("Cannot open image: '" + file.getAbsolutePath() + "'.");
}
return imp;
}
示例12: open
import ij.io.Opener; //导入依赖的package包/类
/** Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut,
roi, or text file. Displays an error message if the specified file
is not in one of the supported formats, or if it is not found.
With 1.41k or later, opens images specified by a URL.
*/
public static void open(String path) {
if (ij==null && Menus.getCommands()==null) init();
Opener o = new Opener();
macroRunning = true;
if (path==null || path.equals(""))
o.open();
else
o.open(path);
macroRunning = false;
}
示例13: open
import ij.io.Opener; //导入依赖的package包/类
private synchronized void open(){
Opener opener = new Opener();
operand = opener.openImage(operandFileName);
if (operand == null){
RawDataOpener raw = RawDataOpener.getRawDataOpener();
operand = raw.openImage(new File(operandFileName), raw.getFileInfo());
}
configured = true;
}
示例14: main
import ij.io.Opener; //导入依赖的package包/类
public static void main(String[] args) {
CONRAD.setup();
Opener op = new Opener();
ImagePlus ip = op.openImage("C:\\Users\\Martin\\Documents\\MATLAB\\FastRadialSymmetry_PointPicker\\bla.tif");
ip.show();
FastRadialSymmetryTool frst = new FastRadialSymmetryTool();
frst.setRadii(new double[]{3});
frst.setAlpha(3);
frst.setSmallGradientThreshold(0.02);
frst.setConfigured(true);
frst.setImageIndex(0);
frst.applyToolToImage(ImageUtil.wrapImageProcessor(ip.getStack().getProcessor(1))).show();
}
示例15: 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;
}