LensShadingMappublic final class LensShadingMap extends Object Immutable class for describing a {@code 4 x N x M} lens shading map of floats. |
Fields Summary |
---|
public static final float | MINIMUM_GAIN_FACTORThe smallest gain factor in this map.
All values in this map will be at least this large. | private final int | mRows | private final int | mColumns | private final float[] | mElements |
Constructors Summary |
---|
public LensShadingMap(float[] elements, int rows, int columns)Create a new immutable LensShadingMap instance.
The elements must be stored in a row-major order (fully packed).
This constructor takes over the array; do not write to the array afterwards.
mRows = checkArgumentPositive(rows, "rows must be positive");
mColumns = checkArgumentPositive(columns, "columns must be positive");
mElements = checkNotNull(elements, "elements must not be null");
if (elements.length != getGainFactorCount()) {
throw new IllegalArgumentException("elements must be " + getGainFactorCount() +
" length, received " + elements.length);
}
// Every element must be finite and >= 1.0f
checkArrayElementsInRange(elements, MINIMUM_GAIN_FACTOR, Float.MAX_VALUE, "elements");
|
Methods Summary |
---|
public void | copyGainFactors(float[] destination, int offset)Copy all gain factors in row-major order from this lens shading map into the destination.
Each gain factor will be >= {@link #MINIMUM_GAIN_FACTOR}.
checkArgumentNonnegative(offset, "offset must not be negative");
checkNotNull(destination, "destination must not be null");
if (destination.length + offset < getGainFactorCount()) {
throw new ArrayIndexOutOfBoundsException("destination too small to fit elements");
}
System.arraycopy(mElements, /*srcPos*/0, destination, offset, getGainFactorCount());
| public boolean | equals(java.lang.Object obj)Check if this LensShadingMap is equal to another LensShadingMap.
Two lens shading maps are equal if and only if they have the same rows/columns,
and all of their elements are {@link Object#equals equal}.
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (obj instanceof LensShadingMap) {
final LensShadingMap other = (LensShadingMap) obj;
return mRows == other.mRows
&& mColumns == other.mColumns
&& Arrays.equals(mElements, other.mElements);
}
return false;
| public int | getColumnCount()Get the number of columns in this map.
return mColumns;
| public float | getGainFactor(int colorChannel, int column, int row)Get a single color channel gain factor from this lens shading map by its row and column.
The rows must be within the range [0, {@link #getRowCount}),
the column must be within the range [0, {@link #getColumnCount}),
and the color channel must be within the range [0, {@value RggbChannelVector#COUNT}).
The channel order is {@code [R, Geven, Godd, B]}, where
{@code Geven} is the green channel for the even rows of a Bayer pattern, and
{@code Godd} is the odd rows.
if (colorChannel < 0 || colorChannel > COUNT) {
throw new IllegalArgumentException("colorChannel out of range");
} else if (column < 0 || column >= mColumns) {
throw new IllegalArgumentException("column out of range");
} else if (row < 0 || row >= mRows) {
throw new IllegalArgumentException("row out of range");
}
return mElements[colorChannel + (row * mColumns + column) * COUNT ];
| public int | getGainFactorCount()Get the total number of gain factors in this map.
A single gain factor contains exactly one color channel.
Use with {@link #copyGainFactors} to allocate a large-enough array.
return mRows * mColumns * COUNT;
| public RggbChannelVector | getGainFactorVector(int column, int row)Get a gain factor vector from this lens shading map by its row and column.
The rows must be within the range [0, {@link #getRowCount}),
the column must be within the range [0, {@link #getColumnCount}).
if (column < 0 || column >= mColumns) {
throw new IllegalArgumentException("column out of range");
} else if (row < 0 || row >= mRows) {
throw new IllegalArgumentException("row out of range");
}
final int offset = (row * mColumns + column) * COUNT;
final float red =
mElements[RED + offset];
final float greenEven =
mElements[GREEN_EVEN + offset];
final float greenOdd =
mElements[GREEN_ODD + offset];
final float blue =
mElements[BLUE + offset];
return new RggbChannelVector(red, greenEven, greenOdd, blue);
| public int | getRowCount()Get the number of rows in this map.
return mRows;
| public int | hashCode(){@inheritDoc}
int elemsHash = HashCodeHelpers.hashCode(mElements);
return HashCodeHelpers.hashCode(mRows, mColumns, elemsHash);
|
|