pulsatrix
Loading...
Searching...
No Matches
pulsatrix::ImageDecoder Class Reference

Decodes an image file into a Tensor – pulsatrix's generalization beyond MnistIdxLoader's IDX-format-only precedent (campaign_exai_dl_library_data_pipeline, Phase 2). Powered by stb_image (public-domain, single-header, vendored via FetchContent – Decision Point 2): supports PNG/JPEG/BMP/GIF/TGA/HDR and more. More...

#include <image_decoder.hpp>

Static Public Member Functions

static Tensor DecodeFile (const std::string &path, DeviceBackend *backend, int desired_channels=0)
 

Detailed Description

Decodes an image file into a Tensor – pulsatrix's generalization beyond MnistIdxLoader's IDX-format-only precedent (campaign_exai_dl_library_data_pipeline, Phase 2). Powered by stb_image (public-domain, single-header, vendored via FetchContent – Decision Point 2): supports PNG/JPEG/BMP/GIF/TGA/HDR and more.

Note
stb_image.h itself is included only in image_decoder.cpp – this header never exposes stb's own types/symbols, keeping it out of pulsatrix's public API surface.

Member Function Documentation

◆ DecodeFile()

static Tensor pulsatrix::ImageDecoder::DecodeFile ( const std::string &  path,
DeviceBackend *  backend,
int  desired_channels = 0 
)
static
Parameters
pathPath to an image file, any stb_image-supported format.
backendBackend to allocate the output Tensor through. Not owned.
desired_channelsIf > 0, forces the decoded image to this many channels (stb_image converts as needed – e.g. an RGB source file with desired_channels=1 is converted to grayscale). 0 (default) keeps the file's own channel count.
Returns
Tensor of shape (1, channels, height, width) – matching MnistIdxLoader's existing per-sample batch-of-one convention – float32, pixel values normalized to [0,1].
Exceptions
std::runtime_errorif the file can't be opened or decoded – external boundary (file content, not an internal invariant).

The documentation for this class was generated from the following file: