/** * <p>Fill destination image area from interpolation of source pixels from imageSrc.<br/> * Source pixel coordinates is obtained from invert transformation of destination pixel coordinates.<br/><br/> * - In case where interpolation equals {@linkplain InterpolationCase#LANCZOS lanczos interpolation} the default * choosen lanczos window is initialized by value 2.<br/> * - The default border comportement is define as {@link ResampleBorderComportement#FILL_VALUE}<br/> * - In case where pixel transformation is out of source image boundary the default choosen fill value is {@link Double#NaN}.<br/><br/> * * <strong> * Moreover : the specified MathTransform should be from CENTER of target image point to CENTER of source image point.<br/> * The used MathTransform is consider as {@link PixelInCell#CELL_CENTER} configuration.</strong></p> * * @param mathTransform Transformation use to transform target point to source point. * @param imageDest image will be fill by image source pixel interpolation. * @param imageSrc source image which contain pixel values which will be interpolate. * @param interpolation case of interpolation. * @throws NoninvertibleTransformException if it is impossible to invert {@code MathTransform} parameter. * @see ResampleBorderComportement * @see LanczosInterpolation#LanczosInterpolation(org.geotoolkit.image.iterator.PixelIterator, int) */ public Resample(MathTransform mathTransform, WritableRenderedImage imageDest, RenderedImage imageSrc, InterpolationCase interpolation) throws TransformException { this(mathTransform, imageDest, null, imageSrc, interpolation, 2, ResampleBorderComportement.FILL_VALUE, new double[imageDest.getSampleModel().getNumBands()]); }
/** * Colors an area of connected pixels with the same set of color. * The fill is performed in place in the given image. * The operation is performed immediately; it is not deferred like usual JAI operations. * * @param image The image in which to colors an area. * @param oldValues The colors to replace (usually only 1 color, but more are allowed). * @param newValues The new colors replacing the old ones. * @param points The coordinate of the starting point. There is usually only one * such point, but more are allowed. */ public static void fill(final WritableRenderedImage image, final double[][] oldValues, final double[] newValues, final Point... points) { /* * Copies the old values in a set of SampleValues objects. The exact type of SampleValues * will depend on the transfer type. */ final int transferType = image.getSampleModel().getTransferType(); final Set<SampleValues> oldSamples = new HashSet<>(hashMapCapacity(oldValues.length)); for (final double[] samples : oldValues) { oldSamples.add(SampleValues.getInstance(transferType, samples)); } final SampleValues newSamples = SampleValues.getInstance(transferType, newValues); oldSamples.remove(newSamples); // Necessary for avoiding infinite loop. if (oldSamples.isEmpty()) { return; } fill(image, oldSamples::contains, newSamples, points); }
/** * Colors an area of connected pixels with the same set of color. * The fill is performed in place in the given image. * The operation is performed immediately; it is not deferred like usual JAI operations. * * @param image The image in which to colors an area. * @param oldColors The colors to replace (usually only 1 color, but more are allowed). * @param newColors The new colors replacing the old ones. * @param points The coordinate of the starting point. There is usually only one * such point, but more are allowed. */ public static void fill(final WritableRenderedImage image, final Color[] oldColors, final Color newColors, final Point... points) { final int numBands = image.getSampleModel().getNumBands(); final double[][] oldValues = new double[oldColors.length][]; for (int i=0; i<oldValues.length; i++) { oldValues[i] = ColorUtilities.toDoubleValues(oldColors[i], numBands); } final double[] newValues = ColorUtilities.toDoubleValues(newColors, numBands); fill(image, oldValues, newValues, points); }
destination = output; if (output != null) { if (!input.getSampleModel().equals(output.getSampleModel())) { throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedSampleModel)); } else if (input.getMinX() != output.getMinX() ||
|| renderedImage.getWidth() != writableRI.getWidth() || renderedImage.getHeight() != writableRI.getHeight() || renderedImage.getSampleModel().getNumBands() != writableRI.getSampleModel().getNumBands()) throw new IllegalArgumentException("rendered image and writable rendered image dimensions are not conform.\n" + "First : "+renderedImage+"\nSecond : "+writableRI);
if (renderedImage.getSampleModel().getNumBands() != writableRI.getSampleModel().getNumBands()) throw new IllegalArgumentException("renderedImage and writableRenderedImage haven't got same band number"); final int riMinX = renderedImage.getMinX();
destCoords = new double[2]; this.rbc = rbc; this.clamp = getClamp(imageDest.getSampleModel().getDataType());
this.clamp = getClamp(imageDest.getSampleModel().getDataType());