RGBBox
- class RGBBox(shape=(3,), *args, init_value=None, **kwargs)[source]
Bases:
BoxSpecialized box space for RGB image data with automatic constraints.
This class extends
Boxto provide a convenient space for RGB images, automatically enforcing uint8 dtype and [0, 255] value ranges. It validates that the shape includes exactly 3 channels for RGB data.- Parameters:
shape (tuple) – Shape of the image. Must include a dimension of size 3 for the RGB channels. Common formats: (H, W, 3) or (3, H, W).
init_value (np.ndarray, optional) – Initial RGB image. Must match shape and be uint8 dtype.
*args – Additional positional arguments passed to Box.
**kwargs – Additional keyword arguments passed to Box.
- Variables:
init_value (np.ndarray) – The initial RGB image.
value (np.ndarray) – The current RGB image.
Example
Create a space for 64x64 RGB images:
import numpy as np space = RGBBox( shape=(64, 64, 3), init_value=np.zeros((64, 64, 3), dtype=np.uint8) ) image = space.sample() # Random RGB image space.reset() # Returns to black image- Raises:
AssertionError – If shape does not contain a dimension of size 3.
Note
This space is useful for vision-based environments where images need to be sampled or tracked as part of environment configuration. The low, high, and dtype parameters are automatically set and cannot be overridden.