Java Code Examples for ij.process.ImageProcessor#isInvertedLut()
The following examples show how to use
ij.process.ImageProcessor#isInvertedLut() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BinaryOrbit.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public void run (ImageProcessor ip) { int fg = Prefs.blackBackground ? 255 : 0; foreground = ip.isInvertedLut() ? 255-fg : fg; background = 255 - foreground; ip.setSnapshotCopyMode(true); if (arg.equals("outline")) outline(ip); else if (arg.startsWith("fill")) fill(ip, foreground, background); else if (arg.startsWith("skel")) { ip.resetRoi(); skeletonize(ip); } else if (arg.equals("erode") || arg.equals("dilate")) doIterations(ip, arg); else if (arg.equals("open")) { doIterations(ip, "erode"); doIterations(ip, "dilate"); } else if (arg.equals("close")) { doIterations(ip, "dilate"); doIterations(ip, "erode"); } ip.setSnapshotCopyMode(false); ip.setBinaryThreshold(); }
Example 2
Source File: DistanceTransformWatershed.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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(); } }
Example 3
Source File: ChamferDistanceMapPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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(); } }
Example 4
Source File: MorphologicalFilterCross3DPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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(); }
Example 5
Source File: RankFiltersOrbit.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
/** Filters an image by any method except 'despecle' (for 'despeckle', use 'median' and radius=1) * @param ip The image subject to filtering * @param radius The kernel radius * @param filterType as defined above; DESPECKLE is not a valid type here; use median and * a radius of 1.0 instead * @param whichOutliers BRIGHT_OUTLIERS or DARK_OUTLIERS for 'outliers' filter * @param threshold Threshold for 'outliers' filter */ public void rank(ImageProcessor ip, double radius, int filterType, int whichOutliers, float threshold) { Rectangle roi = ip.getRoi(); ImageProcessor mask = ip.getMask(); Rectangle roi1 = null; int[] lineRadii = makeLineRadii(radius); float minMaxOutliersSign = filterType==MIN ? -1f : 1f; if (filterType == OUTLIERS) //sign is -1 for high outliers: compare number with minimum minMaxOutliersSign = (ip.isInvertedLut()==(whichOutliers==DARK_OUTLIERS)) ? -1f : 1f; boolean isImagePart = (roi.width<ip.getWidth()) || (roi.height<ip.getHeight()); boolean[] aborted = new boolean[1]; // returns whether interrupted during preview or ESC pressed for (int ch=0; ch<ip.getNChannels(); ch++) { int filterType1 = filterType; if (isMultiStepFilter(filterType)) { filterType1 = (filterType==OPEN) ? MIN : MAX; if (isImagePart) { //composite filters ('open maxima' etc.) need larger area in first step int kRadius = kRadius(lineRadii); int kHeight = kHeight(lineRadii); Rectangle roiClone = (Rectangle)roi.clone(); roiClone.grow(kRadius, kHeight/2); roi1 = roiClone.intersection(new Rectangle(ip.getWidth(), ip.getHeight())); ip.setRoi(roi1); } } doFiltering(ip, lineRadii, filterType1, minMaxOutliersSign, threshold, ch, aborted); if (aborted[0]) break; if (isMultiStepFilter(filterType)) { ip.setRoi(roi); ip.setMask(mask); int filterType2 = (filterType==OPEN) ? MAX : MIN; doFiltering(ip, lineRadii, filterType2, minMaxOutliersSign, threshold, ch, aborted); if (aborted[0]) break; if (isImagePart) resetRoiBoundary(ip, roi, roi1); } } }
Example 6
Source File: MorphologicalFilterPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Displays the current structuring element in a new ImagePlus. * @param strel the structuring element to display */ private void showStrelImage(Strel 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 strelImage = new ByteProcessor(width, height); strelImage.set(width / 2, height / 2, 255); strelImage = Morphology.dilation(strelImage, strel); // Forces the display to inverted LUT (display a black over white) if (!strelImage.isInvertedLut()) strelImage.invertLut(); // Display strel image if (strelDisplay == null) { strelDisplay = new ImagePlus("Structuring Element", strelImage); } else { strelDisplay.setProcessor(strelImage); } strelDisplay.show(); }
Example 7
Source File: InteractiveMorphologicalReconstruction.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Apply the current filter settings to process the given image. */ public void run( ImageProcessor image ) { if( null == image ) return; long t0 = System.currentTimeMillis(); // Compute geodesic reconstruction result = process( image, imagePlus.getRoi() ); if ( null == result ) { // force preview to be unchecked when processing fails gd.getPreviewCheckbox().setState( false ); pfr.dialogItemChanged( gd, new ActionEvent( gd.getPreviewCheckbox(), ActionEvent.ACTION_PERFORMED, "Preview" ) ); return; } if( previewing ) { // Fill up the values of original image with values of the result image.setPixels( result.getPixels() ); image.resetMinAndMax(); if (image.isInvertedLut()) image.invertLut(); } long t1 = System.currentTimeMillis(); IJUtils.showElapsedTime(operation.toString(), t1 - t0, imagePlus); }
Example 8
Source File: InteractiveGeodesicDistanceMap.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Apply the current filter settings to process the given image. */ public void run( ImageProcessor image ) { if( null == image ) return; long t0 = System.currentTimeMillis(); // Execute core of the plugin if (resultAsFloat) result = process( image, imagePlus.getRoi(), weights.getFloatWeights(), normalize ); else result = process( image, imagePlus.getRoi(), weights.getShortWeights(), normalize ); if ( null == result ) { // force preview to be unchecked when processing fails gd.getPreviewCheckbox().setState( false ); pfr.dialogItemChanged( gd, new ActionEvent( gd.getPreviewCheckbox(), ActionEvent.ACTION_PERFORMED, "Preview" ) ); return; } if( previewing ) { // Fill up the values of original image with values of the result double valMax = result.getMax(); // values need to be adjusted to the input image type for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, (int) (255 * result.getf(i) / valMax)); } // Copy LUT image.setLut( result.getLut() ); image.resetMinAndMax(); if (image.isInvertedLut()) image.invertLut(); } long t1 = System.currentTimeMillis(); IJUtils.showElapsedTime( "Interactive Geodesic Distance Map", t1 - t0, imagePlus ); }