forked from BradLarson/GPUImage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5917d97
commit 48b2936
Showing
11 changed files
with
193 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,25 @@ | ||
#import "GPUImageFilterGroup.h" | ||
|
||
@class GPUImageGaussianBlurFilter; | ||
@class GPUImageToonFilter; | ||
|
||
@interface GPUImageSmoothToonFilter : GPUImageFilterGroup | ||
{ | ||
GPUImageGaussianBlurFilter *blurFilter; | ||
GPUImageToonFilter *toonFilter; | ||
} | ||
|
||
// The image width and height factors tweak the appearance of the edges. By default, they match the filter size in pixels | ||
@property(readwrite, nonatomic) CGFloat imageWidthFactor; | ||
@property(readwrite, nonatomic) CGFloat imageHeightFactor; | ||
|
||
// A multiplier for the blur size, ranging from 0.0 on up, with a default of 0.5 | ||
@property (readwrite, nonatomic) CGFloat blurSize; | ||
|
||
// The threshold at which to apply the edges, default of 0.2 | ||
@property(readwrite, nonatomic) CGFloat threshold; | ||
|
||
// The levels of quantization for the posterization of colors within the scene, with a default of 10.0 | ||
@property(readwrite, nonatomic) CGFloat quantizationLevels; | ||
|
||
@end |
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,94 @@ | ||
#import "GPUImageSmoothToonFilter.h" | ||
#import "GPUImageGaussianBlurFilter.h" | ||
#import "GPUImageToonFilter.h" | ||
|
||
@implementation GPUImageSmoothToonFilter | ||
|
||
@synthesize threshold; | ||
@synthesize blurSize; | ||
@synthesize quantizationLevels; | ||
@synthesize imageWidthFactor; | ||
@synthesize imageHeightFactor; | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
// First pass: apply a variable Gaussian blur | ||
blurFilter = [[GPUImageGaussianBlurFilter alloc] init]; | ||
[self addFilter:blurFilter]; | ||
|
||
// Second pass: run the Sobel edge detection on this blurred image, along with a posterization effect | ||
toonFilter = [[GPUImageToonFilter alloc] init]; | ||
[self addFilter:toonFilter]; | ||
|
||
// Texture location 0 needs to be the sharp image for both the blur and the second stage processing | ||
[blurFilter addTarget:toonFilter]; | ||
|
||
self.initialFilters = [NSArray arrayWithObject:blurFilter]; | ||
self.terminalFilter = toonFilter; | ||
|
||
self.blurSize = 0.5; | ||
self.threshold = 0.2; | ||
self.quantizationLevels = 10.0; | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
- (void)setBlurSize:(CGFloat)newValue; | ||
{ | ||
blurFilter.blurSize = newValue; | ||
} | ||
|
||
- (CGFloat)blurSize; | ||
{ | ||
return blurFilter.blurSize; | ||
} | ||
|
||
- (void)setImageWidthFactor:(CGFloat)newValue; | ||
{ | ||
toonFilter.imageWidthFactor = newValue; | ||
} | ||
|
||
- (CGFloat)imageWidthFactor; | ||
{ | ||
return toonFilter.imageWidthFactor; | ||
} | ||
|
||
- (void)setImageHeightFactor:(CGFloat)newValue; | ||
{ | ||
toonFilter.imageHeightFactor = newValue; | ||
} | ||
|
||
- (CGFloat)imageHeightFactor; | ||
{ | ||
return toonFilter.imageHeightFactor; | ||
} | ||
|
||
- (void)setThreshold:(CGFloat)newValue; | ||
{ | ||
toonFilter.threshold = newValue; | ||
} | ||
|
||
- (CGFloat)threshold; | ||
{ | ||
return toonFilter.threshold; | ||
} | ||
|
||
- (void)setQuantizationLevels:(CGFloat)newValue; | ||
{ | ||
toonFilter.quantizationLevels = newValue; | ||
} | ||
|
||
- (CGFloat)quantizationLevels; | ||
{ | ||
return toonFilter.quantizationLevels; | ||
} | ||
|
||
@end |
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
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