Java Code Examples for ij.process.ImageProcessor#getPixelCount()
The following examples show how to use
ij.process.ImageProcessor#getPixelCount() .
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: 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 2
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 3
Source File: GrayscaleAttributeFilteringPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
private void resetPreview() { ImageProcessor image = this.imagePlus.getProcessor(); if (image instanceof FloatProcessor) { for (int i = 0; i < image.getPixelCount(); i++) image.setf(i, this.baseImage.getf(i)); } else { for (int i = 0; i < image.getPixelCount(); i++) image.set(i, this.baseImage.get(i)); } image.resetMinAndMax(); imagePlus.updateAndDraw(); }
Example 4
Source File: GrayscaleBoxDiameterOpeningPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void run(ImageProcessor image) { BoxDiagonalOpeningQueue algo = new BoxDiagonalOpeningQueue(); DefaultAlgoListener.monitor(algo); this.result = algo.process(image, this.minDiagonalLength); if (previewing) { // Iterate over pixels to change value of reference image for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, result.get(i)); } } }
Example 5
Source File: LabelToRgbPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
private static final int computeMaxLabel(ImageProcessor image) { int labelMax = 0; if (image instanceof FloatProcessor) { for (int i = 0; i < image.getPixelCount(); i++) { labelMax = Math.max(labelMax, (int) image.getf(i)); } } else { for (int i = 0; i < image.getPixelCount(); i++) { labelMax = Math.max(labelMax, image.get(i)); } } return labelMax; }
Example 6
Source File: AreaOpeningPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void run(ImageProcessor image) { if (previewing) { // Iterate over pixels to change value of reference image boolean keepPixel; for (int i = 0; i < image.getPixelCount(); i++) { keepPixel = false; int label = (int) this.labelImage.get(i); if (label > 0) { int index = this.labelMap.get(label); keepPixel = this.pixelCountArray[index] > this.minPixelCount; } image.set(i, keepPixel ? 255 : 0); } } }
Example 7
Source File: DirectionalFilteringPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void run(ImageProcessor image) { IJ.log("Run directional filter"); DirectionalFilter filter = new DirectionalFilter(this.type, this.op, this.lineLength, this.nDirections); DefaultAlgoListener.monitor(filter); this.result = filter.process(image); if (previewing) { // Fill up the values of original image with values of the result for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, result.get(i)); } } }
Example 8
Source File: OctagonStrelTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 6 votes |
/** * Considers the image of a single point, and applies a closing. * One should get the same image back. */ @Test public void testStabilityByClosing() { ImageProcessor image = new ByteProcessor(50, 50); for (int x = 22; x < 27; x++) { for (int y = 22; y < 27; y++) { image.set(x, y, 150); } } image.set(24, 25, 200); image.set(25, 24, 200); image.set(25, 25, 200); int[] radiusList = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 20}; for (int i = 0; i < radiusList.length; i++) { int diam = 2*radiusList[i] + 1; Strel se = new OctagonStrel(diam); ImageProcessor result = se.closing(image); for (int p = 0; p < image.getPixelCount(); p++) { assertEquals(image.get(p), result.get(p)); } } }
Example 9
Source File: LabelImages.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Find largest label (by number of pixels/voxels) in input image * @param imagePlus input image * @return value of the largest label in the input label image */ public final static int findLargestLabel(ImagePlus imagePlus) { int max = 0; for (int i = 1; i <= imagePlus.getImageStackSize(); i++) { ImageProcessor slice = imagePlus.getStack().getProcessor(i); for (int j = 0; j < slice.getPixelCount(); j++) { max = Math.max(max, (int) slice.getf(j)); } } return max; }
Example 10
Source File: GrayscaleAreaOpeningPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run(ImageProcessor image) { this.result = AttributeFiltering.areaOpening(image, this.minPixelCount); if (previewing) { // Iterate over pixels to change value of reference image for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, result.get(i)); } } }
Example 11
Source File: MorphologicalFilterPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run(ImageProcessor image) { // Create structuring element of the given size Strel strel = shape.fromRadius(radius); // add some listeners DefaultAlgoListener.monitor(strel); // Eventually display the structuring element used for processing if (showStrel) { showStrelImage(strel); } // Execute core of the plugin on the original image result = op.apply(this.baseImage, strel); if (!(result instanceof ColorProcessor)) result.setLut(this.baseImage.getLut()); if (previewing) { // Fill up the values of original image with values of the result for (int i = 0; i < image.getPixelCount(); i++) { image.setf(i, result.getf(i)); } image.resetMinAndMax(); } }
Example 12
Source File: MorphologicalFilterPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
private void resetPreview() { ImageProcessor image = this.imagePlus.getProcessor(); if (image instanceof FloatProcessor) { for (int i = 0; i < image.getPixelCount(); i++) image.setf(i, this.baseImage.getf(i)); } else { for (int i = 0; i < image.getPixelCount(); i++) image.set(i, this.baseImage.get(i)); } imagePlus.updateAndDraw(); }
Example 13
Source File: RegionalMinAndMaxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run(ImageProcessor image) { // Create structuring element of the given size // Execute core of the plugin result = op.apply(image, connectivity); if (previewing) { // Fill up the values of original image with inverted values of the // (binary) result double valMax = result.getMax(); for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, 255 - (int) (255 * result.getf(i) / valMax)); } } }
Example 14
Source File: ExtendedMinAndMaxPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void run(ImageProcessor image) { // Create structuring element of the given size // Execute core of the plugin result = op.apply(image, dynamic, connectivity); if (previewing) { // Fill up the values of original image with inverted values of the // (binary) result double valMax = result.getMax(); for (int i = 0; i < image.getPixelCount(); i++) { image.set(i, 255 - (int) (255 * result.getf(i) / valMax)); } } }
Example 15
Source File: OctagonStrelTest.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Considers the image of a single point, and applies a closing. * One should get the same image back. */ @Test public void testStabilityByOpening() { ImageProcessor image = new ByteProcessor(50, 50); image.setValue(255); image.fill(); for (int x = 22; x < 27; x++) { for (int y = 22; y < 27; y++) { image.set(x, y, 100); } } image.set(24, 25, 50); image.set(25, 24, 50); image.set(25, 25, 50); int[] radiusList = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 20}; for (int i = 0; i < radiusList.length; i++) { int diam = 2*radiusList[i] + 1; Strel se = new OctagonStrel(diam); ImageProcessor result = se.opening(image); for (int p = 0; p < image.getPixelCount(); p++) { assertEquals(image.get(p), result.get(p)); } } }
Example 16
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 ); }