1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
29 /**
30 * This class defines a lookup table object. The output of a
31 * lookup operation using an object of this class is interpreted
32 * as an unsigned short quantity. The lookup table contains short
33 * data arrays for one or more bands (or components) of an image,
34 * and it contains an offset which will be subtracted from the
35 * input values before indexing the arrays. This allows an array
36 * smaller than the native data size to be provided for a
37 * constrained input. If there is only one array in the lookup
38 * table, it will be applied to all bands.
39 *
40 * @see ByteLookupTable
41 * @see LookupOp
42 */
43 public class ShortLookupTable extends LookupTable {
44
45 /**
46 * Constants
47 */
48
49 short data[][];
50
51 /**
52 * Constructs a ShortLookupTable object from an array of short
53 * arrays representing a lookup table for each
54 * band. The offset will be subtracted from the input
55 * values before indexing into the arrays. The number of
56 * bands is the length of the data argument. The
57 * data array for each band is stored as a reference.
58 * @param offset the value subtracted from the input values
59 * before indexing into the arrays
60 * @param data an array of short arrays representing a lookup
61 * table for each band
62 */
63 public ShortLookupTable(int offset, short data[][]) {
64 super(offset,data.length);
65 numComponents = data.length;
66 numEntries = data[0].length;
67 this.data = new short[numComponents][];
68 // Allocate the array and copy the data reference
69 for (int i=0; i < numComponents; i++) {
70 this.data[i] = data[i];
71 }
72 }
73
74 /**
75 * Constructs a ShortLookupTable object from an array
76 * of shorts representing a lookup table for each
77 * band. The offset will be subtracted from the input
78 * values before indexing into the array. The
79 * data array is stored as a reference.
80 * @param offset the value subtracted from the input values
81 * before indexing into the arrays
82 * @param data an array of shorts
83 */
84 public ShortLookupTable(int offset, short data[]) {
85 super(offset,data.length);
86 numComponents = 1;
87 numEntries = data.length;
88 this.data = new short[1][];
89 this.data[0] = data;
90 }
91
92 /**
93 * Returns the lookup table data by reference. If this ShortLookupTable
94 * was constructed using a single short array, the length of the returned
95 * array is one.
96 * @return ShortLookupTable data array.
97 */
98 public final short[][] getTable(){
99 return data;
100 }
101
102 /**
103 * Returns an array of samples of a pixel, translated with the lookup
104 * table. The source and destination array can be the same array.
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
29 /**
30 * This class defines a lookup table object. The output of a
31 * lookup operation using an object of this class is interpreted
32 * as an unsigned short quantity. The lookup table contains short
33 * data arrays for one or more bands (or components) of an image,
34 * and it contains an offset which will be subtracted from the
35 * input values before indexing the arrays. This allows an array
36 * smaller than the native data size to be provided for a
37 * constrained input. If there is only one array in the lookup
38 * table, it will be applied to all bands.
39 *
40 * @see ByteLookupTable
41 * @see LookupOp
42 */
43 public class ShortLookupTable extends LookupTable {
44
45 /**
46 * Constants
47 */
48
49 short[][] data;
50
51 /**
52 * Constructs a ShortLookupTable object from an array of short
53 * arrays representing a lookup table for each
54 * band. The offset will be subtracted from the input
55 * values before indexing into the arrays. The number of
56 * bands is the length of the data argument. The
57 * data array for each band is stored as a reference.
58 * @param offset the value subtracted from the input values
59 * before indexing into the arrays
60 * @param data an array of short arrays representing a lookup
61 * table for each band
62 */
63 public ShortLookupTable(int offset, short[][] data) {
64 super(offset,data.length);
65 numComponents = data.length;
66 numEntries = data[0].length;
67 this.data = new short[numComponents][];
68 // Allocate the array and copy the data reference
69 for (int i=0; i < numComponents; i++) {
70 this.data[i] = data[i];
71 }
72 }
73
74 /**
75 * Constructs a ShortLookupTable object from an array
76 * of shorts representing a lookup table for each
77 * band. The offset will be subtracted from the input
78 * values before indexing into the array. The
79 * data array is stored as a reference.
80 * @param offset the value subtracted from the input values
81 * before indexing into the arrays
82 * @param data an array of shorts
83 */
84 public ShortLookupTable(int offset, short[] data) {
85 super(offset,data.length);
86 numComponents = 1;
87 numEntries = data.length;
88 this.data = new short[1][];
89 this.data[0] = data;
90 }
91
92 /**
93 * Returns the lookup table data by reference. If this ShortLookupTable
94 * was constructed using a single short array, the length of the returned
95 * array is one.
96 * @return ShortLookupTable data array.
97 */
98 public final short[][] getTable(){
99 return data;
100 }
101
102 /**
103 * Returns an array of samples of a pixel, translated with the lookup
104 * table. The source and destination array can be the same array.
|