volume = null;
if (datawriter != null)
datawriter.destroy();
initIdList();
disableMenus();
SliceReader sr = new SliceReader(fileName, width, height, depth, 0);
if (getPreferences().getInt("use_cached_access", 0) == 0) {
datawriter = new HeapReader(width, height, depth);
volume = new Stack(datawriter);
} else {
volume = new Stack(width, height, depth, getPreferences().getString("tempFileName", "temp.raw"));
datawriter = volume.getWriter();
}
iw.setReader(datawriter);
depthSlider.setMaximum(depth - 1);
progressbar.setMaximum(depth - 1);
RandomAccessFile ra = sr.getFile();
totalCount = 0;
for (int i = 0; i < depth; i++) {
if (isStopped)
return;
if (inputType == BYTE_TYPE) {
short[] data = new short[width * height];
byte[] ba = new byte[data.length];
try {
ra.readFully(ba);
} catch (IOException e) {
//ignore
}
for (int j = 0; j < data.length; j++) {
data[j] = (short) (ba[j] & 0xff);
}
datawriter.putSlice(data, i);
} else if (inputType == SHORT_TYPE) {
short[] slice = sr.getSlice((i));
for (short aSlice : slice) {
if (aSlice != 0 && aSlice > 255) {
removeFiberId(aSlice);
}
}
datawriter.putSlice(slice, i);
}
setProgress(i);
}
setLabel("Found " + totalCount + " regions.");
sr.close();
depthSlider.setValue(0);
updateImage();
tracker.reset();
enableMenus();
}