-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from charlesbedrosian/develop
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
library/src/jp/co/cyberagent/android/gpuimage/GPUImageSmoothToonFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters