RggbChannelVectorpublic final class RggbChannelVector extends Object Immutable class to store a 4-element vector of floats indexable by a bayer RAW 2x2 pixel block. |
Fields Summary |
---|
public static final int | COUNTThe number of color channels in this vector. | public static final int | REDRed color channel in a bayer Raw pattern. | public static final int | GREEN_EVENGreen color channel in a bayer Raw pattern used by the even rows. | public static final int | GREEN_ODDGreen color channel in a bayer Raw pattern used by the odd rows. | public static final int | BLUEBlue color channel in a bayer Raw pattern. | private final float | mRed | private final float | mGreenEven | private final float | mGreenOdd | private final float | mBlue |
Constructors Summary |
---|
public RggbChannelVector(float red, float greenEven, float greenOdd, float blue)Create a new {@link RggbChannelVector} from an RGGB 2x2 pixel.
All pixel values are considered normalized within {@code [0.0f, 1.0f]}
(i.e. {@code 1.0f} could be linearized to {@code 255} if converting to a
non-floating point pixel representation).
All arguments must be finite; NaN and infinity is not allowed.
mRed = checkArgumentFinite(red, "red");
mGreenEven = checkArgumentFinite(greenEven, "greenEven");
mGreenOdd = checkArgumentFinite(greenOdd, "greenOdd");
mBlue = checkArgumentFinite(blue, "blue");
|
Methods Summary |
---|
public void | copyTo(float[] destination, int offset)Copy the vector into the destination in the order {@code [R, Geven, Godd, B]}.
checkNotNull(destination, "destination must not be null");
if (destination.length - offset < COUNT) {
throw new ArrayIndexOutOfBoundsException("destination too small to fit elements");
}
destination[offset + RED] = mRed;
destination[offset + GREEN_EVEN] = mGreenEven;
destination[offset + GREEN_ODD] = mGreenOdd;
destination[offset + BLUE] = mBlue;
| public boolean | equals(java.lang.Object obj)Check if this {@link RggbChannelVector} is equal to another {@link RggbChannelVector}.
Two vectors are only equal if and only if each of the respective elements is equal.
if (obj == null) {
return false;
} else if (this == obj) {
return true;
} else if (obj instanceof RggbChannelVector) {
final RggbChannelVector other = (RggbChannelVector) obj;
return mRed == other.mRed &&
mGreenEven == other.mGreenEven &&
mGreenOdd == other.mGreenOdd &&
mBlue == other.mBlue;
}
return false;
| public float | getBlue()Get the blue component.
return mBlue;
| public float | getComponent(int colorChannel)Get the component by the color channel index.
{@code colorChannel} must be one of {@link #RED}, {@link #GREEN_EVEN}, {@link #GREEN_ODD},
{@link #BLUE}.
if (colorChannel < 0 || colorChannel >= COUNT) {
throw new IllegalArgumentException("Color channel out of range");
}
switch (colorChannel) {
case RED:
return mRed;
case GREEN_EVEN:
return mGreenEven;
case GREEN_ODD:
return mGreenOdd;
case BLUE:
return mBlue;
default:
throw new AssertionError("Unhandled case " + colorChannel);
}
| public float | getGreenEven()Get the green (even rows) component.
return mGreenEven;
| public float | getGreenOdd()Get the green (odd rows) component.
return mGreenOdd;
| public final float | getRed()Get the red component.
return mRed;
| public int | hashCode(){@inheritDoc}
return Float.floatToIntBits(mRed) ^
Float.floatToIntBits(mGreenEven) ^
Float.floatToIntBits(mGreenOdd) ^
Float.floatToIntBits(mBlue);
| private java.lang.String | toShortString()Return the RggbChannelVector as a string in compact form.
{@code "{R:%f, G_even:%f, G_odd:%f, B:%f}"}, where each {@code %f}
respectively represents one of the the four color channels.
return String.format("{R:%f, G_even:%f, G_odd:%f, B:%f}",
mRed, mGreenEven, mGreenOdd, mBlue);
| public java.lang.String | toString()Return the RggbChannelVector as a string representation.
{@code "RggbChannelVector{R:%f, G_even:%f, G_odd:%f, B:%f}"}, where each
{@code %f} respectively represents one of the the four color channels.
return String.format("RggbChannelVector%s", toShortString());
|
|