@Override public void invertLut() { record("invertLut"); proc.invertLut(); }
@Override public void invertLut() { record("invertLut"); proc.invertLut(); }
/** */ public int setup(String arg, ImagePlus imp) { // about... if (arg.equals("about")) { showAbout(); return DONE; } // Called at the end for cleaning up the results if (arg.equals("final")) { // replace the preview image by the original image imagePlus.setProcessor(baseImage); imagePlus.draw(); // as result is binary, choose inverted LUT result.invertLut(); // Create a new ImagePlus with the result String newName = createResultImageName(imagePlus); ImagePlus resPlus = new ImagePlus(newName, result); resPlus.copyScale(imagePlus); resPlus.show(); return DONE; } return flags; }
/** */ public int setup(String arg, ImagePlus imp) { // about... if (arg.equals("about")) { showAbout(); return DONE; } // Called at the end for cleaning the results if (arg.equals("final")) { // replace the preview image by the original image imagePlus.setProcessor(baseImage); imagePlus.draw(); // as result is binary, choose inverted LUT result.invertLut(); // Create a new ImagePlus with the result String newName = createResultImageName(imagePlus); ImagePlus resPlus = new ImagePlus(newName, result); resPlus.copyScale(imagePlus); resPlus.show(); return DONE; } return flags; }
/** Vertical text for y axis label */ void drawYLabel(String yLabel, int xRight, int yFrameTop, int frameHeight, Font scaledFont) { if (ip==null || yLabel.equals("")) return; ip.setFont(scaledFont); FontMetrics fm = ip.getFontMetrics(); int h = fm.getHeight(); //int w = ip.getStringWidth(yLabel) + sc(5); //int h = fm.getHeight()+sc(1); Rectangle rect = ip.getStringBounds(yLabel); ImageProcessor label = new ByteProcessor(rect.x+rect.width, Math.max(h, rect.height)); label.setAntialiasedText(pp.antialiasedText); if (invertedLut) label.invertLut(); label.setColor(Color.white); label.fill(); label.setColor(Color.black); label.setFont(scaledFont); label.drawString(yLabel, 0, Math.max(-rect.y, h)); //can't antialias if x<0 or y<h label = label.rotateLeft(); int y2 = yFrameTop + (frameHeight-label.getHeight())/2; if (y2 < 0) y2 = 0; int x2 = Math.max(xRight-label.getWidth()*4/3, 0); // distance 1/3 height if possible ip.insert(label, x2, y2); }
/** Vertical text for y axis label */ void drawYLabel(String yLabel, int xRight, int yFrameTop, int frameHeight, Font scaledFont) { if (ip==null || yLabel.equals("")) return; ip.setFont(scaledFont); FontMetrics fm = ip.getFontMetrics(); int h = fm.getHeight(); //int w = ip.getStringWidth(yLabel) + sc(5); //int h = fm.getHeight()+sc(1); Rectangle rect = ip.getStringBounds(yLabel); ImageProcessor label = new ByteProcessor(rect.x+rect.width, Math.max(h, rect.height)); label.setAntialiasedText(pp.antialiasedText); if (invertedLut) label.invertLut(); label.setColor(Color.white); label.fill(); label.setColor(Color.black); label.setFont(scaledFont); label.drawString(yLabel, 0, Math.max(-rect.y, h)); //can't antialias if x<0 or y<h label = label.rotateLeft(); int y2 = yFrameTop + (frameHeight-label.getHeight())/2; if (y2 < 0) y2 = 0; int x2 = Math.max(xRight-label.getWidth()*4/3, 0); // distance 1/3 height if possible ip.insert(label, x2, y2); }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
void invertLookupTable() { int nImages = getStackSize(); ip.invertLut(); if (nImages==1) ip.invert(); else { ImageStack stack2 = getStack(); for (int i=1; i<=nImages; i++) stack2.getProcessor(i).invert(); stack2.setColorModel(ip.getColorModel()); } }
strelImage.invertLut();
ip.invertLut(); ImagePlus imp = new ImagePlus(title, ip); if (slices>1) {
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }
private void showOutput() { if (interrupted) return; if (outStack!=null) { outImp = new ImagePlus(TITLE_PREFIX[processType]+imp.getShortTitle(), outStack); int[] d = imp.getDimensions(); outImp.setDimensions(d[2], d[3], d[4]); for (int i=1; i<=imp.getStackSize(); i++) outStack.setSliceLabel(imp.getStack().getSliceLabel(i), i); } if (outImageType != BYTE_OVERWRITE) { ImageProcessor ip = outImp.getProcessor(); if (!Prefs.blackBackground) ip.invertLut(); ip.resetMinAndMax(); outImp.show(); } }
/** * Displays the current structuring element in a new ImagePlus. * @param strel the structuring element to display */ private void showStrelImage(Strel3D strel) { // Size of the strel image (little bit larger than strel) int[] dim = strel.getSize(); int width = dim[0] + 20; int height = dim[1] + 20; // Creates strel image by dilating a point ImageProcessor maskProcessor = new ByteProcessor(width, height); maskProcessor.set(width / 2, height / 2, 255); ImageStack stack = new ImageStack(); stack.addSlice(maskProcessor); stack = Morphology.dilation(stack, strel); maskProcessor = stack.getProcessor(1); // Forces the display to inverted LUT (display a black over white) if (!maskProcessor.isInvertedLut()) maskProcessor.invertLut(); // Display strel image ImagePlus maskImage = new ImagePlus("Element", maskProcessor); maskImage.show(); }
/** * Apply the current filter settings to process the given image. */ public void run(ImageProcessor image) { synchronized (this){ if (floatProcessing) result = processFloat(image, weights.getFloatWeights(), normalize ); else result = processShort(image, weights.getShortWeights(), normalize); } if (previewing) { // Fill up the values of original image with values of the result double valMax = result.getMax(); for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, (int) (255 * result.getf(i) / valMax)); } image.resetMinAndMax(); if (image.isInvertedLut()) image.invertLut(); } }
/** * Apply the current filter settings to process the given image. */ public void run(ImageProcessor image) { if (floatProcessing) { result = processFloat(image, weights.getFloatWeights(), normalize); } else { result = processShort(image, weights.getShortWeights(), normalize); } if (previewing) { // Fill up the values of original image with values of the result double valMax = result.getMax(); for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, (int) (255 * result.getf(i) / valMax)); } image.resetMinAndMax(); if (image.isInvertedLut()) image.invertLut(); } }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }
/** Converts this ImagePlus to 8-bit grayscale. */ public synchronized void convertToGray8() { if (imp.getStackSize()>1) { new StackConverter(imp).convertToGray8(); return; } ImageProcessor ip = imp.getProcessor(); if (type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { imp.setProcessor(null, ip.convertToByte(doScaling)); imp.setCalibration(imp.getCalibration()); //update calibration record(); } else if (type==ImagePlus.COLOR_RGB) imp.setProcessor(null, ip.convertToByte(doScaling)); else if (ip.isPseudoColorLut()) { boolean invertedLut = ip.isInvertedLut(); ip.setColorModel(LookUpTable.createGrayscaleColorModel(invertedLut)); imp.updateAndDraw(); } else { ip = new ColorProcessor(imp.getImage()); imp.setProcessor(null, ip.convertToByte(doScaling)); } ImageProcessor ip2 = imp.getProcessor(); if (Prefs.useInvertingLut && ip2 instanceof ByteProcessor && !ip2.isInvertedLut()&& !ip2.isColorLut()) { ip2.invertLut(); ip2.invert(); } }