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

Method getProcessor

ij/src/main/java/ij/VirtualStack.java:238–321  ·  view source on GitHub ↗

Returns an ImageProcessor for the specified slice, where {@literal 1<=n<=nslices}. Returns null if the stack is empty. When overriding this function, note that the ImageProcessor may be modified at a later time. Its pixel array can get replaced by the pixel array of another slice. This is because th

(int n)

Source from the content-addressed store, hash-verified

236 * {@link <a href="https://wsr.imagej.net/plugins/Test_Virtual_Stack2.java#gemsiv">Example</a>}
237 */
238 public ImageProcessor getProcessor(int n) {
239 if (path==null) { //Help>Examples>JavaScript>Terabyte VirtualStack
240 ImageProcessor ip = null;
241 int w=getWidth(), h=getHeight();
242 switch (bitDepth) {
243 case 8: ip = new ByteProcessor(w,h); break;
244 case 16: ip = new ShortProcessor(w,h); break;
245 case 24: ip = new ColorProcessor(w,h); break;
246 case 32: ip = new FloatProcessor(w,h); break;
247 }
248 String hlabel = null;
249 if (generateData) {
250 int value = 0;
251 ImagePlus img = WindowManager.getCurrentImage();
252 if (img!=null && img.getStackSize()==nSlices)
253 value = img.getCurrentSlice()-1;
254 if (bitDepth==16)
255 value *= 256;
256 if (bitDepth!=32) {
257 for (int i=0; i<ip.getPixelCount(); i++)
258 ip.set(i,value++);
259 }
260 if (img!=null && img.isHyperStack()) {
261 int[] pos = img.convertIndexToPosition(n);
262 hlabel = pos[0]+" "+pos[1]+" "+pos[2]+" "+n;
263 }
264 }
265 label(ip, hlabel!=null?hlabel:""+n, Color.white);
266 if (delay>0)
267 IJ.wait(delay);
268 return ip;
269 }
270 n = translate(n); // update n for hyperstacks not in the default CZT order
271 Opener opener = new Opener();
272 opener.setSilentMode(true);
273 IJ.redirectErrorMessages(true);
274 ImagePlus imp = opener.openTempImage(path, names[n-1]);
275 IJ.redirectErrorMessages(false);
276 ImageProcessor ip = null;
277 int depthThisImage = 0;
278 if (imp!=null) {
279 int w = imp.getWidth();
280 int h = imp.getHeight();
281 int type = imp.getType();
282 ColorModel cm = imp.getProcessor().getColorModel();
283 String info = (String)imp.getProperty("Info");
284 if (info!=null) {
285 if (FolderOpener.useInfo(info))
286 setSliceLabel(info, n);
287 } else {
288 String sliceLabel = imp.getStack().getSliceLabel(1);
289 if (FolderOpener.useInfo(sliceLabel))
290 setSliceLabel("Label: "+sliceLabel, n);
291 }
292 depthThisImage = imp.getBitDepth();
293 ip = imp.getProcessor();
294 ip.setOverlay(imp.getOverlay());
295 properties = imp.getProperty("FHT")!=null?imp.getProperties():null;

Callers 1

getPixelsMethod · 0.95

Calls 15

getHeightMethod · 0.95
getCurrentImageMethod · 0.95
getStackSizeMethod · 0.95
getCurrentSliceMethod · 0.95
getPixelCountMethod · 0.95
setMethod · 0.95
isHyperStackMethod · 0.95
labelMethod · 0.95
waitMethod · 0.95
translateMethod · 0.95
setSilentModeMethod · 0.95

Tested by

no test coverage detected