Java Code Examples for ij.process.ShortProcessor#setMinAndMax()
The following examples show how to use
ij.process.ShortProcessor#setMinAndMax() .
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: LabelImageProcessorCache.java From render with GNU General Public License v2.0 | 5 votes |
/** * @param width image width. * @param height image height. * * @return a 16-bit gray image filled with white pixels. */ public static BufferedImage createEmptyImage(final int width, final int height) { final short[] pixels = new short[width * height]; Arrays.fill(pixels, (short) MAX_LABEL_INTENSITY); final ShortProcessor labelProcessor = new ShortProcessor(width, height, pixels, null); labelProcessor.setMinAndMax(0, MAX_LABEL_INTENSITY); return labelProcessor.getBufferedImage(); }
Example 2
Source File: DistanceTransform5x5Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Computes the distance map of the distance to the nearest pixel with a * different value. The function returns a new short processor the same size * as the input, with values greater or equal to zero. * * @param labelImage * a label image with black pixels (0) as foreground * @return a new instance of ShortProcessor containing: * <ul> * <li>0 for each background pixel</li> * <li>the (strictly positive) distance to the nearest background * pixel otherwise</li> * </ul> */ public ShortProcessor distanceMap(ImageProcessor labelImage) { ShortProcessor distMap = initializeResult(labelImage); // Two iterations are enough to compute distance map to boundary forwardScan(distMap, labelImage); backwardScan(distMap, labelImage); // Normalize values by the first weight if (this.normalizeMap) { normalizeResult(distMap, labelImage); } // Compute max value within the mask for setting min/max of ImageProcessor double maxVal = LabelValues.maxValueWithinLabels(distMap, labelImage); distMap.setMinAndMax(0, maxVal); // Forces the display to non-inverted LUT if (distMap.isInvertedLut()) distMap.invertLut(); this.fireStatusChanged(new AlgoEvent(this, "")); return distMap; }
Example 3
Source File: DistanceTransform3x3Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 5 votes |
/** * Computes the distance map of the distance to the nearest pixel with a different value. * The function returns a new short processor the same size as the input, * with values greater or equal to zero. * * @param labelImage a label image with black pixels (0) as foreground * @return a new instance of ShortProcessor containing: <ul> * <li> 0 for each background pixel </li> * <li> the (strictly positive) distance to the nearest background pixel otherwise</li> * </ul> */ public ShortProcessor distanceMap(ImageProcessor labelImage) { ShortProcessor distMap = initializeResult(labelImage); // Two iterations are enough to compute distance map to boundary forwardScan(distMap, labelImage); backwardScan(distMap, labelImage); // Normalize values by the first weight if (this.normalizeMap) { normalizeResult(distMap, labelImage); } // Compute max value within the mask for setting min/max of ImageProcessor double maxVal = LabelValues.maxValueWithinLabels(distMap, labelImage); distMap.setMinAndMax(0, maxVal); // Forces the display to non-inverted LUT if (distMap.isInvertedLut()) distMap.invertLut(); this.fireStatusChanged(new AlgoEvent(this, "")); return distMap; }
Example 4
Source File: DownsamplerTest.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
final private static void testShort( ShortProcessor ipShort ) { final double min = ipShort.getMin(); final double max = ipShort.getMax(); while( ipShort.getWidth() > 32 ) { ipShort = Downsampler.downsampleShortProcessor( ipShort ); ipShort.setMinAndMax( min, max ); } }
Example 5
Source File: ExportUnsignedShort.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
final static protected ShortProcessor mapIntensities( final PatchIntensityRange pir, final double min, final double max ) { final double a = 65535.0 / ( max - min ); final ImageProcessor source = pir.patch.getImageProcessor(); final short[] targetPixels = new short[ source.getWidth() * source.getHeight() ]; for ( int i = 0; i < targetPixels.length; ++i ) { targetPixels[ i ] = ( short )Math.max( 0, Math.min( 65535, Math.round( ( ( source.getf( i ) - pir.patch.getMin() ) / pir.a - min ) * a ) ) ); } final ShortProcessor target = new ShortProcessor( source.getWidth(), source.getHeight(), targetPixels, null ); target.setMinAndMax( -min * a, ( 1.0 - min ) * a ); return target; }