FileDocCategorySizeDatePackage
LensShadingMap.javaAPI DocAndroid 5.1 API8895Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.params

LensShadingMap

public final class LensShadingMap extends Object
Immutable class for describing a {@code 4 x N x M} lens shading map of floats.
see
CaptureResult#STATISTICS_LENS_SHADING_CORRECTION_MAP

Fields Summary
public static final float
MINIMUM_GAIN_FACTOR
The 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.

param
elements An array of elements whose length is {@code RggbChannelVector.COUNT * rows * columns}
throws
IllegalArgumentException if the {@code elements} array length is invalid, if any of the subelems are not finite or less than {@value #MINIMUM_GAIN_FACTOR}, or if rows or columns is not positive
throws
NullPointerException if {@code elements} is {@code null}
hide


                                                                                                                                                            
              

        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 voidcopyGainFactors(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}.

param
destination an array big enough to hold at least {@link RggbChannelVector#COUNT} elements after the {@code offset}
param
offset a non-negative offset into the array
throws
NullPointerException If {@code destination} was {@code null}
throws
IllegalArgumentException If offset was negative
throws
ArrayIndexOutOfBoundsException If there's not enough room to write the elements at the specified destination and offset.
see
CaptureResult#STATISTICS_LENS_SHADING_MAP

        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 booleanequals(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}.

return
{@code true} if the objects were equal, {@code false} otherwise

        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 intgetColumnCount()
Get the number of columns in this map.

        return mColumns;
    
public floatgetGainFactor(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.

param
colorChannel color channel from {@code [R, Geven, Godd, B]}
param
column within the range [0, {@link #getColumnCount})
param
row within the range [0, {@link #getRowCount})
return
a gain factor >= {@value #MINIMUM_GAIN_FACTOR}
throws
IllegalArgumentException if any of the parameters was out of range
see
#RED
see
#GREEN_EVEN
see
#GREEN_ODD
see
#BLUE
see
#getRowCount
see
#getColumnCount

        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 intgetGainFactorCount()
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 RggbChannelVectorgetGainFactorVector(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}).

param
column within the range [0, {@link #getColumnCount})
param
row within the range [0, {@link #getRowCount})
return
an {@link RggbChannelVector} where each gain factor >= {@value #MINIMUM_GAIN_FACTOR}
throws
IllegalArgumentException if any of the parameters was out of range
see
#getRowCount
see
#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 intgetRowCount()
Get the number of rows in this map.

        return mRows;
    
public inthashCode()
{@inheritDoc}

        int elemsHash = HashCodeHelpers.hashCode(mElements);
        return HashCodeHelpers.hashCode(mRows, mColumns, elemsHash);