Opens all the images in the directory.
(String directory, String[] list, FileInfo fi)
| 128 | |
| 129 | /** Opens all the images in the directory. */ |
| 130 | void openAll(String directory, String[] list, FileInfo fi) { |
| 131 | FolderOpener fo = new FolderOpener(); |
| 132 | list = fo.trimFileList(list); |
| 133 | list = fo.sortFileList(list); |
| 134 | if (list==null) return; |
| 135 | ImageStack stack=null; |
| 136 | ImagePlus imp=null; |
| 137 | double min = Double.MAX_VALUE; |
| 138 | double max = -Double.MAX_VALUE; |
| 139 | int digits = 0; |
| 140 | for (int i=0; i<list.length; i++) { |
| 141 | if (list[i].startsWith(".")) |
| 142 | continue; |
| 143 | fi.fileName = list[i]; |
| 144 | imp = new FileOpener(fi).openImage(); |
| 145 | if (imp==null) |
| 146 | IJ.log(list[i] + ": unable to open"); |
| 147 | else { |
| 148 | if (stack==null) |
| 149 | stack = imp.createEmptyStack(); |
| 150 | try { |
| 151 | ImageStack stack2 = imp.getStack(); |
| 152 | int slices = stack2.getSize(); |
| 153 | if (digits==0) { |
| 154 | digits = 2; |
| 155 | if (slices>99) digits=3; |
| 156 | if (slices>999) digits=4; |
| 157 | if (slices>9999) digits=5; |
| 158 | } |
| 159 | for (int n=1; n<=slices; n++) { |
| 160 | ImageProcessor ip = stack2.getProcessor(n); |
| 161 | if (ip.getMin()<min) |
| 162 | min = ip.getMin(); |
| 163 | if (ip.getMax()>max) |
| 164 | max = ip.getMax(); |
| 165 | String label = list[i]; |
| 166 | if (slices>1) label += "-" + IJ.pad(n,digits); |
| 167 | stack.addSlice(label, ip); |
| 168 | } |
| 169 | } catch(OutOfMemoryError e) { |
| 170 | IJ.outOfMemory("OpenAll"); |
| 171 | stack.trim(); |
| 172 | break; |
| 173 | } |
| 174 | IJ.showStatus((stack.size()+1) + ": " + list[i]); |
| 175 | } |
| 176 | } |
| 177 | String dir = Recorder.fixPath(fi.directory); |
| 178 | Recorder.recordCall(fi.getCode()+"imp = Raw.openAll(\""+ dir+"\", fi);"); |
| 179 | if (stack!=null) { |
| 180 | String title = FolderOpener.trimTitle(directory); |
| 181 | imp = new ImagePlus(title, stack); |
| 182 | if (imp.getBitDepth()==16 || imp.getBitDepth()==32) |
| 183 | imp.getProcessor().setMinAndMax(min, max); |
| 184 | Calibration cal = imp.getCalibration(); |
| 185 | if (fi.fileType==FileInfo.GRAY16_SIGNED) |
| 186 | cal.setSigned16BitCalibration(); |
| 187 | imp.show(); |
no test coverage detected