• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps A poor beginner ask "How to get pixel value of grayscale bitmap?"

I have converted color bitmap into grayscale bitmap using ColorMatrix.
After that, I would like to get the pixel value of the grayscale bitmap for performing histogram equalization.
It is expected 0-8 (8-bit grayscale), however, i get something like -13027271.

My code:

int[] pixels = new int[grayscaleBitmap.getWidth()*grayscaleBitmap.getHeight()];
grayscaleBitmap.getPixels(pixels, 0, grayscaleBitmap.getWidth(), 0, 0, grayscaleBitmap.getWidth(), grayscaleBitmap.getHeight());


I am a beginner in android and also in this forum. Somebody please help me.
 
Thank you jonbonazza. I should use byte[].

However, there is still some problem. The grayscale value seems expected to be (0-255). However, i get negative value like -124, -116, -100 in some pixel. What is that mean? How to solve this?
 
Back
Top Bottom