ImageFrame

Struct ImageFrame 

Source
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

Source

pub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels

The internal memory layout used for storing pixel data

Source

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.

Source

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 pixels
  • color_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
Source

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
Source

pub fn do_resolutions_channel_depth_and_color_spaces_match( a: &ImageFrame, b: &ImageFrame, ) -> bool

Returns true if two ImageFrames have the same channel count, resolution, and color space.

§Arguments
  • a - First ImageFrame to compare
  • b - Second ImageFrame to compare
§Returns

True if both frames have identical channel count, resolution, and color space.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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
Source

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 containing the pixel data.

Source

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.

Source

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.

Source

pub fn get_number_elements(&self) -> usize

Source

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 containing the raw pixel data.

§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.

Source

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 containing the raw pixel data.

Source

pub fn change_brightness( &mut self, brightness_factor: f32, ) -> Result<(), FeagiDataError>

Source

pub fn change_contrast( &mut self, contrast_factor: f32, ) -> Result<(), FeagiDataError>

Source

pub fn resize_nearest_neighbor( &mut self, target_width_height: ImageXYResolution, ) -> Result<(), FeagiDataError>

Source

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

Source§

fn clone(&self) -> ImageFrame

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ImageFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ImageFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ImageFrame> for WrappedIOData

Source§

fn from(value: ImageFrame) -> Self

Converts to this type from the input type.
Source§

impl<'a> TryFrom<&'a WrappedIOData> for &'a ImageFrame

Source§

type Error = FeagiDataError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a WrappedIOData) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut WrappedIOData> for &'a mut ImageFrame

Source§

type Error = FeagiDataError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a mut WrappedIOData) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<WrappedIOData> for ImageFrame

Source§

type Error = FeagiDataError

The type returned in the event of a conversion error.
Source§

fn try_from(value: WrappedIOData) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.