Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Provides a single jar containing all JAI-tools modules which you can
use instead of including individual modules in your project. Note:
It does not include the Jiffle scripting language or Jiffle image
operator.
/*
* Copyright 2010-2011 Michael Bedward
*
* This file is part of jai-tools.
*
* jai-tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* jai-tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with jai-tools. If not, see .
*
*/
package jaitools.media.jai.contour;
import java.awt.image.RenderedImage;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.media.jai.PlanarImage;
import javax.media.jai.ROI;
import javax.media.jai.iterator.RectIter;
import javax.media.jai.iterator.RectIterFactory;
import com.vividsolutions.jts.geom.LineString;
import jaitools.CollectionFactory;
import jaitools.jts.LineSmoother;
import jaitools.jts.SmootherControl;
import jaitools.jts.Utils;
import jaitools.media.jai.AttributeOpImage;
import jaitools.numeric.CompareOp;
import jaitools.numeric.Range;
/**
* Generates contours for user-specified levels of values in the source image.
* The contours are returned as a {@code Collection} of
* {@link com.vividsolutions.jts.geom.LineString}s.
*
* The interpolation algorithm used is that of Paul Bourke: originally published
* in Byte magazine (1987) as the CONREC contouring subroutine written in
* FORTRAN. The implementation here was adapted from Paul Bourke's C code for the
* algorithm available at:
*
* http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/
*
*
* @author Michael Bedward
* @since 1.1
* @version $Id: ContourOpImage.java 1610 2011-03-31 04:44:28Z michael.bedward $
*/
public class ContourOpImage extends AttributeOpImage {
/*
* Constants to identify vertices for each group of
* data points being processed, as per the diagram
* in the javadoc for getContourSegments method.
*/
private static final int BL_VERTEX1 = 0;
private static final int BR_VERTEX2 = 1;
private static final int TR_VERTEX3 = 2;
private static final int TL_VERTEX4 = 3;
/** The source image band to process */
private int band;
/** Values at which to generate contour intervals */
private List contourLevels;
/**
* Interval between contours. This is used if specific contour
* levels are not requested. Contours will be generated such that
* the value of each is an integer multiple of this value.
*/
private Double contourInterval;
/** List of Numbers to treat as NO_DATA */
private List noDataNumbers;
/** List of Ranges to treat as NO_DATA */
private List> noDataRanges;
/** Whether to use strict NODATA exclusion */
private final boolean strictNodata;
/** Output contour lines */
private SoftReference> cachedContours;
/** Whether to simplify contour lines by removing coincident vertices */
private final boolean simplify;
/** Whether to apply Bezier smoothing to the contour lines */
private final boolean smooth;
/**
* Alpha parameter controlling Bezier smoothing
* (see {@link LineSmoother})
*/
private double smoothAlpha = 0.0;
/**
* Control object for Bezier smoothing. Note that length units here
* are pixels.
*/
private final SmootherControl smootherControl = new SmootherControl() {
public double getMinLength() {
return 0.1;
}
public int getNumVertices(double length) {
return (int) Math.max(5, length * 10);
}
};
/**
* Constructor. Note that one of {@code levels} or {@code interval} must
* be supplied. If both are supplied {@code interval} is ignored.
*
* @param source the source image
*
* @param roi an optional {@code ROI} to constrain the areas for which
* contours are generated
*
* @param band the band of the source image to process
*
* @param levels values for which to generate contours
*
* @param interval interval between contour levels (ignored if {@code levels}
* is supplied)
*
* @param simplify whether to simplify contour lines by removing
* colinear vertices
*
* @param smooth whether contour lines should be smoothed using
* Bezier interpolation
*/
public ContourOpImage(RenderedImage source,
ROI roi,
int band,
Collection extends Number> levels,
Double interval,
Collection