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

Method pixels_from_mask_as_u8

src/opencv/mod.rs:633–653  ·  view source on GitHub ↗
(&self, i: &GrayImage)

Source from the content-addressed store, hash-verified

631 }
632
633 pub fn pixels_from_mask_as_u8(&self, i: &GrayImage) -> Option<Vec<u8>> {
634
635 if self.width() != i.width() || self.height() != i.height() {
636 return None;
637 }
638
639 let mut pixels: Vec<u8> = Vec::new();
640 unsafe {
641 for y in (0..self.height()) {
642 let s: *const c_char = (*self.iplimage).imagedata.offset(y as isize * self.widthstep() as isize);
643 let m: *const c_char = (*i.iplimage).imagedata.offset(y as isize * i.widthstep() as isize);
644 for x in (0..self.width()) {
645 if *m.offset(x as isize) != 0 {
646 pixels.push(*s.offset(x as isize) as u8);
647 }
648 }
649 }
650 }
651
652 Some(pixels)
653 }
654
655 // TODO test
656 pub fn rectangle(&self, x: usize, y: usize, width: usize, height: usize) -> Vec<u8> {

Callers 1

test_mask_imageFunction · 0.80

Calls 3

widthMethod · 0.80
heightMethod · 0.80
widthstepMethod · 0.80

Tested by 1

test_mask_imageFunction · 0.64