/** * Constructor is package-private. */ Region(FillResult fill) { this.id = fill.getID(); this.refValue = fill.getValue(); this.bounds = fill.getBounds(); this.numPixels = fill.getNumPixels(); }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * @param interp ignored * * @return the new ROI */ @Override public ROI transform(AffineTransform at, Interpolation interp) { return transform(at); }
/** * Create a set of colours using a simple colour ramp algorithm in the HSB colour space. * * @param numColours number of colours required * * @return an array of colours sampled from the HSB space. */ public static Color[] createRampColours(int numColours) { return createRampColours(numColours, 0.8f, 0.8f); }
/** * Fills the region connected to the specified start pixel. * A pixel belongs to this region if there is a path between it and the starting * pixel which passes only through pixels of value {@code v} within the range * {@code start_pixel_value - tolerance <= v <= start_pixel_value + tolerance}. * * @param x start pixel x coordinate * * @param y start pixel y coordinate * * @param fillValue the value to write to the destination image for this region * * @return a new {@linkplain FillResult} */ public FillResult fill(int x, int y, int fillValue) { return fill(x, y, fillValue, srcIter.getSampleDouble(x, y, srcBand)); }
/** * Tests if this ROI contains the given image location. * * @param x location X ordinate * @param y location Y ordinate * * @return {@code true} if the location is within this ROI; * {@code false} otherwise */ @Override public boolean contains(int x, int y) { return contains((double)x, (double)y); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle rect) { setTestRect(rect.x, rect.y, rect.width, rect.height); return theGeom.intersects(testRect); }
/** * Creates a new TiledImage object with a single band of constant value. * The data type of the image corresponds to the class of {@code value}. * * @param width image width in pixels * * @param height image height in pixels * * @param value the constant value to fill the image * * @return a new TiledImage object */ public static TiledImage createConstantImage(int width, int height, Number value) { return createConstantImage(width, height, new Number[] {value}); }
/** * Fills the region connected to the specified start pixel. * A pixel belongs to this region if there is a path between it and the starting * pixel which passes only through pixels of value {@code v} within the range * {@code refValue - tolerance <= v <= refValue + tolerance}. * * @param x start pixel x coordinate * * @param y start pixel y coordinate * * @param fillValue the value to write to the destination image for this region * * @param refValue the source image reference value for the region * * @return a new {@linkplain FillResult} */ public FillResult fill(int x, int y, int fillValue, double refValue) { return fillRadius(x, y, fillValue, refValue, Double.NaN); }
/** * Constructor is package-private. */ Region(FillResult fill) { this.id = fill.getID(); this.refValue = fill.getValue(); this.bounds = fill.getBounds(); this.numPixels = fill.getNumPixels(); }
/** * Tests if this ROI contains the given rectangle. * * @param x rectangle origin X ordinate * @param y rectangle origin Y ordinate * @param w rectangle width * @param h rectangle height * * @return {@code true} if the rectangle is within this ROI; * {@code false} otherwise */ @Override public boolean contains(int x, int y, int w, int h) { return contains((double)x, (double)y, (double)w, (double)h); }
/** * Tests if the given rectangle intersects with this ROI. * * @param x rectangle origin X ordinate * @param y rectangle origin Y ordinate * @param w rectangle width * @param h rectangle height * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(double x, double y, double w, double h) { setTestRect(x, y, w, h); return theGeom.intersects(testRect); }
/** * Creates a new TiledImage object with one or more bands of constant value. * The number of bands in the output image corresponds to the length of * the input values array and the data type of the image corresponds to the * {@code Number} class used. * * @param width image width in pixels * * @param height image height in pixels * * @param values array of values (must contain at least one element) * * @return a new TiledImage object */ public static TiledImage createConstantImage(int width, int height, Number[] values) { return createConstantImage(0, 0, width, height, values); }
/** * Create a set of colours using a simple colour ramp algorithm in the HSB colour space. * * @param numColours number of colours required * * @param saturation the saturation of all colours (between 0 and 1) * * @param brightness the brightness of all colours (between 0 and 1) * * @return an array of colours sampled from the HSB space between the start and end hues */ public static Color[] createRampColours(int numColours, float saturation, float brightness) { return createRampColours(numColours, 0.0f, 1.0f, saturation, brightness); }
/** * Tests if this ROI contains the given point. * * @param p the point * * @return {@code true} if the point is within this ROI; * {@code false} otherwise */ @Override public boolean contains(Point p) { return contains(p.getX(), p.getY()); }
/** * Tests if the given rectangle intersects with this ROI. * * @param x rectangle origin X ordinate * @param y rectangle origin Y ordinate * @param w rectangle width * @param h rectangle height * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(int x, int y, int w, int h) { setTestRect(x, y, w, h); return theGeom.intersects(testRect); }
/** * Creates a new TiledImage object with a single band of constant value. * The data type of the image corresponds to the class of {@code value}. * * @param minx minimum image X ordinate * * @param miny minimum image Y ordinate * * @param width image width in pixels * * @param height image height in pixels * * @param value the constant value to fill the image * * @return a new TiledImage object */ public static TiledImage createConstantImage(int minx, int miny, int width, int height, Number value) { return createConstantImage(minx, miny, width, height, new Number[] {value}); }
/** * Tests if this ROI contains the given point. * * @param p the point * * @return {@code true} if the point is within this ROI; * {@code false} otherwise */ @Override public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); }
/** * Tests if the given rectangle intersects with this ROI. * * @param rect the rectangle * @return {@code true} if there is an intersection; {@code false} otherwise */ @Override public boolean intersects(Rectangle2D rect) { setTestRect(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); return theGeom.intersects(testRect); }
/** * Tests if this ROI contains the given rectangle. * * @param rect the rectangle * @return {@code true} if the rectangle is within this ROI; * {@code false} otherwise */ @Override public boolean contains(Rectangle2D rect) { return contains(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); }
/** * Tests if this ROI contains the given rectangle. * * @param rect the rectangle * @return {@code true} if the rectangle is within this ROI; * {@code false} otherwise */ @Override public boolean contains(Rectangle rect) { return contains(rect.getMinX(), rect.getMinY(), rect.getWidth(), rect.getHeight()); }