4

I want to access some pixels in my Mat. Below is an example.

How do I get similar effects in Java? I can not use function Mat.get(...) because returns double[]. Can anyone help?

In C++

Mat saturation;
float sat[256];
for(int i=0; i<256; i++) {
    sat[i]=saturation.at<float>(i,0);
}

In Java

Mat saturation = new Mat();
float[] sat = new float[256];
for(int i=0; i<256; i++){
    sat[i] = ???
}

1 Answers1

0

Create a float array of size 1, then call the get method with that array.

i.e.

float[] element = new float[1];
mat.get(row, column, element);

You can also get the entire row, or partial number of elements, if you create a bigger float[] array - as calling get will fill up the array.

Maverick Meerkat
  • 5,737
  • 3
  • 47
  • 66