I'm trying to Calculate the absolute difference in each CV_8UC3 colour channel, multiplied by the scale in Java using OpenCV 2.4.8!
I know that java doesn't use uchar and thought the closest in java was a String[]
But that didn't work, so I used a short then I got:
"error: cannot find symbol
short[] ptr_entry = image_entry.<short>ptr(row);
symbol: method <short>ptr(int) location: variable image_entry of type Mat
I tried the possibility trying to use the at method, but I couldn't get this to work in java!
for (int row = 0; row < image_entry.rows(); ++row)
{
short[] ptr_entry = image_entry.<short>ptr(row);
uchar[] ptr_compressed = image_compressed.<uchar>ptr(row);
uchar[] ptr_output = image_output.<uchar>ptr(row);
for (int col = 0; col < image_entry.cols(); col++)
{
// Calculation of the absolute difference in each color channel, multiplied by the scale
ptr_output[0] = Math.abs(ptr_entry[0] - ptr_compressed[0]) * scale;
ptr_output[1] = Math.abs(ptr_entry[1] - ptr_compressed[1]) * scale;
ptr_output[2] = Math.abs(ptr_entry[2] - ptr_compressed[2]) * scale;
ptr_entry += 3;
ptr_compressed += 3;
ptr_output += 3;
}
}
Any Suggestions?
Use the Mat.get()
function to access pixel data.
public int get(int row,int col, short[] data)
Read the OpenCV Java API documentation, it would prevent unnecessary posts here.