01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
05: * (C) 2005, Institut de Recherche pour le Développement
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.coverage.processing.operation;
18:
19: // JAI dependencies (for javadoc)
20: import javax.media.jai.operator.InvertDescriptor;
21:
22: // Geotools dependencies
23: import org.geotools.util.NumberRange;
24: import org.geotools.coverage.processing.OperationJAI;
25:
26: /**
27: * Inverts the sample values of a coverage. For source coverages with signed data types,
28: * the sample values of the destination coverage are defined by the pseudocode:
29: *
30: * <BLOCKQUOTE><PRE>
31: * dst[x][y][b] = -src[x][y][b]
32: * </PRE></BLOCKQUOTE>
33: *
34: * <P><STRONG>Name:</STRONG> <CODE>"Invert"</CODE><BR>
35: * <STRONG>JAI operator:</STRONG> <CODE>"{@linkplain InvertDescriptor Invert}"</CODE><BR>
36: * <STRONG>Parameters:</STRONG></P>
37: * <table border='3' cellpadding='6' bgcolor='F4F8FF'>
38: * <tr bgcolor='#B9DCFF'>
39: * <th>Name</th>
40: * <th>Class</th>
41: * <th>Default value</th>
42: * <th>Minimum value</th>
43: * <th>Maximum value</th>
44: * </tr>
45: * <tr>
46: * <td>{@code "Source"}</td>
47: * <td>{@link org.geotools.coverage.grid.GridCoverage2D}</td>
48: * <td align="center">N/A</td>
49: * <td align="center">N/A</td>
50: * <td align="center">N/A</td>
51: * </tr>
52: * </table>
53: *
54: * @since 2.2
55: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/Invert.java $
56: * @version $Id: Invert.java 20970 2006-08-11 07:53:22Z jgarnett $
57: * @author Martin Desruisseaux
58: *
59: * @see org.geotools.coverage.processing.Operations#invert
60: * @see InvertDescriptor
61: */
62: public class Invert extends OperationJAI {
63: /**
64: * Serial number for interoperability with different versions.
65: */
66: private static final long serialVersionUID = 7297641092994880308L;
67:
68: /**
69: * Constructs a default {@code "Invert"} operation.
70: */
71: public Invert() {
72: super ("Invert");
73: }
74:
75: /**
76: * Returns the expected range of values for the resulting image.
77: */
78: protected NumberRange deriveRange(final NumberRange[] ranges,
79: final Parameters parameters) {
80: final NumberRange range = ranges[0];
81: final double min = -range.getMaximum();
82: final double max = -range.getMinimum();
83: return new NumberRange(min, max);
84: }
85: }
|