Skip to content

Commit

Permalink
fix: borrow the mask in fish head tail detector
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Jun 19, 2024
1 parent 5679ce3 commit 34cbe3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fish/fish_head_tail_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct FishHeadTailDetector {
}

impl FishHeadTailDetector {
pub fn find_head_tail(mask: Array2<u8>) -> Result<(Array1<usize>, Array1<usize>), HeadTailError> {
pub fn find_head_tail(mask: &Array2<u8>) -> Result<(Array1<usize>, Array1<usize>), HeadTailError> {
let nonzero: Array1<(i32, i32)> = mask
.indexed_iter()
.filter_map(|(index, &item)| if item != 0 {Some((index.0 as i32, index.1 as i32))} else { None })
Expand Down Expand Up @@ -244,7 +244,7 @@ mod tests {
fn test() {
let rust_img = image::io::Reader::open("./data/segmentations.png").unwrap().decode().unwrap().as_luma8().unwrap().clone();
let mask: ArrayBase<OwnedRepr<u8>, Dim<[usize; 2]>> = Array2::from_shape_vec((rust_img.height() as usize, rust_img.width() as usize), rust_img.as_raw().clone()).unwrap();
let res = FishHeadTailDetector::find_head_tail(mask).unwrap();
let res = FishHeadTailDetector::find_head_tail(&mask).unwrap();
assert_eq!(res, (array![1073, 1114], array![2317,1054]));
}
}

0 comments on commit 34cbe3e

Please sign in to comment.