Skip to content

Commit

Permalink
Merge pull request #43 from charlesbedrosian/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Boos committed Jun 13, 2013
2 parents 45e4f51 + 82336aa commit 88d8c99
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2012 CyberAgent
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package jp.co.cyberagent.android.gpuimage;

import android.opengl.GLES20;

/**
* This uses a similar process as the GPUImageToonFilter, only it precedes the toon effect
* with a Gaussian blur to smooth out noise.
*/
public class GPUImageSmoothToonFilter extends GPUImageFilterGroup {
GPUImageGaussianBlurFilter blurFilter;
GPUImageToonFilter toonFilter;

/**
* setup & teardown
*/
public GPUImageSmoothToonFilter() {
// First pass: apply a variable Gaussian blur
blurFilter = new GPUImageGaussianBlurFilter();
addFilter(blurFilter);

// Second pass: run the Sobel edge detection on this blurred image, along with a posterization effect
toonFilter = new GPUImageToonFilter();
addFilter(toonFilter);

getFilters().add(blurFilter);

setBlurSize(0.5f);
setThreshold(0.2f);
setQuantizationLevels(10.0f);
}

/**
* Accessors
*/
public void setTexelWidth(float value) {
toonFilter.setTexelWidth(value);
}

public void setTexelHeight(float value) {
toonFilter.setTexelHeight(value);
}

public void setBlurSize(float value) {
blurFilter.setBlurSize(value);
}

public void setThreshold(float value) {
toonFilter.setThreshold(value);
}

public void setQuantizationLevels(float value) {
toonFilter.setQuantizationLevels(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static void showDialog(final Context context,
filters.addFilter("RGB Dilation", FilterType.RGB_DILATION);
filters.addFilter("Sketch", FilterType.SKETCH);
filters.addFilter("Toon", FilterType.TOON);
filters.addFilter("Smooth Toon", FilterType.SMOOTH_TOON);

filters.addFilter("Bulge Distortion", FilterType.BULGE_DISTORTION);
filters.addFilter("Glass Sphere", FilterType.GLASS_SPHERE);
Expand Down Expand Up @@ -254,6 +255,8 @@ private static GPUImageFilter createFilterForType(final Context context, final F
return new GPUImageSketchFilter();
case TOON:
return new GPUImageToonFilter();
case SMOOTH_TOON:
return new GPUImageSmoothToonFilter();

case BULGE_DISTORTION:
return new GPUImageBulgeDistortionFilter();
Expand Down Expand Up @@ -300,7 +303,7 @@ private enum FilterType {
SATURATION, EXPOSURE, HIGHLIGHT_SHADOW, MONOCHROME, OPACITY, RGB, WHITE_BALANCE, VIGNETTE, TONE_CURVE, BLEND_COLOR_BURN, BLEND_COLOR_DODGE, BLEND_DARKEN, BLEND_DIFFERENCE,
BLEND_DISSOLVE, BLEND_EXCLUSION, BLEND_SOURCE_OVER, BLEND_HARD_LIGHT, BLEND_LIGHTEN, BLEND_ADD, BLEND_DIVIDE, BLEND_MULTIPLY, BLEND_OVERLAY, BLEND_SCREEN, BLEND_ALPHA,
BLEND_COLOR, BLEND_HUE, BLEND_SATURATION, BLEND_LUMINOSITY, BLEND_LINEAR_BURN, BLEND_SOFT_LIGHT, BLEND_SUBTRACT, BLEND_CHROMA_KEY, BLEND_NORMAL, LOOKUP_AMATORKA,
GAUSSIAN_BLUR, CROSSHATCH, BOX_BLUR, CGA_COLORSPACE, DILATION, KUWAHARA, RGB_DILATION, SKETCH, TOON, BULGE_DISTORTION, GLASS_SPHERE, HAZE, LAPLACIAN, NON_MAXIMUM_SUPPRESSION,
GAUSSIAN_BLUR, CROSSHATCH, BOX_BLUR, CGA_COLORSPACE, DILATION, KUWAHARA, RGB_DILATION, SKETCH, TOON, SMOOTH_TOON, BULGE_DISTORTION, GLASS_SPHERE, HAZE, LAPLACIAN, NON_MAXIMUM_SUPPRESSION,
SPHERE_REFRACTION, SWIRL, WEAK_PIXEL_INCLUSION, FALSE_COLOR
}

Expand Down

0 comments on commit 88d8c99

Please sign in to comment.