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 byte quantity. The lookup table contains byte
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 ShortLookupTable
41 * @see LookupOp
42 */
43 public class ByteLookupTable extends LookupTable {
44
45 /**
46 * Constants
47 */
48
49 byte data[][];
50
51 /**
52 * Constructs a ByteLookupTable object from an array of byte
53 * arrays representing a lookup table for each
54 * band. The offset will be subtracted from 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 byte arrays representing a lookup
61 * table for each band
62 * @throws IllegalArgumentException if {@code offset} is
63 * is less than 0 or if the length of {@code data}
64 * is less than 1
65 */
66 public ByteLookupTable(int offset, byte data[][]) {
67 super(offset,data.length);
68 numComponents = data.length;
69 numEntries = data[0].length;
70 this.data = new byte[numComponents][];
71 // Allocate the array and copy the data reference
72 for (int i=0; i < numComponents; i++) {
73 this.data[i] = data[i];
74 }
75 }
76
77 /**
78 * Constructs a ByteLookupTable object from an array
79 * of bytes representing a lookup table to be applied to all
80 * bands. The offset will be subtracted from input
81 * values before indexing into the array.
82 * The data array is stored as a reference.
83 * @param offset the value subtracted from the input values
84 * before indexing into the array
85 * @param data an array of bytes
86 * @throws IllegalArgumentException if {@code offset} is
87 * is less than 0 or if the length of {@code data}
88 * is less than 1
89 */
90 public ByteLookupTable(int offset, byte data[]) {
91 super(offset,data.length);
92 numComponents = 1;
93 numEntries = data.length;
94 this.data = new byte[1][];
95 this.data[0] = data;
96 }
97
98 /**
99 * Returns the lookup table data by reference. If this ByteLookupTable
100 * was constructed using a single byte array, the length of the returned
101 * array is one.
102 * @return the data array of this {@code ByteLookupTable}.
103 */
104 public final byte[][] getTable(){
105 return data;
106 }
107
108 /**
109 * Returns an array of samples of a pixel, translated with the lookup
110 * 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 byte quantity. The lookup table contains byte
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 ShortLookupTable
41 * @see LookupOp
42 */
43 public class ByteLookupTable extends LookupTable {
44
45 /**
46 * Constants
47 */
48
49 byte[][] data;
50
51 /**
52 * Constructs a ByteLookupTable object from an array of byte
53 * arrays representing a lookup table for each
54 * band. The offset will be subtracted from 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 byte arrays representing a lookup
61 * table for each band
62 * @throws IllegalArgumentException if {@code offset} is
63 * is less than 0 or if the length of {@code data}
64 * is less than 1
65 */
66 public ByteLookupTable(int offset, byte[][] data) {
67 super(offset,data.length);
68 numComponents = data.length;
69 numEntries = data[0].length;
70 this.data = new byte[numComponents][];
71 // Allocate the array and copy the data reference
72 for (int i=0; i < numComponents; i++) {
73 this.data[i] = data[i];
74 }
75 }
76
77 /**
78 * Constructs a ByteLookupTable object from an array
79 * of bytes representing a lookup table to be applied to all
80 * bands. The offset will be subtracted from input
81 * values before indexing into the array.
82 * The data array is stored as a reference.
83 * @param offset the value subtracted from the input values
84 * before indexing into the array
85 * @param data an array of bytes
86 * @throws IllegalArgumentException if {@code offset} is
87 * is less than 0 or if the length of {@code data}
88 * is less than 1
89 */
90 public ByteLookupTable(int offset, byte[] data) {
91 super(offset,data.length);
92 numComponents = 1;
93 numEntries = data.length;
94 this.data = new byte[1][];
95 this.data[0] = data;
96 }
97
98 /**
99 * Returns the lookup table data by reference. If this ByteLookupTable
100 * was constructed using a single byte array, the length of the returned
101 * array is one.
102 * @return the data array of this {@code ByteLookupTable}.
103 */
104 public final byte[][] getTable(){
105 return data;
106 }
107
108 /**
109 * Returns an array of samples of a pixel, translated with the lookup
110 * table. The source and destination array can be the same array.
|