Sets the 3rd, 4th and 5th dimensions, where nChannels nSlices nFrames must be equal to the stack size.
(int nChannels, int nSlices, int nFrames)
| 1369 | <code>nChannels</code>*<code>nSlices</code>*<code>nFrames</code> |
| 1370 | must be equal to the stack size. */ |
| 1371 | public void setDimensions(int nChannels, int nSlices, int nFrames) { |
| 1372 | //IJ.log("setDimensions: "+nChannels+" "+nSlices+" "+nFrames+" "+getImageStackSize()); |
| 1373 | if (nChannels*nSlices*nFrames!=getImageStackSize() && ip!=null) { |
| 1374 | //throw new IllegalArgumentException("channels*slices*frames!=stackSize"); |
| 1375 | nChannels = 1; |
| 1376 | nSlices = getImageStackSize(); |
| 1377 | nFrames = 1; |
| 1378 | if (isDisplayedHyperStack()) { |
| 1379 | setOpenAsHyperStack(false); |
| 1380 | new StackWindow(this); |
| 1381 | setSlice(1); |
| 1382 | } |
| 1383 | } |
| 1384 | boolean updateWin = isDisplayedHyperStack() && (this.nChannels!=nChannels||this.nSlices!=nSlices||this.nFrames!=nFrames); |
| 1385 | boolean newSingleImage = win!=null && (win instanceof StackWindow) && nChannels==1&&nSlices==1&&nFrames==1; |
| 1386 | if (newSingleImage) updateWin = true; |
| 1387 | this.nChannels = nChannels; |
| 1388 | this.nSlices = nSlices; |
| 1389 | this.nFrames = nFrames; |
| 1390 | if (updateWin) { |
| 1391 | if (nSlices!=getImageStackSize()) |
| 1392 | setOpenAsHyperStack(true); |
| 1393 | ip = null; |
| 1394 | img = null; |
| 1395 | setPositionWithoutUpdate(getChannel(), getSlice(), getFrame()); |
| 1396 | if (isComposite()) ((CompositeImage)this).reset(); |
| 1397 | new StackWindow(this); |
| 1398 | } |
| 1399 | dimensionsSet = true; |
| 1400 | } |
| 1401 | |
| 1402 | /** Returns 'true' if this image has more |
| 1403 | * than three dimensions. |
no test coverage detected