import java.awt.*; import java.awt.event.*; import java.io.*; import ij.*; import ij.io.*; import ij.plugin.PlugIn; //This can open the SOHIAS BIN file. //With the modified HandleExtraFileTypes.java, Drag&Drop can be used to open the file. //This plugin was modified from the plugin (OpenSPE_.java) to open the SPE files. // // Satoshi Matsuyama (Osaka Univ.) // matsuyama@prec.eng.osaka-u.ac.jp public class OpenBIN_ implements PlugIn { public void run(String arg) { OpenDialog od = new OpenDialog("Open BIN...", arg); String file = od.getFileName(); if (file == null) return; String directory = od.getDirectory(); ImagePlus imp = open(directory, file); if (imp != null ) { imp.show(); } else { IJ.showMessage("Open BIN...", "Failed."); } } public static ImagePlus open(String directory, String file) { //データ本体を開く FileInfo fi = new FileInfo(); fi.directory = directory; fi.fileFormat = fi.RAW; fi.fileName = file; fi.fileType = FileInfo.GRAY32_FLOAT; //32ビット(4バイト),Real. fi.gapBetweenImages = 0; fi.height = 891; fi.intelByteOrder = true; //これ大事.最下位の桁から順番に数字が格納されているという意味.img,speともにtrueでOK. fi.nImages = 1; //画像の数,2以上はスタックになると思われる fi.offset = 0; //ヘッダの数,バイト単位.この部分を飛ばしてくれる. fi.width = 2160; FileOpener fo = new FileOpener(fi); ImagePlus imp = fo.open(false); IJ.showStatus(""); return imp; } }