How to contribute android-gpuimage

107c7e4625bacbe78ee562359d89b318?s=47 Yuji Koketsu
November 16, 2018

How to contribute android-gpuimage

107c7e4625bacbe78ee562359d89b318?s=128

Yuji Koketsu

November 16, 2018
Tweet

Transcript

  1. 12.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture;

    uniform highp float threshold; const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); void main() { highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); highp float luminance = dot(textureColor.rgb, W); highp float thresholdResult = step(luminance, threshold); highp vec3 finalColor = abs(thresholdResult - textureColor.rgb); gl_FragColor = vec4(finalColor, textureColor.w); } Operations/Shaders/Solarize_GLES.fsh
  2. 13.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ public static final String SOLARIZE_FRAGMENT_SHADER = ""

    + "varying highp vec2 textureCoordinate;\n" + "\n" + "uniform sampler2D inputImageTexture;\n" + "uniform highp float threshold;\n" + "\n" + "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" + "\n" + "void main()\n" + "{\n" + " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" + " highp float luminance = dot(textureColor.rgb, W);\n" + " highp float thresholdResult = step(luminance, threshold);\n" + " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" + " \n" + " gl_FragColor = vec4(finalColor, textureColor.w);\n" + "}"; /filter/GPUImageSolarizeFilter.java
  3. 14.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ public static final String SOLARIZE_FRAGMENT_SHADER = ""

    + "varying highp vec2 textureCoordinate;\n" + "\n" + "uniform sampler2D inputImageTexture;\n" + "uniform highp float threshold;\n" + "\n" + "const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);\n" + "\n" + "void main()\n" + "{\n" + " highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" + " highp float luminance = dot(textureColor.rgb, W);\n" + " highp float thresholdResult = step(luminance, threshold);\n" + " highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);\n" + " \n" + " gl_FragColor = vec4(finalColor, textureColor.w);\n" + "}"; /filter/GPUImageSolarizeFilter.java ม਺Λ४උ͢Δ
  4. 16.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 2. FilterΛ࣮૷͢Δ /filter/GPUImageSolarizeFilter.java @Override public void onInitialized() { super.onInitialized();

    setThreshold(threshold); } public void setThreshold(final float threshold) { this.threshold = threshold; setFloat(uniformThresholdLocation, threshold); } ֎෦͔Β஋Λ౉ͤΔΑ͏ʹ͢Δ
  5. 17.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt FilterTypeʹ௥Ճ private enum class FilterType {

    CONTRAST, GRAYSCALE, SHARPEN, SEPIA, SOBEL_EDGE_DETECTION, THRESHOLD_EDGE_DETECTION, THREE_X_THREE_CONVOLUTION, FILTER_GROUP, EMBOSS, …, SOLARIZE }
  6. 18.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ fun showDialog( context: Context, listener: (filter: GPUImageFilter)

    -> Unit ) { val filters = FilterList().apply { addFilter("Contrast", FilterType.CONTRAST) addFilter("Invert", FilterType.INVERT) addFilter("Pixelation", FilterType.PIXELATION) addFilter("Hue", FilterType.HUE) addFilter("Gamma", FilterType.GAMMA) addFilter("Brightness", FilterType.BRIGHTNESS) addFilter("Sepia", FilterType.SEPIA) addFilter("Grayscale", FilterType.GRAYSCALE) … addFilter("Solarize", FilterType.SOLARIZE) } … } sample/GPUImageFilterTools.kt FilterListʹ௥Ճ
  7. 19.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt ࡞ͬͨFilterΛબ୒Ͱ͖ΔΑ͏ʹ private fun createFilterForType(context: Context, type:

    FilterType): GPUImageFilter { return when (type) { FilterType.CONTRAST -> GPUImageContrastFilter(2.0f) FilterType.GAMMA -> GPUImageGammaFilter(2.0f) FilterType.INVERT -> GPUImageColorInvertFilter() FilterType.PIXELATION -> GPUImagePixelationFilter() FilterType.HUE -> GPUImageHueFilter(90.0f) FilterType.BRIGHTNESS -> GPUImageBrightnessFilter(1.5f) FilterType.GRAYSCALE -> GPUImageGrayscaleFilter() FilterType.LEVELS_FILTER_MIN -> GPUImageLevelsFilter() FilterType.HALFTONE -> GPUImageHalftoneFilter() FilterType.BILATERAL_BLUR -> GPUImageBilateralBlurFilter() FilterType.TRANSFORM2D -> GPUImageTransformFilter() … FilterType.SOLARIZE -> GPUImageSolarizeFilter() } }
  8. 22.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt AdjusterΫϥεΛ࡞੒ class FilterAdjuster(filter: GPUImageFilter) { …

    private inner class BilateralAdjuster(filter: GPUImageBilateralBlurFilter) : Adjuster<GPUImageBilateralBlurFilter>(filter) { override fun adjust(percentage: Int) { filter.setDistanceNormalizationFactor(range(percentage, 0.0f, 15.0f)) } } … private inner class SolarizeAdjuster(filter: GPUImageSolarizeFilter) : Adjuster<GPUImageSolarizeFilter>(filter) { override fun adjust(percentage: Int) { filter.setThreshold(range(percentage, 0.0f, 1.0f)) } } }
  9. 23.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 3. sampleͰࢼͤΔΑ͏ʹ͢Δ sample/GPUImageFilterTools.kt ࡞ͬͨAdjusterΛ௥Ճ class FilterAdjuster(filter: GPUImageFilter) { private

    val adjuster: Adjuster<out GPUImageFilter>? init { adjuster = when (filter) { … is GPUImageLevelsFilter -> LevelsMinMidAdjuster(filter) is GPUImageBilateralBlurFilter -> BilateralAdjuster(filter) is GPUImageTransformFilter -> RotateAdjuster(filter) is GPUImageSolarizeFilter -> SolarizeAdjuster(filter) else -> null } }
  10. 25.

    ࠓ͙͢Ͱ͖Δʂcontributeͷ࢓ํ 4. PRΛग़͢ - [x] Color Inversion - [x] Solarize

    - [x] Vibrance - [x] Highlight and Shadow Tint ࡞ͬͨFilterͷCheckboxΛ๨Εͣʹ㾎
  11. 28.