public String arrayAsString(final Locale locale, final String delimiter, final int nDecimalPlaces) { return GeneralTools.arrayToString(locale, new double[]{r, g, b}, delimiter, nDecimalPlaces); // return String.format( "%.Nf%s%.Nf%s%.Nf".replace("N", Integer.toString(nDecimalPlaces)), r, delimiter, g, delimiter, b); // return String.format( "%.Nf, %.Nf, %.Nf".replace("N", Integer.toString(nDecimalPlaces)), r, g, b ); // return String.format( "[%.Nf, %.Nf, %.Nf]".replace("N", Integer.toString(nDecimalPlaces)), r, g, b ); // return "[" + IJ.d2s(r, nDecimalPlaces) + ", " + IJ.d2s(g, nDecimalPlaces) + ", " + IJ.d2s(b, nDecimalPlaces) + "]"; }
/** * Read URL as String, with default timeout of 5 seconds. * * @param url * @return */ public static String readURLAsString(final URL url) throws IOException { return readURLAsString(url, 5000); // Here, use 5 second timeout }
/** * Create a workflow step to run a classifier. * * @param name * @param classifierPath */ public RunSavedClassifierWorkflowStep(final String name, final String classifierPath) { this.name = name; this.classifierPath = GeneralTools.escapeFilePath(classifierPath); }
/** * Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily). * @param r * @param g * @param b * @return */ public static Color getCachedColor(final int r, final int g, final int b) { return ColorToolsAwt.getCachedColor(ColorTools.makeRGB(r, g, b)); }
public TilerPlugin() { // Set up initial parameters params = new ParameterList(); params.addTitleParameter("Tile options"); params.addDoubleParameter("tileSizeMicrons", "Tile size", 100, GeneralTools.micrometerSymbol(), "Specify tile width and height, in " + GeneralTools.micrometerSymbol()); params.addDoubleParameter("tileSizePx", "Tile size", 200, "px", "Specify tile width and height, in pixels"); params.addBooleanParameter("trimToROI", "Trim to ROI", true, "Trim tiles to match the parent ROI shape, rather than overlap boundaries with full squares"); params.addTitleParameter("Annotation options"); params.addBooleanParameter("makeAnnotations", "Make annotation tiles", false, "Create annotation objects, rather than tile objects"); params.addBooleanParameter("removeParentAnnotation", "Remove parent annotation", false, "Remove the parent object, if it was an annotation; has no effect if 'Make annotation tiles' is not selected, or the parent object is not an annotation"); }
/** * Get a scaled version of the specified color, where the RGB values are independently scaled by a specified factor. * * The alpha value is preserved unchanged. * * @param color * @return */ public static Color scaleColor(Color color, double factor) { return new Color(ColorTools.do8BitRangeCheck(color.getRed()*factor), ColorTools.do8BitRangeCheck(color.getGreen()*factor), ColorTools.do8BitRangeCheck(color.getBlue()*factor), color.getAlpha()); }
@Override public boolean validateSquarePixels() { return GeneralTools.almostTheSame(getPixelWidthMicrons(), getPixelHeightMicrons(), 0.0001); }
/** * Format a value with a maximum number of decimal places, using the default Locale. * * @param value * @param nDecimalPlaces * @return */ public synchronized static String formatNumber(final double value, final int maxDecimalPlaces) { return formatNumber(Locale.getDefault(Category.FORMAT), value, maxDecimalPlaces); }
/** * Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily). * @param r * @param g * @param b * @param a * @return */ public static Color getCachedColor(final int r, final int g, final int b, final int a) { return ColorToolsAwt.getCachedColor(ColorTools.makeRGBA(r, g, b, a)); }
@Override public boolean isValid() { return !GeneralTools.blankString(intensityMeasurement, true) && !Double.isNaN(t1); }
public ParallelTileObject(final ROI pathROI, final PathObjectHierarchy hierarchy, final AtomicInteger countdown) { super(pathROI); this.bounds = getBounds2D(pathROI); this.hierarchy = hierarchy; this.countdown = countdown; setColorRGB(ColorTools.makeRGB(128, 128, 128)); }
public SmoothFeaturesPlugin() { params = new ParameterList() .addDoubleParameter("fwhmMicrons", "Radius (FWHM)", 25, GeneralTools.micrometerSymbol(), "Smoothing filter size - higher values indicate more smoothing") .addDoubleParameter("fwhmPixels", "Radius (FWHM)", 100, "pixels", "Smoothing filter size - higher values indicate more smoothing") .addBooleanParameter("smoothWithinClasses", "Smooth within classes", false, "Restrict smoothing to only be applied within objects with the same base classification") .addBooleanParameter("useLegacyNames", "Use legacy feature names", false, "Use previous naming strategy for smoothed features - only retained here for backwards compatibility") ; }
/** * Convert a double array to a String using a space as a delimiter. * * @param locale * @param array * @param nDecimalPlaces * @return */ public static String arrayToString(final Locale locale, final double[] array, final int nDecimalPlaces) { return arrayToString(locale, array, " ", nDecimalPlaces); }
/** * Get a Color that (roughly) corresponds to color represented by this stain vector. * It may be used to create a color lookup table. * * @return */ public int getColor() { int r2 = clip255(255.0 - r * 255); int g2 = clip255(255.0 - g * 255); int b2 = clip255(255.0 - b * 255); return ColorTools.makeRGB(r2, g2, b2); }
public CoherenceFeaturePlugin(final ImageRegionStore<BufferedImage> regionServer) { this.regionStore = regionServer; params = new ParameterList(). addDoubleParameter("magnification", "Magnification", 5). addChoiceParameter("stainChoice", "Stains", "Optical density", new String[]{"Optical density", "H-DAB", "H&E", "H-DAB (8-bit)", "H&E (8-bit)", "RGB", "Grayscale"}); params.addDoubleParameter("tileSizeMicrons", "Tile diameter", 25, GeneralTools.micrometerSymbol()); params.addDoubleParameter("tileSizePx", "Tile diameter", 200, "px (full resolution image)"); params.addBooleanParameter("includeStats", "Include basic statistics", true). addBooleanParameter("doCircular", "Use circular tiles", false); }
public String arrayAsString(final Locale locale, final int nDecimalPlaces) { return GeneralTools.arrayToString(locale, new double[]{r, g, b}, nDecimalPlaces); // return String.format( "%.Nf %.Nf %.Nf".replace("N", Integer.toString(nDecimalPlaces)), r, g, b ); // return String.format( "%.Nf, %.Nf, %.Nf".replace("N", Integer.toString(nDecimalPlaces)), r, g, b ); // return String.format( "[%.Nf, %.Nf, %.Nf]".replace("N", Integer.toString(nDecimalPlaces)), r, g, b ); // return "[" + IJ.d2s(r, nDecimalPlaces) + ", " + IJ.d2s(g, nDecimalPlaces) + ", " + IJ.d2s(b, nDecimalPlaces) + "]"; }
public LocalBinaryPatternsPlugin(final ImageRegionStore<BufferedImage> regionServer) { this.regionStore = regionServer; params = new ParameterList(). addDoubleParameter("magnification", "Magnification", 5). addChoiceParameter("stainChoice", "Stains", "Optical density", new String[]{"Optical density", "H-DAB", "H&E", "H-DAB (8-bit)", "H&E (8-bit)", "RGB", "Grayscale"}); params.addDoubleParameter("tileSizeMicrons", "Tile diameter", 25, GeneralTools.micrometerSymbol()); params.addDoubleParameter("tileSizePx", "Tile diameter", 200, "px (full resolution image)"); params.addBooleanParameter("includeStats", "Include basic statistics", false). addBooleanParameter("doCircular", "Use circular tiles", false); }
public ShapeFeaturesPlugin() { params = new ParameterList() .addTitleParameter("Measurements") .addBooleanParameter("area", "Area", true, "Compute area of ROI") .addBooleanParameter("perimeter", "Perimeter", false, "Compute perimeter of ROI") .addBooleanParameter("circularity", "Circularity", false, "Compute circularity of ROI, between 0 (a line) and 1 (a circle)") .addTitleParameter("Units") .addBooleanParameter("useMicrons", "Use microns", true, "Compute measurements using " + GeneralTools.micrometerSymbol() + ", where possible"); }