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 high pass and a low pass filter. Fixed compilation issues wit…
…h GPUImageBuffer on older Xcode versions.
- Loading branch information
1 parent
09dcd46
commit 46fa7df
Showing
13 changed files
with
203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import "GPUImageFilterGroup.h" | ||
#import "GPUImageLowPassFilter.h" | ||
#import "GPUImageDifferenceBlendFilter.h" | ||
|
||
@interface GPUImageHighPassFilter : GPUImageFilterGroup | ||
{ | ||
GPUImageLowPassFilter *lowPassFilter; | ||
GPUImageDifferenceBlendFilter *differenceBlendFilter; | ||
} | ||
|
||
// This controls the degree by which the previous accumulated frames are blended and then subtracted from the current one. This ranges from 0.0 to 1.0, with a default of 0.5. | ||
@property(readwrite, nonatomic) CGFloat filterStrength; | ||
|
||
@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,44 @@ | ||
#import "GPUImageHighPassFilter.h" | ||
|
||
@implementation GPUImageHighPassFilter | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
// Start with a low pass filter to define the component to be removed | ||
lowPassFilter = [[GPUImageLowPassFilter alloc] init]; | ||
[self addFilter:lowPassFilter]; | ||
|
||
// Take the difference of the current frame from the low pass filtered result to get the high pass | ||
differenceBlendFilter = [[GPUImageDifferenceBlendFilter alloc] init]; | ||
[self addFilter:differenceBlendFilter]; | ||
|
||
// Texture location 0 needs to be the original image for the difference blend | ||
[lowPassFilter addTarget:differenceBlendFilter atTextureLocation:1]; | ||
|
||
self.initialFilters = [NSArray arrayWithObjects:lowPassFilter, differenceBlendFilter, nil]; | ||
self.terminalFilter = differenceBlendFilter; | ||
|
||
self.filterStrength = 0.5; | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
- (void)setFilterStrength:(CGFloat)newValue; | ||
{ | ||
lowPassFilter.filterStrength = newValue; | ||
} | ||
|
||
- (CGFloat)filterStrength; | ||
{ | ||
return lowPassFilter.filterStrength; | ||
} | ||
|
||
@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,14 @@ | ||
#import "GPUImageFilterGroup.h" | ||
#import "GPUImageBuffer.h" | ||
#import "GPUImageDissolveBlendFilter.h" | ||
|
||
@interface GPUImageLowPassFilter : GPUImageFilterGroup | ||
{ | ||
GPUImageBuffer *bufferFilter; | ||
GPUImageDissolveBlendFilter *dissolveBlendFilter; | ||
} | ||
|
||
// This controls the degree by which the previous accumulated frames are blended with the current one. This ranges from 0.0 to 1.0, with a default of 0.5. | ||
@property(readwrite, nonatomic) CGFloat filterStrength; | ||
|
||
@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,50 @@ | ||
#import "GPUImageLowPassFilter.h" | ||
|
||
@implementation GPUImageLowPassFilter | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
// Take in the frame and blend it with the previous one | ||
dissolveBlendFilter = [[GPUImageDissolveBlendFilter alloc] init]; | ||
[self addFilter:dissolveBlendFilter]; | ||
|
||
// Buffer the result to be fed back into the blend | ||
bufferFilter = [[GPUImageBuffer alloc] init]; | ||
[self addFilter:bufferFilter]; | ||
|
||
// Texture location 0 needs to be the original image for the dissolve blend | ||
[bufferFilter addTarget:dissolveBlendFilter atTextureLocation:1]; | ||
[dissolveBlendFilter addTarget:bufferFilter]; | ||
|
||
[dissolveBlendFilter disableSecondFrameCheck]; | ||
|
||
// To prevent double updating of this filter, disable updates from the sharp image side | ||
// self.inputFilterToIgnoreForUpdates = unsharpMaskFilter; | ||
|
||
self.initialFilters = [NSArray arrayWithObject:dissolveBlendFilter]; | ||
self.terminalFilter = dissolveBlendFilter; | ||
|
||
self.filterStrength = 0.5; | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
- (void)setFilterStrength:(CGFloat)newValue; | ||
{ | ||
dissolveBlendFilter.mix = newValue; | ||
} | ||
|
||
- (CGFloat)filterStrength; | ||
{ | ||
return dissolveBlendFilter.mix; | ||
} | ||
|
||
@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
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