private static Image5D createImage5D(CMMCore core, String wndTitle) throws Exception { core_ = core; ImageProcessor ip; int type = 0; int width_ = (int) core_.getImageWidth(); int height_ = (int) core_.getImageHeight(); long byteDepth = core_.getBytesPerPixel(); long channels = core_.getNumberOfChannels(); if (byteDepth == 1 && channels == 1) { type = ImagePlus.GRAY8; ip = new ByteProcessor(width_, height_); if (contrastSettings8_.getRange() == 0.0) ip.setMinAndMax(0, 255); else ip.setMinAndMax(contrastSettings8_.min, contrastSettings8_.max); } else if (byteDepth == 2 && channels == 1) { type = ImagePlus.GRAY16; ip = new ShortProcessor(width_, height_); if (contrastSettings16_.getRange() == 0.0) ip.setMinAndMax(0, 65535); else ip.setMinAndMax(contrastSettings16_.min, contrastSettings16_.max); } else if (byteDepth == 0) { throw (new Exception(logError("Imaging device not initialized"))); } else if (byteDepth == 1 && channels == 4) { // assuming RGB32 format ip = new ColorProcessor(width_, height_); if (contrastSettings8_.getRange() == 0.0) ip.setMinAndMax(0, 255); else ip.setMinAndMax(contrastSettings8_.min, contrastSettings8_.max); } else { String message = "Unsupported pixel depth: " + core_.getBytesPerPixel() + " byte(s) and " + channels + " channel(s)."; throw (new Exception(logError(message))); } ip.setColor(Color.black); if (currentColorModel_ != null) ip.setColorModel(currentColorModel_); ip.fill(); Image5D img5d = new Image5D(wndTitle, type, width_, height_, 1, 1, 1, false); @SuppressWarnings("unused") Image5DWindow i5dw = new Image5DWindow(img5d); return img5d; }