/** * Creates a rectangular kernel where all elements have the same value. * The key element will be at {@code (width/2, height/2)}. * * @param width rectangle width * @param height rectangle height * @param value element value * * @return a new {@code KernelJAI} object * * @throws IllegalArgumentException if either {@code width} or {@code height} * are less than 1 */ public static KernelJAI createConstantRectangle(int width, int height, float value) { if (width < 1 || height < 1) { throw new IllegalArgumentException("width and height must both be >= 1"); } float [] weights = (new KernelFactoryHelper()).makeRect(width, height, value); return new KernelJAI(width, height, weights); }
/** * Creates a rectangular kernel where all elements have the same value. * * @param width rectangle width * @param height rectangle height * @param value element value * @param keyX key element X ordinate * @param keyY key element Y ordinate * * @return a new {@code KernelJAI} object * * @throws IllegalArgumentException if either {@code width} or {@code height} * are less than 1 or if the key element location is outside the * rectangle */ public static KernelJAI createConstantRectangle(int width, int height, int keyX, int keyY, float value) { if (width < 1 || height < 1) { throw new IllegalArgumentException("width and height must both be >= 1"); } if (keyX < 0 || keyX >= width || keyY < 0 || keyY >= height) { throw new IllegalArgumentException("key element must be within the rectangle"); } float [] weights = (new KernelFactoryHelper()).makeRect(width, height, value); return new KernelJAI(width, height, keyX, keyY, weights); }
/** * Creates a new KernelJAI object with a rectangular configuraton. * An IllegalArgumentException will be thrown if width or height are less than 1. * <p> * This is equivalent to calling... * <p> * {@code createRectangle(width, height, Kernel.ValueType.BINARY, width/2, height/2, 1.0f) } * * @param width rectangle width * @param height rectangle height * * @return a new instance of KernelJAI */ public static KernelJAI createRectangle(int width, int height) { float [] weights = (new KernelFactoryHelper()).makeRect(width, height); return new KernelJAI(width, height, weights); }
/** * Creates a new KernelJAI object with a rectangular configuraton. * An IllegalArgumentException will be thrown if width or height are less than 1. * <p> * This is equivalent to calling... * <p> * {@code createRectangle(width, height, Kernel.ValueType.BINARY, width/2, height/2, 1.0f) } * * @param width rectangle width * @param height rectangle height * * @return a new instance of KernelJAI */ public static KernelJAI createRectangle(int width, int height) { float [] weights = (new KernelFactoryHelper()).makeRect(width, height); return new KernelJAI(width, height, weights); }
weights = kh.makeRect(width, height, 1.0f); return new KernelJAI(width, height, keyX, keyY, weights);
weights = kh.makeRect(width, height); weights[keyX + keyY*width] = keyValue; return new KernelJAI(width, height, keyX, keyY, weights);
weights = kh.makeRect(width, height); weights[keyX + keyY*width] = keyValue; return new KernelJAI(width, height, keyX, keyY, weights);