MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / setDimensions

Method setDimensions

ij/src/main/java/ij/ImagePlus.java:1371–1400  ·  view source on GitHub ↗

Sets the 3rd, 4th and 5th dimensions, where nChannels nSlices nFrames must be equal to the stack size.

(int nChannels, int nSlices, int nFrames)

Source from the content-addressed store, hash-verified

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.

Callers 15

ImagePlusMethod · 0.95
createHyperStackMethod · 0.95
createImageMethod · 0.95
createHyperStackMethod · 0.95
runMethod · 0.95
mergeHyperstacksMethod · 0.95
duplicateStackMethod · 0.95
zScaleHyperstackMethod · 0.95
openMethod · 0.95
groupZProjectMethod · 0.95
runMethod · 0.95
runMethod · 0.95

Calls 10

getImageStackSizeMethod · 0.95
isDisplayedHyperStackMethod · 0.95
setOpenAsHyperStackMethod · 0.95
setSliceMethod · 0.95
getChannelMethod · 0.95
getSliceMethod · 0.95
getFrameMethod · 0.95
isCompositeMethod · 0.95
resetMethod · 0.65

Tested by

no test coverage detected