Android image processing 1.3

Source: Internet
Author: User
Tags image flip

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 ;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.