Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access slices of a 3d matrix #824

Closed
turekg opened this issue Dec 4, 2019 · 1 comment
Closed

Cannot access slices of a 3d matrix #824

turekg opened this issue Dec 4, 2019 · 1 comment
Labels

Comments

@turekg
Copy link

turekg commented Dec 4, 2019

I am trying to get slices of a 3D image. In C++ this is done by passing an array of the ranges like:

Range ranges[3];
ranges[0] = Range::all();
ranges[1] = Range::all();
ranges[2] = Range(x,x+1) //within a for loop.
Mat 2dmat = 3dmat(ranges).clone();

But I can't see how to do this with import org.bytedeco.opencv.opencv_core.Mat;
The method apply in the above mentioned class says it takes an array of Ranges, but it actually does not:

   /**\overload
    @param ranges Array of selected ranges along each array dimension.
    */
    public native @ByVal @Name("operator ()") Mat apply( @Const Range ranges );
@turekg turekg closed this as completed Dec 4, 2019
@turekg turekg reopened this Dec 4, 2019
@saudet saudet added the question label Dec 5, 2019
@saudet
Copy link
Member

saudet commented Dec 5, 2019

Range is a Pointer, which provides functionality to access native arrays, so something like this will do what you need:

Range ranges = new Range(3);
ranges.position(0).put(Range.all());
ranges.position(1).put(Range.all());
ranges.position(2).put(new Range(x,x+1));
Mat 2dmat = 3dmat(ranges.position(0)).clone();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants