pub struct ImageFrame { /* private fields */ }Expand description
Represents an image frame with pixel data and metadata for FEAGI vision processing.
An ImageFrame stores image data as a 3D array of f32 values along with information
about the color channel format and color space. The internal storage uses row-major
ordering (height, width, channels) for efficient processing.
Implementations§
Source§impl ImageFrame
impl ImageFrame
Sourcepub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels
pub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels
The internal memory layout used for storing pixel data
Sourcepub fn new(
channel_format: &ColorChannelLayout,
color_space: &ColorSpace,
xy_resolution: &ImageXYResolution,
) -> Result<ImageFrame, FeagiDataError>
pub fn new( channel_format: &ColorChannelLayout, color_space: &ColorSpace, xy_resolution: &ImageXYResolution, ) -> Result<ImageFrame, FeagiDataError>
Creates a new ImageFrame with the specified channel format, color space, and resolution.
§Arguments
channel_format- The color channel format for the image (GrayScale, RG, RGB, or RGBA)color_space- The color space of the image (Linear or Gamma)xy_resolution- The resolution of the image as a tuple of (width, height)
§Returns
A new ImageFrame instance with all pixels initialized to zero.
Sourcepub fn from_array(
input: Array3<f32>,
color_space: &ColorSpace,
source_memory_order: &MemoryOrderLayout,
) -> Result<ImageFrame, FeagiDataError>
pub fn from_array( input: Array3<f32>, color_space: &ColorSpace, source_memory_order: &MemoryOrderLayout, ) -> Result<ImageFrame, FeagiDataError>
Creates an ImageFrame from an existing ndarray with the specified color space.
§Arguments
input- A 3D array of f32 values representing the image pixelscolor_space- The color space of the image (Linear or Gamma)source_memory_order- The memory layout of the input array
§Returns
A Result containing either:
- Ok(ImageFrame) if the input array has a valid number of color channels (1-4)
- Err(DataProcessingError) if the number of color channels is invalid
Sourcepub fn from_image_frame_properties(
image_frame_properties: &ImageFrameProperties,
) -> Result<ImageFrame, FeagiDataError>
pub fn from_image_frame_properties( image_frame_properties: &ImageFrameProperties, ) -> Result<ImageFrame, FeagiDataError>
Creates a new ImageFrame from ImageFrameProperties specification.
Creates a new ImageFrame with all pixels initialized to zero, using the resolution, color space, and channel layout specified in the properties.
§Arguments
image_frame_properties- Properties specifying the desired image configuration
§Returns
A Result containing either:
- Ok(ImageFrame) if the frame was created successfully
- Err(FeagiDataError) if the properties specify invalid dimensions
Sourcepub fn do_resolutions_channel_depth_and_color_spaces_match(
a: &ImageFrame,
b: &ImageFrame,
) -> bool
pub fn do_resolutions_channel_depth_and_color_spaces_match( a: &ImageFrame, b: &ImageFrame, ) -> bool
Sourcepub fn is_array_valid_for_image_frame(array: &Array3<f32>) -> bool
pub fn is_array_valid_for_image_frame(array: &Array3<f32>) -> bool
Returns true if the given array has valid dimensions for an ImageFrame.
An array is considered valid if:
- It has between 1 and 4 color channels
- It has non-zero width and height
§Arguments
array- The array to validate
§Returns
True if the array dimensions are valid for an ImageFrame, false otherwise.
Sourcepub fn get_image_frame_properties(&self) -> ImageFrameProperties
pub fn get_image_frame_properties(&self) -> ImageFrameProperties
Returns the properties of this image frame.
Creates an ImageFrameProperties struct that describes this frame’s resolution, color space, and channel layout.
§Returns
An ImageFrameProperties struct containing this frame’s properties.
Sourcepub fn get_channel_layout(&self) -> &ColorChannelLayout
pub fn get_channel_layout(&self) -> &ColorChannelLayout
Returns a reference to the channel layout of this image.
§Returns
A reference to the ChannelLayout enum value representing the image’s color channel format.
Sourcepub fn get_color_space(&self) -> &ColorSpace
pub fn get_color_space(&self) -> &ColorSpace
Returns a reference to the color space of this image.
§Returns
A reference to the ColorSpace enum value representing the image’s color space.
Sourcepub fn get_color_channel_count(&self) -> usize
pub fn get_color_channel_count(&self) -> usize
Returns the number of color channels in this ImageFrame.
§Returns
The number of color channels as an usize:
- 1 for GrayScale
- 2 for RG
- 3 for RGB
- 4 for RGBA
Sourcepub fn get_pixels_view(&self) -> ArrayView3<'_, f32>
pub fn get_pixels_view(&self) -> ArrayView3<'_, f32>
Returns a read-only view of the pixel data.
This provides access to the underlying 3D ndarray of pixel values.
§Returns
An ArrayView3
Sourcepub fn get_xy_resolution(&self) -> ImageXYResolution
pub fn get_xy_resolution(&self) -> ImageXYResolution
Returns the resolution of the image in cartesian space (width, height)
§Returns
A tuple of (width, height) representing the image dimensions in pixels.
Sourcepub fn get_xyz_shape(&self) -> Dimensions
pub fn get_xyz_shape(&self) -> Dimensions
Returns the internal shape of the image array in row-major order.
The shape is returned as (height, width, channels) representing the dimensions of the internal ndarray storage.
§Returns
A tuple of (height, width, channels) representing the array dimensions.
pub fn get_number_elements(&self) -> usize
Sourcepub fn get_internal_data(&self) -> &Array3<f32>
pub fn get_internal_data(&self) -> &Array3<f32>
Returns a reference to the internal pixel data array.
Provides direct access to the underlying 3D array containing the pixel data. The array is organized as (height, width, channels) following row-major ordering.
§Returns
A reference to the Array3
§Safety
This method provides direct access to internal data. Modifying the array
through this reference could break invariants. Use get_internal_data_mut()
for safe mutable access.
Sourcepub fn get_internal_data_mut(&mut self) -> &mut Array3<f32>
pub fn get_internal_data_mut(&mut self) -> &mut Array3<f32>
Returns a mutable reference to the internal pixel data array.
Provides mutable access to the underlying 3D array containing the pixel data. Be cautious when using this as you can easily set the data to an invalid state!
§Returns
A mutable reference to the Array3
pub fn change_brightness( &mut self, brightness_factor: f32, ) -> Result<(), FeagiDataError>
pub fn change_contrast( &mut self, contrast_factor: f32, ) -> Result<(), FeagiDataError>
pub fn resize_nearest_neighbor( &mut self, target_width_height: ImageXYResolution, ) -> Result<(), FeagiDataError>
pub fn write_as_neuron_xyzp_data( &self, write_target: &mut CorticalMappedXYZPNeuronData, target_id: CorticalID, x_channel_offset: CorticalChannelIndex, ) -> Result<(), FeagiDataError>
Trait Implementations§
Source§impl Clone for ImageFrame
impl Clone for ImageFrame
Source§fn clone(&self) -> ImageFrame
fn clone(&self) -> ImageFrame
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more