-1

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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Ronny
  • 454
  • 4
  • 15
  • 3
    Please provide a [MCVE], otherwise we will be blindly guessing over what the concrete issue might be. – E_net4 Nov 13 '17 at 15:19

1 Answers1

1

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>();

red75prime
  • 3,733
  • 1
  • 16
  • 22