I'm using the arrayfire crate to open an image with af::load_image
. This gives me a f32
array that I can do some processing on. After I am done, I would like to save it as an u8
image using af::save_image
:
extern crate arrayfire as af;
fn main() {
let im = af::load_image("image".into(), false);
//let im2: af::Array = im.cast(); // Error: cannot infer type for T
//let im2: af::Array<DType::U8> = im.cast(); // Error: expected no type arguments
}
I can't figure out how to convert the array into a u8
type. I looked into the from
method but I have no idea how to use it.
The signature for cast
is cast<T: HasAfEnum>(&self) -> Array
Array
type doesn't have type parameters. It is the cast
method which has one. You need to provide type parameter to the cast
method using turbofish syntax ::<_>
let im2 = im.cast::<u8>();