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.
Added a threshold filter that takes the average luminance of a scene …
…into account. Updated the documentation for the new filters.
- Loading branch information
1 parent
6c433ae
commit ff718ab
Showing
8 changed files
with
91 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import "GPUImageFilterGroup.h" | ||
|
||
@interface GPUImageAverageLuminanceThresholdFilter : GPUImageFilterGroup | ||
|
||
// This is multiplied by the continually calculated average image luminosity to arrive at the final threshold. Default is 1.0. | ||
@property(readwrite, nonatomic) CGFloat thresholdMultiplier; | ||
|
||
@end |
47 changes: 47 additions & 0 deletions
47
framework/Source/GPUImageAverageLuminanceThresholdFilter.m
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,47 @@ | ||
#import "GPUImageAverageLuminanceThresholdFilter.h" | ||
#import "GPUImageLuminosity.h" | ||
#import "GPUImageLuminanceThresholdFilter.h" | ||
|
||
@interface GPUImageAverageLuminanceThresholdFilter() | ||
{ | ||
GPUImageLuminosity *luminosityFilter; | ||
GPUImageLuminanceThresholdFilter *luminanceThresholdFilter; | ||
} | ||
@end | ||
|
||
@implementation GPUImageAverageLuminanceThresholdFilter | ||
|
||
@synthesize thresholdMultiplier = _thresholdMultiplier; | ||
|
||
#pragma mark - | ||
#pragma mark Initialization and teardown | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
self.thresholdMultiplier = 1.0; | ||
|
||
luminosityFilter = [[GPUImageLuminosity alloc] init]; | ||
[self addFilter:luminosityFilter]; | ||
|
||
luminanceThresholdFilter = [[GPUImageLuminanceThresholdFilter alloc] init]; | ||
[self addFilter:luminanceThresholdFilter]; | ||
|
||
__unsafe_unretained GPUImageAverageLuminanceThresholdFilter *weakSelf = self; | ||
__unsafe_unretained GPUImageLuminanceThresholdFilter *weakThreshold = luminanceThresholdFilter; | ||
|
||
[luminosityFilter setLuminosityProcessingFinishedBlock:^(CGFloat luminosity, CMTime frameTime) { | ||
weakThreshold.threshold = luminosity * weakSelf.thresholdMultiplier; | ||
}]; | ||
|
||
self.initialFilters = [NSArray arrayWithObjects:luminosityFilter, luminanceThresholdFilter, nil]; | ||
self.terminalFilter = luminanceThresholdFilter; | ||
|
||
return self; | ||
} | ||
|
||
@end |