Procs
proc read_image(buffer: seq[byte]): Tensor[uint8] {. ...raises: [STBIException, ValueError], tags: [], forbids: [].}
-
Read an image from a buffer and loads it into a Tensoruint8 of shape Channel x Height x Width. Channel is 1 for greyscale, 3 for RGB.
Supports JPEG, PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM See stb_image https://github.com/nothings/stb/blob/master/stb_image.h
Source Edit proc read_image(filepath: string): Tensor[uint8] {. ...raises: [STBIException, ValueError], tags: [], forbids: [].}
-
Read an image file and loads it into a Tensoruint8 of shape Channel x Height x Width. Channel is 1 for greyscale, 3 for RGB.
Supports JPEG, PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM See stb_image https://github.com/nothings/stb/blob/master/stb_image.h
Usage example with conversion to 0..1 float: .. code:: nim let raw_img = read_image('path/to/image.png') let img = raw_img.map_inline: x.float32 / 255.0
Source Edit