xxxxxxxxxx
//import image crate
use image::*;
pub fn init(path: &str) -> (Vec<i32>, Vec<i32>){
//get the image
let img = image::open(path).expect("File not found!");
//null x and y coordinates
let (mut non_null_x, mut non_null_y): (Vec<i32>, Vec<i32>) = (Vec::new(), Vec::new());
//check for null pixels
for pix in img.pixels() {
//I don't really get this line still it just works and that's awesome!
let check_null = i32::from_be_bytes(<[u8; 4]>::try_from(pix.2.channels()).expect("Why tho?!"));
//if check_null == 0 then the pixel is null(empty)
if check_null != 0{
//push the x and y values
non_null_x.push(pix.0.try_into().unwrap());
non_null_y.push(pix.1.try_into().unwrap());
}
}
//returns the postion of not null pixels in type: (Vec<i32>, Vec<i32>)
return (non_null_x, non_null_y);
}