"Android" image transform

Source: Internet
Author: User

SOURCE Download: http://download.csdn.net/detail/jsgaobiao/9510213

? "Experimental Purpose"

Image transformation using a n d r o ID system, including shape transformation and color transformation

– Image transformations: Translation transformations, scale transformations, rotation transformations, and so on.

– Color transform: Freeze effect, thaw effect, comic effect, feather effect, zoom blur effect, lomo effects, movie effect, etc.

? "Laboratory Equipment"

Android Studio 1.5.1

Xiaomi Pad (7.9 "): Android 4.4.4, 1536*2048 xhdpi

? "Experimental principle"

This experiment involves two kinds of transformations, the first is the image transformation, including:

Translation:

Rotating:

Scaling:

Wrong cut:

The second type of transformation is color transformation, including:

Comics: r= |g–b + G + r| * r/256

G = |b–g + B + r| * r/256

b = |b–g + B + r| * g/256

Frozen: r= R–g–b

G = G–b–r

B = B–r–g

Fusion: R = R * +/(G + B + 1)

G = g * +/(B +r + 1)

B = b * +/(R + G + 1)

Edge: two pixels adjacent to differential

As shown, the program provides two spinner options for the user to select the appropriate color transform and shape transformation, and displays the image in the main area of the screen.

In the implementation of the program, I will read the original image to save as bitmap, first to do color transformation, and then do shape transformation:

Specific shape transformations and color transformations are implemented according to the method given above.

Among them, the rotation, scaling, error-cutting three effects can be achieved by using the matrix type of the transformation function:

The translation effect is based on the formula: displacement by pixel.

The color transformation takes the freezing effect as an example:


The freezing effect is based on the formula: R = r–g–b;g = G–b–r;b = B–r–g

The RGB of the image is recalculated.

Since the RGB values for each pixel are stored in a binary format in an int type, I first store the color information of (i,j) pixels in the PIX, extract the values of their alpha,r,g,b,4 channels by bit operations, and then recalculate the RGB values of the images.

The effects of other color transformations can be calculated according to different formulas.

In the actual test, I found that the lack of the blue component of the picture, the use of the frozen formula effect is not good, will make the resulting image is very dark, so the effect of the transformation formula is still a certain defect.

? Summary

Through this experiment, I learned about the image transformation of the relevant algorithm and the use of Android image data structure, familiar with the Android System dropdown selection menu use. Increased programming experience in image processing.

"Android" image transform

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.