Java Code Examples for ij.process.ImageProcessor#getMax()
The following examples show how to use
ij.process.ImageProcessor#getMax() .
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: Patch.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
/** Update type, original dimensions and min,max from the given ImagePlus. */ private void readProps(final ImagePlus imp) { this.type = imp.getType(); this.false_color = imp.getProcessor().isColorLut(); if (imp.getWidth() != (int)this.o_width || imp.getHeight() != this.o_height) { this.o_width = imp.getWidth(); this.o_height = imp.getHeight(); this.width = o_width; this.height = o_height; updateBucket(); } final ImageProcessor ip = imp.getProcessor(); this.min = ip.getMin(); this.max = ip.getMax(); final HashSet<String> keys = new HashSet<String>(); keys.add("type"); keys.add("dimensions"); keys.add("min_and_max"); updateInDatabase(keys); //updateInDatabase(new HashSet<String>(Arrays.asList(new String[]{"type", "dimensions", "min_and_max"}))); }
Example 2
Source File: Loader.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
static public ImageProcessor scaleImage(final ImagePlus imp, double mag, final boolean quality) { if (mag > 1) mag = 1; ImageProcessor ip = imp.getProcessor(); if (Math.abs(mag - 1) < 0.000001) return ip; // else, make a properly scaled image: // - gaussian blurred for best quality when resizing with nearest neighbor // - direct nearest neighbor otherwise final int w = ip.getWidth(); final int h = ip.getHeight(); // TODO releseToFit ! if (quality) { // apply proper gaussian filter final double sigma = Math.sqrt(Math.pow(2, getMipMapLevel(mag, Math.max(imp.getWidth(), imp.getHeight()))) - 0.25); // sigma = sqrt(level^2 - 0.5^2) ip = new FloatProcessorT2(w, h, ImageFilter.computeGaussianFastMirror(new FloatArray2D((float[])ip.convertToFloat().getPixels(), w, h), (float)sigma).data, ip.getDefaultColorModel(), ip.getMin(), ip.getMax()); ip = ip.resize((int)(w * mag), (int)(h * mag)); // better while float return Utils.convertTo(ip, imp.getType(), false); } else { return ip.resize((int)(w * mag), (int)(h * mag)); } }
Example 3
Source File: Loader.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
static public ImageProcessor scaleImage(final ImagePlus imp, final int level, final boolean quality) { if (level <= 0) return imp.getProcessor(); // else, make a properly scaled image: // - gaussian blurred for best quality when resizing with nearest neighbor // - direct nearest neighbor otherwise ImageProcessor ip = imp.getProcessor(); final int w = ip.getWidth(); final int h = ip.getHeight(); final double mag = 1 / Math.pow(2, level); // TODO releseToFit ! if (quality) { // apply proper gaussian filter final double sigma = Math.sqrt(Math.pow(2, level) - 0.25); // sigma = sqrt(level^2 - 0.5^2) ip = new FloatProcessorT2(w, h, ImageFilter.computeGaussianFastMirror(new FloatArray2D((float[])ip.convertToFloat().getPixels(), w, h), (float)sigma).data, ip.getDefaultColorModel(), ip.getMin(), ip.getMax()); ip = ip.resize((int)(w * mag), (int)(h * mag)); // better while float return Utils.convertTo(ip, imp.getType(), false); } else { return ip.resize((int)(w * mag), (int)(h * mag)); } }
Example 4
Source File: ExportUnsignedShort.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
PatchIntensityRange( final Patch patch ) { this.patch = patch; a = patch.getMax() - patch.getMin(); final ImageProcessor ip = patch.getImageProcessor(); ip.resetMinAndMax(); min = ( ip.getMin() - patch.getMin() ) / a; max = ( ip.getMax() - patch.getMin() ) / a; ip.setMinAndMax( patch.getMin(), patch.getMax() ); }
Example 5
Source File: GeodesicDistanceMapPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Computes the distance propagated from the boundary of the white * particles, within the white phase. * * @param markerPlus * the binary marker image from which distances will be * propagated * @param maskPlus * the binary mask image that will constrain the propagation * @param newName * the name of the result image * @param weights * the set of chamfer weights for computing distances * @param normalize * specifies whether the resulting distance map should be * normalized * @return an array of object, containing the name of the new image, and the * new ImagePlus instance */ public ImagePlus process(ImagePlus markerPlus, ImagePlus maskPlus, String newName, float[] weights, boolean normalize) { // Check validity of parameters if (markerPlus == null) { throw new IllegalArgumentException("Marker image not specified"); } if (maskPlus == null) { throw new IllegalArgumentException("Mask image not specified"); } if (newName == null) newName = createResultImageName(maskPlus); if (weights == null) { throw new IllegalArgumentException("Weights not specified"); } // size of image int width = maskPlus.getWidth(); int height = maskPlus.getHeight(); // check input and mask have the same size if (markerPlus.getWidth() != width || markerPlus.getHeight() != height) { IJ.showMessage("Error", "Input and marker images\nshould have the same size"); return null; } // Initialize calculator GeodesicDistanceTransform algo = new GeodesicDistanceTransformFloat5x5(weights, normalize); DefaultAlgoListener.monitor(algo); // Compute distance on specified images ImageProcessor marker = markerPlus.getProcessor(); ImageProcessor mask = maskPlus.getProcessor(); ImageProcessor result = algo.geodesicDistanceMap(marker, mask); ImagePlus resultPlus = new ImagePlus(newName, result); // setup display options double maxVal = result.getMax(); resultPlus.setLut(createFireLUT(maxVal)); resultPlus.setDisplayRange(0, maxVal); // return result image return resultPlus; }
Example 6
Source File: GeodesicDistanceMapPlugin.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Computes the distance propagated from the boundary of the white * particles, within the black phase. * * @param marker * the binary marker image from which distances will be * propagated * @param mask * the binary mask image that will constrain the propagation * @param newName * the name of the result image * @param weights * the set of chamfer weights for computing distances * @param normalize * specifies whether the resulting distance map should be * normalized * @return an array of object, containing the name of the new image, and the * new ImagePlus instance */ public ImagePlus process(ImagePlus marker, ImagePlus mask, String newName, short[] weights, boolean normalize) { // Check validity of parameters if (marker == null) { throw new IllegalArgumentException("Marker image not specified"); } if (mask == null) { throw new IllegalArgumentException("Mask image not specified"); } if (newName == null) newName = createResultImageName(mask); if (weights == null) { throw new IllegalArgumentException("Weights not specified"); } // size of image int width = mask.getWidth(); int height = mask.getHeight(); // check input and mask have the same size if (marker.getWidth() != width || marker.getHeight() != height) { IJ.showMessage("Error", "Input and marker images\nshould have the same size"); return null; } // Initialize calculator GeodesicDistanceTransform algo = new GeodesicDistanceTransformShort5x5(weights, normalize); DefaultAlgoListener.monitor(algo); // Compute distance on specified images ImageProcessor result = algo.geodesicDistanceMap(marker.getProcessor(), mask.getProcessor()); ImagePlus resultPlus = new ImagePlus(newName, result); // setup display options double maxVal = result.getMax(); resultPlus.setLut(createFireLUT(maxVal)); resultPlus.setDisplayRange(0, maxVal); // create result array return resultPlus; }
Example 7
Source File: InteractiveGeodesicDistanceMap.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Computes the distance propagated from the boundary of the white * particles, within the white phase. * * @param mask * the binary mask image that will constrain the propagation * @param roi * the roi to define the marker image * @param weights * the set of chamfer weights for computing distances * @param normalize * specifies whether the resulting distance map should be * normalized * @return geodesic distance map image */ public ImageProcessor process( ImageProcessor mask, Roi roi, float[] weights, boolean normalize) { if( mask == null || imagePlus == null || baseImage == null) { IJ.showMessage( "Please run the plugin with an image open." ); return null; } if( weights == null ) { IJ.showMessage( "Weights not specified" ); return null; } if( roi == null ) { IJ.showMessage( "Please define the markers using for example " + "the point selection tool." ); return null; } // Create marker image from ROI ByteProcessor marker = new ByteProcessor( mask.getWidth(), mask.getHeight() ); marker.setColor( java.awt.Color.WHITE ); marker.draw( roi ); // Initialize calculator GeodesicDistanceTransform algo; if( weights.length == 2 ) algo = new GeodesicDistanceTransformFloat( weights, normalize ); else algo = new GeodesicDistanceTransformFloat5x5( weights, normalize ); DefaultAlgoListener.monitor( algo ); // Compute distance on specified images ImageProcessor result = algo.geodesicDistanceMap( marker, mask ); // setup display options double maxVal = result.getMax(); result.setLut( createFireLUT( maxVal ) ); // create result image return result; }
Example 8
Source File: InteractiveGeodesicDistanceMap.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
/** * Computes the distance propagated from the boundary of the white * particles, within the white phase. * * @param mask * the binary mask image that will constrain the propagation * @param roi * the roi to define the marker image * @param weights * the set of chamfer weights for computing distances * @param normalize * specifies whether the resulting distance map should be * normalized * @return geodesic distance map image */ public ImageProcessor process( ImageProcessor mask, Roi roi, short[] weights, boolean normalize) { if( mask == null || imagePlus == null || baseImage == null) { IJ.showMessage( "Please run the plugin with an image open." ); return null; } if( weights == null ) { IJ.showMessage( "Weights not specified" ); return null; } if( roi == null ) { IJ.showMessage( "Please define the markers using for example " + "the point selection tool." ); return null; } // Create marker image from ROI ByteProcessor marker = new ByteProcessor( mask.getWidth(), mask.getHeight() ); marker.setColor( java.awt.Color.WHITE ); marker.draw( roi ); // Initialize calculator GeodesicDistanceTransform algo; if( weights.length == 2 ) algo = new GeodesicDistanceTransformShort( weights, normalize ); else algo = new GeodesicDistanceTransformShort5x5( weights, normalize ); DefaultAlgoListener.monitor( algo ); // Compute distance on specified images ImageProcessor result = algo.geodesicDistanceMap( marker, mask ); // setup display options double maxVal = result.getMax(); result.setLut( createFireLUT( maxVal ) ); // create result image return result; }
Example 9
Source File: ImageSaver.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
/** Returns a string containing information about the specified image. */ static public final String getDescriptionString(final ImagePlus imp, final FileInfo fi) { final Calibration cal = imp.getCalibration(); final StringBuilder sb = new StringBuilder(100); sb.append("ImageJ="+ImageJ.VERSION+"\n"); if (fi.nImages>1 && fi.fileType!=FileInfo.RGB48) sb.append("images="+fi.nImages+"\n"); int channels = imp.getNChannels(); if (channels>1) sb.append("channels="+channels+"\n"); int slices = imp.getNSlices(); if (slices>1) sb.append("slices="+slices+"\n"); int frames = imp.getNFrames(); if (frames>1) sb.append("frames="+frames+"\n"); if (fi.unit!=null) sb.append("unit="+fi.unit+"\n"); if (fi.valueUnit!=null && fi.calibrationFunction!=Calibration.CUSTOM) { sb.append("cf="+fi.calibrationFunction+"\n"); if (fi.coefficients!=null) { for (int i=0; i<fi.coefficients.length; i++) sb.append("c"+i+"="+fi.coefficients[i]+"\n"); } sb.append("vunit="+fi.valueUnit+"\n"); if (cal.zeroClip()) sb.append("zeroclip=true\n"); } // get stack z-spacing and fps if (fi.nImages>1) { if (fi.pixelDepth!=0.0 && fi.pixelDepth!=1.0) sb.append("spacing="+fi.pixelDepth+"\n"); if (cal.fps!=0.0) { if ((int)cal.fps==cal.fps) sb.append("fps="+(int)cal.fps+"\n"); else sb.append("fps="+cal.fps+"\n"); } sb.append("loop="+(cal.loop?"true":"false")+"\n"); if (cal.frameInterval!=0.0) { if ((int)cal.frameInterval==cal.frameInterval) sb.append("finterval="+(int)cal.frameInterval+"\n"); else sb.append("finterval="+cal.frameInterval+"\n"); } if (!cal.getTimeUnit().equals("sec")) sb.append("tunit="+cal.getTimeUnit()+"\n"); } // get min and max display values final ImageProcessor ip = imp.getProcessor(); final double min = ip.getMin(); final double max = ip.getMax(); final int type = imp.getType(); final boolean enhancedLut = (type==ImagePlus.GRAY8 || type==ImagePlus.COLOR_256) && (min!=0.0 || max !=255.0); if (enhancedLut || type==ImagePlus.GRAY16 || type==ImagePlus.GRAY32) { sb.append("min="+min+"\n"); sb.append("max="+max+"\n"); } // get non-zero origins if (cal.xOrigin!=0.0) sb.append("xorigin="+cal.xOrigin+"\n"); if (cal.yOrigin!=0.0) sb.append("yorigin="+cal.yOrigin+"\n"); if (cal.zOrigin!=0.0) sb.append("zorigin="+cal.zOrigin+"\n"); if (cal.info!=null && cal.info.length()<=64 && cal.info.indexOf('=')==-1 && cal.info.indexOf('\n')==-1) sb.append("info="+cal.info+"\n"); sb.append((char)0); return new String(sb); }