Skip to content

Commit

Permalink
第一版
Browse files Browse the repository at this point in the history
1.0版本的Indoor项目
  • Loading branch information
Thomas Left committed Jul 31, 2015
1 parent a7d9812 commit 1056cb2
Show file tree
Hide file tree
Showing 1,993 changed files with 72,487 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ImageFilterForAndroid/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
16 changes: 16 additions & 0 deletions ImageFilterForAndroid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties
33 changes: 33 additions & 0 deletions ImageFilterForAndroid/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ImageFilterForAndroid</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions ImageFilterForAndroid/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
18 changes: 18 additions & 0 deletions ImageFilterForAndroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="HaoRan.ImageFilter"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />

<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" >
<activity android:label="@string/app_name" android:launchMode="standard" android:name=".Main.ImageFilterMain" android:screenOrientation="portrait" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
2 changes: 2 additions & 0 deletions ImageFilterForAndroid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ImageFilterForAndroid
=====================
40 changes: 40 additions & 0 deletions ImageFilterForAndroid/proguard.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
12 changes: 12 additions & 0 deletions ImageFilterForAndroid/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-7
android.library=true
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImageFilterForAndroid/res/drawable/image.jpg
Binary file added ImageFilterForAndroid/res/drawable/texture1.png
Binary file added ImageFilterForAndroid/res/drawable/texture2.png
33 changes: 33 additions & 0 deletions ImageFilterForAndroid/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="visible"
android:orientation="vertical">
<Gallery
android:id="@+id/galleryFilter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:spacing="2px" />

</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/runtime"
android:text="图片渲染中......"
android:singleLine="true"
android:textColor="#666666"
android:textSize="14dip"
android:visibility="gone"
/>
<ImageView android:id="@+id/imgfilter"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:clickable="false" android:focusable="false" />

</LinearLayout>
7 changes: 7 additions & 0 deletions ImageFilterForAndroid/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="hello">Hello World!</string>
<string name="app_name">ImageFilterForAndroid</string>

</resources>
38 changes: 38 additions & 0 deletions ImageFilterForAndroid/src/HaoRan/ImageFilter/AutoAdjustFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* HaoRan ImageFilter Classes v0.1
* Copyright (C) 2012 Zhenjun Dai
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation.
*/


package HaoRan.ImageFilter;

/**
* ×Ô¶¯Ð£ÕýЧ¹û
* @author daizhj
*
*/
public class AutoAdjustFilter implements IImageFilter{
//@Override
public Image process(Image imageIn) {
HistogramEqualFilter hee = new HistogramEqualFilter();
hee.ContrastIntensity = 0.5f;
imageIn = hee.process(imageIn);

AutoLevelFilter ale = new AutoLevelFilter();
ale.Intensity = 0.5f;
return ale.process(imageIn);
}
}
140 changes: 140 additions & 0 deletions ImageFilterForAndroid/src/HaoRan/ImageFilter/AutoLevelFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* HaoRan ImageFilter Classes v0.1
* Copyright (C) 2012 Zhenjun Dai
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation.
*/

package HaoRan.ImageFilter;

/**
* 自动校正效果
* @author daizhj
*
*/
public class AutoLevelFilter implements IImageFilter{
public float Intensity = 1f;

private static float[] ComputeGamma(int[] lo, int[] md, int[] hi)
{
float[] array = new float[3];
for (int i = 0; i < 3; i++){
if (lo[i] < md[i] && md[i] < hi[i]) {
double log = Math.log1p(/*0.5, */(double) (((float) (md[i] - lo[i])) / ((float) (hi[i] - lo[i]))));
array[i] = (log > 10.0) ? ((float) 10.0) : ((log < 0.1) ? ((float) 0.1) : ((float) log));
}
else{
array[i] = 1f;
}
}
return array;
}

public int[] GetMeanColor(int[][] h)
{
float[] array = new float[3];
for (int i = 0; i < 3; i++) {
long sum1 = 0L;
long sum2 = 0L;
for (int j = 0; j < 256; j++){
sum1 += j * h[i][j];
sum2 += h[i][j];
}
array[i] = (sum2 == 0L) ? 0f : (((float) sum1) / ((float) sum2));
}
return new int[] { (((int) (array[0] + 0.5f)) & 255), (((int) (array[1] + 0.5f)) & 255), (((int) (array[2] + 0.5f)) & 255) };
}

public int[] GetPercentileColor(int[][] h, float fraction)
{
int[] array = new int[3];
for (int i = 0; i < 3; i++)
{
long sum1 = 0L;
long sum2 = 0L;
for (int j = 0; j < 256; j++) {
sum2 += h[i][j];
}
for (int k = 0; k < 256; k++) {
sum1 += h[i][k];
if (sum1 > (sum2 * fraction)) {
array[i] = k;
break;
}
}
}
return array;
}



//@Override
public Image process(Image imageIn) {
int[][] h = new int[3][256];
int[] array = new int[3];
int[] rgb = new int[] { 255, 255, 255 };
int[] bb = new int[256];
int[] gg = new int[256];
int[] rr = new int[256];
int intensity = (int) (this.Intensity * 255f);
int intensity_invert = 255 - intensity;
for (int x = 0; x < imageIn.getWidth() - 1; x++){
for (int y = 0; y < imageIn.getHeight() - 1; y++) {
h[0][imageIn.getRComponent(x, y)]++;
h[1][imageIn.getGComponent(x, y)]++;
h[2][imageIn.getBComponent(x, y)]++;
}
}
int[] percentileColor = GetPercentileColor(h, 0.005f);
int[] meanColor = GetMeanColor(h);
int[] hi = GetPercentileColor(h, 0.995f);
float[] gamma = ComputeGamma(percentileColor, meanColor, hi);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 256; j++){
int[] arr = new int[3];
for (int n = 0; n < 3; n++){
float percent = j - percentileColor[n];
if (percent < 0f){
arr[n] = array[n];
}
else if ((percent + percentileColor[n]) >= hi[n]){
arr[n] = rgb[n];
}
else {
double adjust = array[n] + ((rgb[n] - array[n]) * Math.pow((double) (percent / ((float) (hi[n] - percentileColor[n]))), (double) gamma[n]));
arr[n] = (adjust > 255.0) ? ((int) 255.0) : ((adjust < 0.0) ? ((int) 0.0) : ((int) adjust));
}
}
rr[j] = arr[0];
gg[j] = arr[1];
bb[j] = arr[2];
}
}
Image clone = imageIn.clone();
int r,g,b;
for (int x = 0; x < imageIn.getWidth() - 1; x++){
for (int y = 0; y < imageIn.getHeight() - 1; y++) {
r = clone.getRComponent(x, y);
g = clone.getGComponent(x, y);
b = clone.getBComponent(x, y);
r = (r * intensity_invert + rr[r] * intensity) >> 8;
g = (g * intensity_invert + gg[g] * intensity) >> 8;
b = (b * intensity_invert + bb[b] * intensity) >> 8;
imageIn.setPixelColor(x, y, r, g, b);
}
}
return imageIn;//做直方图模式增强
}

}
Loading

0 comments on commit 1056cb2

Please sign in to comment.