I don't know how to get the pixel value (0-255) of the coordinates you specified from the Mat type grayscale image on Android (Java).Please let me know if there are any available functions.
Also, I would appreciate it if you could tell me how to get pixel values from Bitmap in numeric form.
java android opencv
Retrieving the value of RGBA 0..255
from Bitmap
can be done using Bitmap#getPixel(x,y)
, for example:
//cf.https://stackoverflow.com/a/26960189/3501958
int color=bitmap.getPixel(x,y);
intred=Color.red(color);
int green=Color.green(color);
int blue=Color.blue(color);
int alpha=Color.alpha(color);
Log.d(TAG, String.format(
"(R,G,B,A)=(%3d,%3d,%3d,%3d),red,green,blue,alpha
));
I'm not familiar with Mat
format files, but once you convert them to Bitmap
, the rest is the same.In any Android program, the image files (whether PNG
or JPEG
) are basically operated in Bitmap
.
I haven't checked, but I found a code snippet called to convert Mat to Bitmap in OpenCV.
© 2024 OneMinuteCode. All rights reserved.