Image processing result:
Add the following code to ImageProcess. java:
[Java]
/*
* Histogram equalization
*/
Public Bitmap histEqualize (Bitmap myBitmap ){
// Create new array
Int width = myBitmap. getWidth ();
Int height = myBitmap. getHeight ();
Int [] pix = new int [width * height];
MyBitmap. getPixels (pix, 0, width, 0, 0, width, height );
Matrix dataR = getDataR (pix, width, height );
Matrix dataG = getDataG (pix, width, height );
Matrix dataB = getDataB (pix, width, height );
// Matrix transport Ray = gettransport Ray (pix, width, height );
//////////////////////////////////////// /////////////////
DataR = eachEqualize (dataR, width, height );
DataG = eachEqualize (dataG, width, height );
DataB = eachEqualize (dataB, width, height );
//////////////////////////////////////// ///////////////////////
// Change bitmap to use new array
Bitmap bitmap = makeToBitmap (dataR, dataG, dataB, width, height );
MyBitmap = null;
Pix = null;
Return bitmap;
}
Private Matrix eachEqualize (Matrix temp, int width, int height ){
// Grayscale ing table
Int bMap [] = new int [256];
// Grayscale ing table
Int lCount [] = new int [256];
// Reset the count to 0
Int I, j;
For (I = 0; I <256; I ++ ){
// Clear
LCount [I] = 0;
}
// Calculate the Count of each grayscale value-reference the grayscale histogram drawing code (in the dialog box)
For (I = 0; I For (j = 0; j <width; j ++ ){
LCount [(int) temp. get (I, j)] ++; // count plus 1
}
}
// Calculate the grayscale ing table
For (I = 0; I <256; I ++ ){
// The initial value is 0.
Int Temp = 0;
For (j = 0; j <= I; j ++ ){
Temp + = lCount [j];
}
// Calculate the corresponding new gray value
BMap [I] = (int) (Temp * 255/height/width );
}
// Each line
For (I = 0; I // Each column
For (j = 0; j <width; j ++ ){
Temp. set (I, j, bMap [(int) temp. get (I, j)]);
}
}
Return temp;
}