Android image processing 1.3
Finished project: Hand score: http://as.baidu.com/a/item? Docid = 2758385
This version is greatly updated. In terms of image processing, I introduced the matrix class in Java ). This class is composedHttp://math.nist.gov/javanumerics/jama/. The addition, subtraction, multiplication, transpose, inverse, Norm, and determinant of the matrix are implemented.AlgorithmAnd there are multiple constructors and methods to obtain matrix data. In image processing system 1.3, we save the RGB data of images as matrix, laying a solid foundation for subsequent algorithm expansion. We introduce the package import in imageprocess. java.
Jama. matrix; In order to encapsulate the image processing process, we encapsulate the obtained RGB modules into three member functions, respectively, and encapsulate the generated bitmap image into the maketobitmap function. And implements a 90-degree image flip algorithm.
@ Author: Zheng Haibo 2012-08-29 reprint please declare: http://blog.csdn.net/nuptboyzhb/article/details/7925994
Blog: http://blog.csdn.net/nuptboyzhb/article/details/7857366
Http://blog.csdn.net/nuptboyzhb/article/details/7852999
[Operation interface and result]
Obtain RGB and grayscaleCode:
[Java]
Private matrix getdatar (INT [] pix, int width, int height) {matrix DATAR = new matrix (width, height, 0.0 ); // apply pixel-by-pixel change int Index = 0; For (INT y = 0; y
Function Code for Rotating 90 degrees:
[Java]
Public bitmap rotate90 (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 vertex Ray = getdatagray (pix, width, height ); //////////////////////////////////////// /// // DATAR = DATAR. transpose (); datag = datag. transpose (); datab = datab. transpose (); //////////////////////////////////////// ////////////////////// change bitmap to use new array bitmap = maketobitmap (DATAR, datag, datab, width, height); mybitmap = NULL; pix = NULL; return bitmap ;}
Encapsulate the maketobitmap code:
[Java code]
Public bitmap rotate90 (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 vertex Ray = getdatagray (pix, width, height ); //////////////////////////////////////// /// // DATAR = DATAR. transpose (); datag = datag. transpose (); datab = datab. transpose (); //////////////////////////////////////// ////////////////////// change bitmap to use new array bitmap = maketobitmap (DATAR, datag, datab, width, height); mybitmap = NULL; pix = NULL; return bitmap ;}