01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
05: * (C) 2003, 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;
18:
19: // J2SE and JAI dependencies
20: import java.util.Arrays;
21: import javax.media.jai.operator.BinarizeDescriptor;
22:
23: // OpenGIS dependencies
24: import org.opengis.coverage.processing.OperationNotFoundException;
25:
26: // Geotools dependencies
27: import org.geotools.coverage.Category;
28: import org.geotools.coverage.GridSampleDimension;
29:
30: /**
31: * Wraps any JAI operation producing a bilevel image. An example of such operation is
32: * {@link BinarizeDescriptor Binarize}.
33: *
34: * @since 2.2
35: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/processing/BilevelOperation.java $
36: * @version $Id: BilevelOperation.java 23211 2006-12-05 00:38:41Z desruisseaux $
37: * @author Martin Desruisseaux
38: */
39: public class BilevelOperation extends OperationJAI {
40: /**
41: * Serial number for interoperability with different versions.
42: */
43: private static final long serialVersionUID = 8975871552152978976L;
44:
45: /**
46: * The sample dimension for the resulting image.
47: */
48: private static final GridSampleDimension SAMPLE_DIMENSION = new GridSampleDimension(
49: "Bilevel SampleDimension", new Category[] { Category.FALSE,
50: Category.TRUE }, null);
51:
52: /**
53: * Constructs a bilevel operation with an OGC's name identical to the JAI name.
54: *
55: * @param name The JAI operation name.
56: * @throws OperationNotFoundException if no JAI descriptor was found for the given name.
57: */
58: public BilevelOperation(final String name)
59: throws OperationNotFoundException {
60: super (name);
61: }
62:
63: /**
64: * Derives the {@link GridSampleDimension}s for the destination image.
65: *
66: * @param bandLists Sample dimensions for each band in each source coverages.
67: * @param parameters The user-supplied parameters.
68: * @return The sample dimensions for each band in the destination image.
69: */
70: protected GridSampleDimension[] deriveSampleDimension(
71: final GridSampleDimension[][] bandLists,
72: final Parameters parameters) {
73: final GridSampleDimension[] bands = new GridSampleDimension[bandLists[0].length];
74: Arrays.fill(bands, SAMPLE_DIMENSION);
75: return bands;
76: }
77: }
|