tech.v3.libs.buffered-image
Bindings to buffered images for the datatype system
as-ubyte-tensor
(as-ubyte-tensor img)
Get the buffered image as a uint8 tensor. Works for byte and integer-buffer backed images.
buffered-image->data-buffer
(buffered-image->data-buffer img)
Given a buffered image, return it's data buffer.
downsample-bilinear
(downsample-bilinear src-img & {:keys [dst-img-width dst-img-height dst-img-type]})
Reduce an image size using bilinear filtering. This is a buffered-image->buffered->image transformation.
draw-image!
(draw-image! src-img dst-image & {:keys [src-x-offset src-y-offset src-rect-width src-rect-height dst-x-offset dst-y-offset dst-rect-width dst-rect-height interpolation-type]})
Draw a source image onto a destination image. This can be used for scaling, cropping, or copying images.
image-channel-format
(image-channel-format img)
Get the image channel format of the buffered image. Formats returned may be: :gray :bgr :rgb :abgr :argb :abgr-pre :argb-pre
image-channel-map
(image-channel-map img)
Get a map from keyword channel name to channel index in a ubyte tensor
new-image
(new-image height width img-type)
Create a new buffered image. img-type is a keyword and must be one of the keys in the image-types map. ** Arguments are reverse of the buffered image constructor **
resize
(resize src-img new-width new-height {:keys [resize-algorithm dst-img-type]})
Resize an image. Options -
- resize-algorithm - One of #{:bilinear :cubic :nearest}. Defaults to - if the new width is larger than then old width, bilinear is chosen else nearest is chosen.
- dst-img-type - Defaults to the src image type. Should be one of the keys of image-types.
save!
(save! img format-str fname-or-stream)
(save! img fname-str)
Save an image. Format-str can be things like "PNG" or "JPEG". There are better versions of this in tech.io.
tensor->image
(tensor->image t options)
(tensor->image t)
Convert a tensor directly to a buffered image. The values will be interpreted as unsigned bytes in the range of 0-255.
Options:
:img-type
- Force a particular type of image type - see keys of image-types.