/** * 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); }
/** * Gets a value from the first band of each image in this set * and returns them as a {@code Map} of key : value pairs. * * @return image (or outside) values */ public Map<K, Number> getSample() { return getSample(0); }
/** * 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); }
/** * Creates a new image set which will contain the same keys, images and * outside values as the input set. If the input set is {@code null} or * empty, an empty image set is created. * * @param <K> the key type * @param set the image set to copy * * @return the new copy */ public static <K> ImageSet<K> copy(ImageSet<K> set) { ImageSet<K> newSet = new ImageSet<K>(); if (!(set == null || set.isEmpty())) { for (K key : set.keySet()) { RenderedImage image = set.get(key); Number outsideValue = set.getOutsideValue(key); newSet.add(key, image, outsideValue); } } return newSet; }
private static void fillRaster(WritableRaster wr, int w, int h, int dataType, Object typedValues) { switch (dataType) { case DataBuffer.TYPE_DOUBLE: { double[] values = (double[]) typedValues; fillRasterDouble(wr, w, h, values); } break; case DataBuffer.TYPE_FLOAT: { float[] values = (float[]) typedValues; fillRasterFloat(wr, w, h, values); } break; case DataBuffer.TYPE_BYTE: case DataBuffer.TYPE_SHORT: case DataBuffer.TYPE_INT: { int[] values = (int[]) typedValues; fillRasterInt(wr, w, h, values); } break; } }
/** * Gets the value that an image set iterator will return for the * image associated with the given key when it is positioned * outside the bounds of that image. * * @param key the key * @return the value returned for out-of-bounds value requests * (may be {@code null}) */ public Number getOutsideValue(K key) { assertKey(key); return elements.get(key).getOutsideValue(); }
/** * 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); }
/** * 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}); }
/** * Gets a new iterator based on the bounds of the image with the * specified key value. * * @param bounds iterator bounds * @return the new iterator * * @throws IllegalArgumentException if this image set is empty or if no * image corresponds to the key value */ public Iterator<K> getIterator(Rectangle bounds) { return new Iterator<K>(this, bounds); }
/** * 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); }
/** * Gets the bounds of the image associated with the given key. * * @param key the image key * @return image bounds as a new Rectangle or {@code null} if the key * could not be found */ public Rectangle getBounds(K key) { Element e = elements.get(key); return e == null ? null : e.getBounds(); }
/** * 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); }
/** * 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); }
/** * 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()); }
/** * 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 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()); }