Java Code Examples for ij.process.ImageProcessor#resetMinAndMax()
The following examples show how to use
ij.process.ImageProcessor#resetMinAndMax() .
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: Stitching_2D.java From Stitching with GNU General Public License v2.0 | 6 votes |
private ImagePlus FloatArrayToImagePlus(FloatArray2D image, String name, float min, float max) { int width = image.width; int height = image.height; ImagePlus impResult = IJ.createImage(name, "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x, y); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); impResult.updateAndDraw(); return impResult; }
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: 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 5
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
public static ImagePlus DoubleArrayToStack(double[] image, int width, int height, int nstacks, String name, float min, float max) { ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = (float)image[x + width * (y + slice * height)]; ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
Example 6
Source File: PatchStack.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
/** Reset temporary changes such as from dragging B&C sliders and so on, in the current slice (the current Patch). */ public void resetNonActive() { Utils.log2("PatchStack: calling reset"); // remake the awt for the patch, flush the previous awt Loader loader = patch[currentSlice-1].getProject().getLoader(); for (int i=0; i<patch.length; i++) { if (currentSlice-1 == i || !called[i]) continue; called[i] = false; ImagePlus imp = loader.fetchImagePlus(patch[i]); ImageProcessor ip = imp.getProcessor(); switch (imp.getType()) { // as in ij.plugin.frame.ContrastAdjuster.reset(ImagePlus, ImageProcessor) case ImagePlus.COLOR_RGB: ip.reset(); break; case ImagePlus.GRAY16: case ImagePlus.GRAY32: ip.resetMinAndMax(); break; } patch[i].setMinAndMax(ip.getMin(), ip.getMax()); patch[i].getProject().getLoader().decacheAWT(patch[i].getId()); Display.repaint(patch[i].getLayer(), patch[i], null, 0, true); } }
Example 7
Source File: Stitching_3D.java From Stitching with GNU General Public License v2.0 | 5 votes |
private ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x, y, slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
Example 8
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 9
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public static void FloatArrayToFloatProcessor(ImageProcessor ip, FloatArray2D pixels) { float[] data = new float[pixels.width * pixels.height]; int count = 0; for (int y = 0; y < pixels.height; y++) for (int x = 0; x < pixels.width; x++) data[count] = pixels.data[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
Example 10
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public static void ArrayToFloatProcessor(ImageProcessor ip, float[] pixels, int width, int height) { float[] data = new float[width * height]; int count = 0; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) data[count] = (float)pixels[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
Example 11
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public static void ArrayToFloatProcessor(ImageProcessor ip, double[] pixels, int width, int height) { float[] data = new float[width * height]; int count = 0; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) data[count] = (float)pixels[count++]; ip.setPixels(data); ip.resetMinAndMax(); }
Example 12
Source File: ImageArrayConverter.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public static ImagePlus FloatArrayToStack(FloatArray3D image, String name, float min, float max) { int width = image.width; int height = image.height; int nstacks = image.depth; ImageStack stack = new ImageStack(width, height); for (int slice = 0; slice < nstacks; slice++) { ImagePlus impResult = IJ.createImage("Result", "32-Bit Black", width, height, 1); ImageProcessor ipResult = impResult.getProcessor(); float[] sliceImg = new float[width * height]; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) sliceImg[y * width + x] = image.get(x,y,slice); ipResult.setPixels(sliceImg); if (min == max) ipResult.resetMinAndMax(); else ipResult.setMinAndMax(min, max); stack.addSlice("Slice " + slice, ipResult); } return new ImagePlus(name, stack); }
Example 13
Source File: SingleWindowDisplay.java From Colocalisation_Analysis with GNU General Public License v3.0 | 5 votes |
protected void toggleLogarithmic(boolean enabled) { if (imp == null) return; ImageProcessor ip = imp.getProcessor(); if (enabled) { ip.snapshot(); ip.log(); ip.resetMinAndMax(); } else ip.reset(); imagePanel.repaint(); }
Example 14
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 15
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 16
Source File: ResetMinAndMax.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
@Override public ImageProcessor process(ImageProcessor ip) { ip.resetMinAndMax(); return ip; }
Example 17
Source File: Patch.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
/** Reconstruct from an XML entry. */ public Patch(final Project project, final long id, final HashMap<String,String> ht_attributes, final HashMap<Displayable,String> ht_links) { super(project, id, ht_attributes, ht_links); // cache path: project.getLoader().addedPatchFrom(ht_attributes.get("file_path"), this); boolean hasmin = false; boolean hasmax = false; // parse specific fields String data; if (null != (data = ht_attributes.get("type"))) this.type = Integer.parseInt(data); if (null != (data = ht_attributes.get("false_color"))) this.false_color = Boolean.parseBoolean(data); if (null != (data = ht_attributes.get("min"))) { this.min = Double.parseDouble(data); hasmin = true; } if (null != (data = ht_attributes.get("max"))) { this.max = Double.parseDouble(data); hasmax = true; } if (null != (data = ht_attributes.get("o_width"))) this.o_width = Integer.parseInt(data); if (null != (data = ht_attributes.get("o_height"))) this.o_height = Integer.parseInt(data); if (null != (data = ht_attributes.get("pps"))) { if (FSLoader.isRelativePath(data)) data = project.getLoader().getParentFolder() + data; project.getLoader().setPreprocessorScriptPathSilently(this, data); } if (null != (data = ht_attributes.get("original_path"))) this.original_path = data; if (null != (data = ht_attributes.get("mres"))) this.meshResolution = Integer.parseInt(data); if (null != (data = ht_attributes.get("ct_id"))) this.ct_id = Long.parseLong(data); if (null != (data = ht_attributes.get("alpha_mask_id"))) this.alpha_mask_id = Long.parseLong(data); if (0 == o_width || 0 == o_height) { // The original image width and height are unknown. try { Utils.log2("Restoring original width/height from file for id=" + id); // Use BioFormats to read the dimensions out of the original file's header final Dimension dim = project.getLoader().getDimensions(this); o_width = dim.width; o_height = dim.height; } catch (final Exception e) { Utils.log("Could not read source data width/height for patch " + this +"\n --> To fix it, close the project and add o_width=\"XXX\" o_height=\"YYY\"\n to patch entry with oid=\"" + id + "\",\n where o_width,o_height are the image dimensions as defined in the image file."); // So set them to whatever is somewhat survivable for the moment o_width = (int)width; o_height = (int)height; IJError.print(e); } } if (hasmin && hasmax) { checkMinMax(); } else { if (ImagePlus.GRAY8 == type || ImagePlus.COLOR_RGB == type || ImagePlus.COLOR_256 == type) { min = 0; max = 255; } else { // Re-read: final ImageProcessor ip = getImageProcessor(); if (null == ip) { // Some values, to survive: min = 0; max = Patch.getMaxMax(this.type); Utils.log("WARNING could not restore min and max from image file for Patch #" + this.id + ", and they are not present in the XML file."); } else { ip.resetMinAndMax(); // finds automatically reasonable values setMinAndMax(ip.getMin(), ip.getMax()); } } } }
Example 18
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 ); }