org.eclipse.january.dataset

## Class RGBByteDataset

- java.lang.Object
- - org.eclipse.january.dataset.LazyDatasetBase
  - - org.eclipse.january.dataset.AbstractDataset
    - - org.eclipse.january.dataset.AbstractCompoundDataset
      - - org.eclipse.january.dataset.CompoundByteDataset
        - - org.eclipse.january.dataset.RGBByteDataset

- All Implemented Interfaces:
    Serializable, Cloneable, CompoundDataset, Dataset, IDataset, ILazyDataset, IMetadataProvider, INameable

      public class RGBByteDataset
      extends CompoundByteDataset
      implements Cloneable

  Class to hold colour datasets as red, green, blue tuples of byte integers. Note that the values are treated as unsigned integers
  Since:
    2.3
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.january.dataset.CompoundByteDataset

      `data`

    - ### Fields inherited from class org.eclipse.january.dataset.AbstractCompoundDataset

      `isize`

    - ### Fields inherited from class org.eclipse.january.dataset.AbstractDataset

      `base, BLOCK_CLOSE, BLOCK_OPEN, ELLIPSIS, odata, offset, size, stride, stringFormat`

    - ### Fields inherited from class org.eclipse.january.dataset.LazyDatasetBase

      `metadata, name, shape`

    - ### Fields inherited from interface org.eclipse.january.dataset.Dataset

      `ARRAYFLOAT32, ARRAYFLOAT64, ARRAYINT16, ARRAYINT32, ARRAYINT64, ARRAYINT8, ARRAYMUL, BOOL, COMPLEX, COMPLEX128, COMPLEX64, DATE, FLOAT, FLOAT32, FLOAT64, INT, INT16, INT32, INT64, INT8, OBJECT, RGB, RGB8, STRING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RGBByteDataset()` Create a null dataset
    `RGBByteDataset(byte[] redData, byte[] greenData, byte[] blueData, int... shape)` Create a dataset using given data (red, green and blue parts are given separately)
    `RGBByteDataset(byte[] data, int... shape)`
    `RGBByteDataset(CompoundDataset colour)` Create a dataset using given compound data
    `RGBByteDataset(Dataset grey)` Create a dataset using given grey data
    `RGBByteDataset(Dataset red, Dataset green, Dataset blue)` Create a dataset using given colour data (colour components are given separately)
    `RGBByteDataset(int... shape)`
    `RGBByteDataset(int[] redData, int[] greenData, int[] blueData, int... shape)` Create a dataset using given data (red, green and blue parts are given separately)
    `RGBByteDataset(RGBByteDataset dataset)` Copy a dataset
    `RGBByteDataset(short[] redData, short[] greenData, short[] blueData, int... shape)` Create a dataset using given data (red, green and blue parts are given separately)

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `RGBByteDataset` | `clone()` Clone dataset
    `<T extends Dataset> T` | `createBlueDataset(Class<T> clazz)` Extract blue colour channel
    `Dataset` | `createBlueDataset(int dtype)` Deprecated. Use `createBlueDataset(java.lang.Class<T>)`
    `static RGBByteDataset` | `createFromCompoundDataset(CompoundDataset a)` Create a RGB dataset from a compound dataset (no normalisation performed)
    `static RGBByteDataset` | `createFromHSL(Dataset hue, Dataset saturation, Dataset lightness)` Create a RGB dataset from hue, saturation and lightness dataset
    `static RGBByteDataset` | `createFromHSV(Dataset hue, Dataset saturation, Dataset value)` Create a RGB dataset from hue, saturation and value dataset
    `static RGBByteDataset` | `createFromObject(Object obj)` Create a RGB dataset from an object which could be a Java list, array (of arrays...) or Number.
    `<T extends Dataset> T` | `createGreenDataset(Class<T> clazz)` Extract green colour channel
    `Dataset` | `createGreenDataset(int dtype)` Deprecated. Use `createGreenDataset(java.lang.Class<T>)`
    `<T extends Dataset> T` | `createGreyDataset(Class<T> clazz)` Convert colour dataset to a grey-scale one using the NTSC formula, aka ITU-R BT.601, for RGB to luma mapping
    `<T extends Dataset> T` | `createGreyDataset(Class<T> clazz, double red, double green, double blue)` Convert colour dataset to a grey-scale one using given RGB to luma mapping
    `Dataset` | `createGreyDataset(double red, double green, double blue, int dtype)` Deprecated. Use `createGreyDataset(Class, double, double, double)`
    `Dataset` | `createGreyDataset(int dtype)` Deprecated. Use `createGreyDataset(Class)`
    `<T extends Dataset> T` | `createRedDataset(Class<T> clazz)` Extract red colour channel
    `Dataset` | `createRedDataset(int dtype)` Deprecated. Use `createRedDataset(java.lang.Class<T>)`
    `byte` | `getBlue()`
    `byte` | `getBlue(int... pos)`
    `byte` | `getBlue(int i)`
    `byte` | `getBlue(int i, int j)`
    `byte` | `getBlueAbs(int n)` Get a blue value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
    `ByteDataset` | `getBlueView()`
    `double` | `getElementDoubleAbs(int index)` Get an element from given absolute index as a double.
    `long` | `getElementLongAbs(int index)` Get an element from given absolute index as a long.
    `byte` | `getGreen()`
    `byte` | `getGreen(int... pos)`
    `byte` | `getGreen(int i)`
    `byte` | `getGreen(int i, int j)`
    `byte` | `getGreenAbs(int n)` Get a green value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
    `ByteDataset` | `getGreenView()`
    `byte` | `getRed()`
    `byte` | `getRed(int... pos)`
    `byte` | `getRed(int i)`
    `byte` | `getRed(int i, int j)`
    `byte` | `getRedAbs(int n)` Get a red value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
    `ByteDataset` | `getRedView()`
    `RGBByteDataset` | `getSlice(SliceIterator siter)` Get a slice of the dataset.
    `RGBByteDataset` | `getView(boolean deepCopyMetadata)`
    `Number` | `max(boolean... ignored)`
    `Number` | `min(boolean... ignored)`

    - ### Methods inherited from class org.eclipse.january.dataset.CompoundByteDataset

      `asNonCompoundDataset, containsInfs, containsInvalidNumbers, containsNans, copyElements, copyItemsFromAxes, createArray, createCompoundDatasetWithLastDimension, createFromObject, equals, fill, fillDataset, getAbs, getAbs, getBufferLength, getByteArray, getByteArray, getByteArray, getByteArray, getData, getDoubleArray, getDoubleArray, getDoubleArray, getDoubleArray, getDoubleArrayAbs, getElementBooleanAbs, getElements, getElementsView, getFirstValue, getFirstValue, getFirstValue, getFirstValue, getFloatArray, getFloatArray, getFloatArray, getFloatArray, getIntArray, getIntArray, getIntArray, getIntArray, getLongArray, getLongArray, getLongArray, getLongArray, getObject, getObject, getObject, getObject, getObjectAbs, getShortArray, getShortArray, getShortArray, getShortArray, getString, getString, getString, getString, getStringAbs, hashCode, iadd, idivide, ifloor, imultiply, ipower, iremainder, isubtract, residual, resize, set, set, set, set, setAbs, setAbs, setBy1DIndex, setByBoolean, setByIndexes, setData, setElements, setItem, setItem, setItem, setItem, setItemDirect, setItemsOnAxes, setObjectAbs, setSlice`

    - ### Methods inherited from class org.eclipse.january.dataset.AbstractCompoundDataset

      `argMax, argMin, cast, cast, flatten, get1DIndex, get1DIndex, get1DIndexFromShape, getBoolean, getBoolean, getBoolean, getBoolean, getBroadcastView, getBy1DIndex, getByBoolean, getByIndexes, getByte, getByte, getByte, getByte, getCompoundStats, getDouble, getDouble, getDouble, getDouble, getDoubleArray, getDoubleArray, getDoubleArray, getDoubleArray, getElementsPerItem, getError, getError, getError, getErrorArray, getErrorArray, getErrorArray, getErrors, getFloat, getFloat, getFloat, getFloat, getInt, getInt, getInt, getInt, getIterator, getIterator, getLong, getLong, getLong, getLong, getShort, getShort, getShort, getShort, getSlice, getSlice, getSlice, getSlice, getSlice, getSlice, getSliceView, getSliceView, getSliceView, getTransposedView, getUniqueItems, ifloorDivide, internalGetSliceIterator, max, maxItem, maxPos, mean, mean, min, minItem, minPos, peakToPeak, product, reshape, rootMeanSquare, rootMeanSquare, setSlice, setSlice, sort, squeeze, squeeze, squeezeEnds, stdDeviation, stdDeviation, sum, sum, swapAxes, synchronizedCopy, transpose, variance, variance, variance`

    - ### Methods inherited from class org.eclipse.january.dataset.AbstractDataset

      `all, all, any, any, argMax, argMin, calcSteps, cast, cast, checkAxis, checkAxis, checkCompatibility, copy, copy, copyToView, count, count, count, createStrides, createStrides, createStrides, createStrides, fillData, get1DIndex, get1DIndexFromShape, getBooleanIterator, getBooleanIterator, getBuffer, getDType, getElementClass, getError, getErrorBuffer, getFirst1DIndex, getIndices, getInternalSquaredError, getItemBytes, getIterator, getMaxLineLength, getNbytes, getNDPosition, getOffset, getPositionIterator, getRank, getRealPart, getRealView, getShape, getShapeRef, getSize, getSliceIterator, getSliceIterator, getSliceIteratorFromAxes, getStats, getStrides, getStringStats, hasFloatingPointElements, isCompatibleWith, isComplex, max, mean, min, overrideInternal, peakToPeak, peakToPeak, product, product, residual, residual, rootMeanSquare, setErrorBuffer, setMaxLineLength, setShape, setSlice, setStringFormat, stdDeviation, stdDeviation, stdDeviation, stdDeviation, sum, toString, toString, variance, variance, variance`

    - ### Methods inherited from class org.eclipse.january.dataset.LazyDatasetBase

      `addMetadata, checkPermutatedAxes, checkSliceND, clearMetadata, copyMetadata, copyMetadata, createFromSerializable, dirtyMetadata, findMetadataTypeSubInterfaces, getErrorMetadata, getFirstMetadata, getMetadata, getMetadata, getMetadataMap, getName, hasErrors, reshapeMetadata, restoreMetadata, setDirty, setErrors, setMetadata, setName, sliceMetadata, transposeMetadata`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.january.dataset.Dataset

      `all, all, any, any, argMax, argMin, cast, cast, checkAxis, checkCompatibility, copy, copy, count, count, count, get1DIndex, getBooleanIterator, getBooleanIterator, getBuffer, getDType, getError, getErrorBuffer, getIndices, getIterator, getNbytes, getNDPosition, getOffset, getPositionIterator, getRealPart, getRealView, getShapeRef, getSliceIterator, getSliceIterator, getSliceIteratorFromAxes, getStrides, hasFloatingPointElements, isCompatibleWith, isComplex, max, mean, min, overrideInternal, peakToPeak, peakToPeak, product, product, residual, residual, rootMeanSquare, setDirty, setErrorBuffer, setSlice, stdDeviation, stdDeviation, stdDeviation, stdDeviation, sum, toString, variance, variance, variance`

    - ### Methods inherited from interface org.eclipse.january.dataset.IDataset

      `getItemBytes, getMetadata, setStringFormat`

    - ### Methods inherited from interface org.eclipse.january.dataset.ILazyDataset

      `addMetadata, clearMetadata, getElementClass, getRank, getShape, getSize, hasErrors, setErrors, setMetadata, setShape`

    - ### Methods inherited from interface org.eclipse.january.dataset.IMetadataProvider

      `getFirstMetadata, getMetadata`

    - ### Methods inherited from interface org.eclipse.january.INameable

      `getName, setName`

- - ### Constructor Detail

    - #### RGBByteDataset

          public RGBByteDataset()

      Create a null dataset

    - #### RGBByteDataset

          public RGBByteDataset(int... shape)

      Parameters:
        `shape` - output shape

    - #### RGBByteDataset

          public RGBByteDataset(byte[] data,
                                int... shape)

      Parameters:
        `data` - interleaved RGB values
        `shape` - output shape

    - #### RGBByteDataset

          public RGBByteDataset(RGBByteDataset dataset)

      Copy a dataset
      Parameters:
        `dataset` - to clone

    - #### RGBByteDataset

          public RGBByteDataset(int[] redData,
                                int[] greenData,
                                int[] blueData,
                                int... shape)

      Create a dataset using given data (red, green and blue parts are given separately)
      Parameters:
        `redData` - data for red
        `greenData` - data for green
        `blueData` - data for blue
        `shape` - (can be null to create 1D dataset)

    - #### RGBByteDataset

          public RGBByteDataset(short[] redData,
                                short[] greenData,
                                short[] blueData,
                                int... shape)

      Create a dataset using given data (red, green and blue parts are given separately)
      Parameters:
        `redData` - data for red
        `greenData` - data for green
        `blueData` - data for blue
        `shape` - (can be null to create 1D dataset)

    - #### RGBByteDataset

          public RGBByteDataset(byte[] redData,
                                byte[] greenData,
                                byte[] blueData,
                                int... shape)

      Create a dataset using given data (red, green and blue parts are given separately)
      Parameters:
        `redData` - data for red
        `greenData` - data for green
        `blueData` - data for blue
        `shape` - (can be null to create 1D dataset)

    - #### RGBByteDataset

          public RGBByteDataset(Dataset red,
                                Dataset green,
                                Dataset blue)

      Create a dataset using given colour data (colour components are given separately)
      Parameters:
        `red` - dataset
        `green` - dataset
        `blue` - dataset

    - #### RGBByteDataset

          public RGBByteDataset(Dataset grey)

      Create a dataset using given grey data
      Parameters:
        `grey` - dataset

    - #### RGBByteDataset

          public RGBByteDataset(CompoundDataset colour)

      Create a dataset using given compound data
      Parameters:
        `colour` - dataset with colour data

  - ### Method Detail

    - #### clone

          public RGBByteDataset clone()

      Description copied from interface: `ILazyDataset`
      Clone dataset
      Specified by:
        `clone` in interface `CompoundDataset`
      Specified by:
        `clone` in interface `Dataset`
      Specified by:
        `clone` in interface `IDataset`
      Specified by:
        `clone` in interface `ILazyDataset`
      Overrides:
        `clone` in class `CompoundByteDataset`
      Returns:
        a (shallow) copy of dataset

    - #### createFromObject

          public static RGBByteDataset createFromObject(Object obj)

      Create a RGB dataset from an object which could be a Java list, array (of arrays...) or Number. Ragged sequences or arrays are padded with zeros. The item size is the last dimension of the corresponding elemental dataset
      Parameters:
        `obj` - object
      Returns:
        dataset with contents given by input

    - #### createFromCompoundDataset

          public static RGBByteDataset createFromCompoundDataset(CompoundDataset a)

      Create a RGB dataset from a compound dataset (no normalisation performed)
      Parameters:
        `a` - dataset
      Returns:
        RGB dataset (grey if input dataset has less than 3 elements per item)

    - #### createFromHSV

          public static RGBByteDataset createFromHSV(Dataset hue,
                                                     Dataset saturation,
                                                     Dataset value)

      Create a RGB dataset from hue, saturation and value dataset
      Parameters:
        `hue` - (in degrees from -360 to 360)
        `saturation` - (from 0 to 1), can be null to denote 1
        `value` - (from 0 to 1)
      Returns:
        RGB dataset

    - #### createFromHSL

          public static RGBByteDataset createFromHSL(Dataset hue,
                                                     Dataset saturation,
                                                     Dataset lightness)

      Create a RGB dataset from hue, saturation and lightness dataset
      Parameters:
        `hue` - (in degrees from -360 to 360)
        `saturation` - (from 0 to 1), can be null to denote 1
        `lightness` - (from 0 to 1)
      Returns:
        RGB dataset

    - #### getSlice

          public RGBByteDataset getSlice(SliceIterator siter)

      Description copied from class: `AbstractDataset`
      Get a slice of the dataset. The returned dataset is a copied selection of items
      Overrides:
        `getSlice` in class `CompoundByteDataset`
      Parameters:
        `siter` - Slice iterator
      Returns:
        The dataset of the sliced data

    - #### getView

          public RGBByteDataset getView(boolean deepCopyMetadata)

      Specified by:
        `getView` in interface `CompoundDataset`
      Specified by:
        `getView` in interface `Dataset`
      Overrides:
        `getView` in class `CompoundByteDataset`
      Parameters:
        `deepCopyMetadata` - if true then deep-copy metadata
      Returns:
        whole view of dataset (i.e. data buffer is shared)

    - #### getRed

          public byte getRed()

      Returns:
        red value in the first position

    - #### getRed

          public byte getRed(int i)

      Parameters:
        `i` - position in first dimension
      Returns:
        red value in given position

    - #### getRed

          public byte getRed(int i,
                             int j)

      Parameters:
        `i` - position in first dimension
        `j` - position in second dimension
      Returns:
        red value in given position

    - #### getRed

          public byte getRed(int... pos)

      Parameters:
        `pos` - position
      Returns:
        red value in given position

    - #### getGreen

          public byte getGreen()

      Returns:
        green value in the first position

    - #### getGreen

          public byte getGreen(int i)

      Parameters:
        `i` - position in first dimension
      Returns:
        green value in given position

    - #### getGreen

          public byte getGreen(int i,
                               int j)

      Parameters:
        `i` - position in first dimension
        `j` - position in second dimension
      Returns:
        green value in given position

    - #### getGreen

          public byte getGreen(int... pos)

      Parameters:
        `pos` - position
      Returns:
        green value in given position

    - #### getBlue

          public byte getBlue()

      Returns:
        blue value in the first position

    - #### getBlue

          public byte getBlue(int i)

      Parameters:
        `i` - position in first dimension
      Returns:
        blue value in given position

    - #### getBlue

          public byte getBlue(int i,
                              int j)

      Parameters:
        `i` - position in first dimension
        `j` - position in second dimension
      Returns:
        blue value in given position

    - #### getBlue

          public byte getBlue(int... pos)

      Parameters:
        `pos` - position
      Returns:
        blue value in given position

    - #### getRedAbs

          public byte getRedAbs(int n)

      Get a red value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
      Parameters:
        `n` - absolute index
      Returns:
        red value

    - #### getGreenAbs

          public byte getGreenAbs(int n)

      Get a green value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
      Parameters:
        `n` - absolute index
      Returns:
        green value

    - #### getBlueAbs

          public byte getBlueAbs(int n)

      Get a blue value from given absolute index as a byte - note this index does not take in account the item size so be careful when using with multi-element items
      Parameters:
        `n` - absolute index
      Returns:
        blue value

    - #### createGreyDataset

          public <T extends Dataset> T createGreyDataset(Class<T> clazz)

      Convert colour dataset to a grey-scale one using the NTSC formula, aka ITU-R BT.601, for RGB to luma mapping
      Type Parameters:
        `T` - dataset sub-interface
      Parameters:
        `clazz` - dataset sub-interface
      Returns:
        a grey-scale dataset of given type

    - #### createGreyDataset

          public <T extends Dataset> T createGreyDataset(Class<T> clazz,
                                                         double red,
                                                         double green,
                                                         double blue)

      Convert colour dataset to a grey-scale one using given RGB to luma mapping
      Type Parameters:
        `T` - dataset sub-interface
      Parameters:
        `clazz` - dataset sub-interface
        `red` - weight
        `green` - weight
        `blue` - weight
      Returns:
        a grey-scale dataset of given class

    - #### createGreyDataset

          @Deprecated
          public Dataset createGreyDataset(int dtype)

      Deprecated. Use `createGreyDataset(Class)`
      Convert colour dataset to a grey-scale one using the NTSC formula, aka ITU-R BT.601, for RGB to luma mapping
      Parameters:
        `dtype` - dataset type
      Returns:
        a grey-scale dataset of given class

    - #### createGreyDataset

          @Deprecated
          public Dataset createGreyDataset(double red,
                                                       double green,
                                                       double blue,
                                                       int dtype)

      Deprecated. Use `createGreyDataset(Class, double, double, double)`
      Convert colour dataset to a grey-scale one using given RGB to luma mapping
      Parameters:
        `red` - weight
        `green` - weight
        `blue` - weight
        `dtype` - dataset type
      Returns:
        a grey-scale dataset of given type

    - #### createRedDataset

          public <T extends Dataset> T createRedDataset(Class<T> clazz)

      Extract red colour channel
      Type Parameters:
        `T` - dataset sub-interface
      Parameters:
        `clazz` - dataset sub-interface
      Returns:
        a dataset of given class

    - #### createGreenDataset

          public <T extends Dataset> T createGreenDataset(Class<T> clazz)

      Extract green colour channel
      Type Parameters:
        `T` - dataset sub-interface
      Parameters:
        `clazz` - dataset sub-interface
      Returns:
        a dataset of given class

    - #### createBlueDataset

          public <T extends Dataset> T createBlueDataset(Class<T> clazz)

      Extract blue colour channel
      Type Parameters:
        `T` - dataset sub-interface
      Parameters:
        `clazz` - dataset sub-interface
      Returns:
        a dataset of given class

    - #### createRedDataset

          @Deprecated
          public Dataset createRedDataset(int dtype)

      Deprecated. Use `createRedDataset(java.lang.Class<T>)`
      Extract red colour channel
      Parameters:
        `dtype` - dataset type
      Returns:
        a dataset of given type

    - #### createGreenDataset

          @Deprecated
          public Dataset createGreenDataset(int dtype)

      Deprecated. Use `createGreenDataset(java.lang.Class<T>)`
      Extract green colour channel
      Parameters:
        `dtype` - dataset type
      Returns:
        a dataset of given type

    - #### createBlueDataset

          @Deprecated
          public Dataset createBlueDataset(int dtype)

      Deprecated. Use `createBlueDataset(java.lang.Class<T>)`
      Extract blue colour channel
      Parameters:
        `dtype` - dataset type
      Returns:
        a dataset of given type

    - #### getRedView

          public ByteDataset getRedView()

      Returns:
        red view

    - #### getGreenView

          public ByteDataset getGreenView()

      Returns:
        green view

    - #### getBlueView

          public ByteDataset getBlueView()

      Returns:
        blue view

    - #### getElementDoubleAbs

          public double getElementDoubleAbs(int index)

      Description copied from interface: `Dataset`
      Get an element from given absolute index as a double. See warning in interface doc
      Specified by:
        `getElementDoubleAbs` in interface `Dataset`
      Overrides:
        `getElementDoubleAbs` in class `CompoundByteDataset`
      Parameters:
        `index` - in array
      Returns:
        element as double

    - #### getElementLongAbs

          public long getElementLongAbs(int index)

      Description copied from interface: `Dataset`
      Get an element from given absolute index as a long. See warning in interface doc
      Specified by:
        `getElementLongAbs` in interface `Dataset`
      Overrides:
        `getElementLongAbs` in class `CompoundByteDataset`
      Parameters:
        `index` - in array
      Returns:
        element as long

    - #### max

          public Number max(boolean... ignored)

      Specified by:
        `max` in interface `IDataset`
      Overrides:
        `max` in class `AbstractCompoundDataset`
      Parameters:
        `ignored` - - Can be null, empty, or one or more booleans. By default, all booleans are false. If the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to ignore infinities separately.
      Returns:
        Maximum value

    - #### min

          public Number min(boolean... ignored)

      Specified by:
        `min` in interface `IDataset`
      Overrides:
        `min` in class `AbstractCompoundDataset`
      Parameters:
        `ignored` - - see `IDataset.max(boolean...)`
      Returns:
        Minimum value

Copyright © 2014–2022 Eclipse Foundation. All rights reserved.