MCPcopy Create free account
hub / github.com/daniel-e/rustml / from_slice

Method from_slice

src/opencv/mod.rs:553–572  ·  view source on GitHub ↗
(v: &[u8], rows: usize, cols: usize)

Source from the content-addressed store, hash-verified

551 }
552
553 pub fn from_slice(v: &[u8], rows: usize, cols: usize) -> Option<GrayImage> {
554
555 if rows * cols != v.len() {
556 return None;
557 }
558
559 let siz = CvSize {
560 width: cols as c_int,
561 height: rows as c_int
562 };
563 // TODO background
564 let mut dst = GrayImage { iplimage: unsafe { cvCreateImage(siz, 8, 1) } };
565
566 for y in (0..rows) {
567 for x in (0..cols) {
568 dst.set_pixel(x, y, *v.get(y * cols + x).unwrap());
569 }
570 }
571 Some(dst)
572 }
573
574 pub fn from_raw(image: *const IplImage) -> GrayImage {
575

Callers

nothing calls this directly

Calls 3

set_pixelMethod · 0.80
getMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected