Skip to content

How to own a part of array, just like what OpenCV does? #1097

Description

@fzyzcjy

Hi thanks for the lib! I want to own a part of array, just like what OpenCV does. Consider the (simplified) code:

fn read_and_crop_image() -> ??? {
  let big_image: Array2<u8> = read_the_image();
  let cropped = big_image.slice(s![0..3000, 0..4000]);
  cropped // ERROR!!
}

However it errors, since ArrayView should not outlive the Array it belongs to. I have tried ArcArray but it does not seem to support .slice() as well.

With OpenCV I can do:

fn read_and_crop_image() -> Mat {
  let big_image: Mat = read_the_image();
  let cropped = Mat::roi([0..3000, 0..4000], big_image);
  cropped // no problem, it is another Mat, and underlying it is reference counting
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions