File IO

int32_t hv_hsi_file_append_sequential_axis(hv_hsi_file_t *file, hv_array_t *data)

Appends a new plane along the sequential axis in the HSIFile.

Parameters:
  • file – Mutable reference to the HSIFile.

  • data – Boxed 2D array to append.

Return values:
  • 0 – Ok

  • nonzero – Error

void hv_hsi_file_close(hv_hsi_file_t **file)

Closes and frees the memory associated with an HSIFile handle.

Parameters:

file – Output parameter for the HSIFile to close.

int32_t hv_hsi_file_create_empty(char const *path, slice_ref_size_t _plane_size, size_t n_planes, hv_interleave_t interleave, hv_dtype_t dtype, hv_hsi_file_t **_out)

Creates an empty hyperspectral image file with the specified parameters.

The file format is determined by the extension. Plane size must be 2D.

Parameters:
  • path – Path to the file to create.

  • _plane_size – Slice containing the plane dimensions (must be length 2).

  • n_planes – Number of planes.

  • interleave – Interleave mode.

  • dtype – Data type.

  • _out – Output parameter for the resulting HSIFile.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_extend(hv_hsi_file_t *file, size_t n_planes)

Extends the HSIFile by adding the specified number of planes.

Parameters:
  • file – Mutable reference to the HSIFile.

  • n_planes – Number of planes to add.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_plane(hv_hsi_file_t const *file, uint64_t index, hv_array_t **plane)

Reads a single image plane from the HSIFile at the given index.

Parameters:
  • file – Reference to the HSIFile.

  • index – Plane index to read.

  • plane – Output parameter for the resulting plane array.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_plane_crop(hv_hsi_file_t const *file, uint64_t index, hv_rect_t crop, hv_array_t **plane)

Reads a cropped region of a single image plane from the HSIFile.

Parameters:
  • file – Reference to the HSIFile.

  • index – Plane index to read.

  • crop – Rectangle specifying the crop region.

  • plane – Output parameter for the resulting cropped plane array.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_shrink(hv_hsi_file_t *file, size_t n_planes)

Shrinks the HSIFile by removing the specified number of planes.

Parameters:
  • file – Mutable reference to the HSIFile.

  • n_planes – - Number of planes to remove.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_write_array_plane(hv_hsi_file_t *file, uint64_t index, hv_array_t *data)

Writes a 2D array to a specific plane axis in the HSIFile.

Parameters:
  • file – Mutable reference to the HSIFile.

  • index – Plane index to write to.

  • data – Boxed 2D array to write.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_hsi_file_write_array_plane_multiple(hv_hsi_file_t *file, uint64_t index_start, hv_array_t *data)

Writes multiple planes (3D array) starting at the given index in the HSIFile.

Parameters:
  • file – Mutable reference to the HSIFile.

  • index_start – Starting plane index.

  • data – Boxed 3D array to write.

Return values:
  • 0 – Ok

  • nonzero – Error