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 binary opening and closing filters.
- Loading branch information
1 parent
d183c28
commit ba24e68
Showing
8 changed files
with
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#import "GPUImageFilterGroup.h" | ||
|
||
@class GPUImageErosionFilter; | ||
@class GPUImageDilationFilter; | ||
|
||
// A filter that first performs a dilation on the red channel of an image, followed by an erosion of the same radius. | ||
// This helps to filter out smaller dark elements. | ||
|
||
@interface GPUImageClosingFilter : GPUImageFilterGroup | ||
{ | ||
GPUImageErosionFilter *erosionFilter; | ||
GPUImageDilationFilter *dilationFilter; | ||
} | ||
|
||
- (id)initWithRadius:(NSUInteger)radius; | ||
|
||
@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,41 @@ | ||
#import "GPUImageClosingFilter.h" | ||
#import "GPUImageErosionFilter.h" | ||
#import "GPUImageDilationFilter.h" | ||
|
||
@implementation GPUImageClosingFilter | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [self initWithRadius:1])) | ||
{ | ||
return nil; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (id)initWithRadius:(NSUInteger)radius; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
// First pass: dilation | ||
dilationFilter = [[GPUImageDilationFilter alloc] initWithRadius:radius]; | ||
[self addFilter:dilationFilter]; | ||
|
||
// Second pass: erosion | ||
erosionFilter = [[GPUImageErosionFilter alloc] initWithRadius:radius]; | ||
[self addFilter:erosionFilter]; | ||
|
||
[dilationFilter addTarget:erosionFilter]; | ||
|
||
self.initialFilters = [NSArray arrayWithObjects:dilationFilter, nil]; | ||
self.terminalFilter = erosionFilter; | ||
|
||
return self; | ||
} | ||
|
||
|
||
@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,17 @@ | ||
#import "GPUImageFilterGroup.h" | ||
|
||
@class GPUImageErosionFilter; | ||
@class GPUImageDilationFilter; | ||
|
||
// A filter that first performs an erosion on the red channel of an image, followed by a dilation of the same radius. | ||
// This helps to filter out smaller bright elements. | ||
|
||
@interface GPUImageOpeningFilter : GPUImageFilterGroup | ||
{ | ||
GPUImageErosionFilter *erosionFilter; | ||
GPUImageDilationFilter *dilationFilter; | ||
} | ||
|
||
- (id)initWithRadius:(NSUInteger)radius; | ||
|
||
@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,40 @@ | ||
#import "GPUImageOpeningFilter.h" | ||
#import "GPUImageErosionFilter.h" | ||
#import "GPUImageDilationFilter.h" | ||
|
||
@implementation GPUImageOpeningFilter | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [self initWithRadius:1])) | ||
{ | ||
return nil; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (id)initWithRadius:(NSUInteger)radius; | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
// First pass: erosion | ||
erosionFilter = [[GPUImageErosionFilter alloc] initWithRadius:radius]; | ||
[self addFilter:erosionFilter]; | ||
|
||
// Second pass: dilation | ||
dilationFilter = [[GPUImageDilationFilter alloc] initWithRadius:radius]; | ||
[self addFilter:dilationFilter]; | ||
|
||
[erosionFilter addTarget:dilationFilter]; | ||
|
||
self.initialFilters = [NSArray arrayWithObjects:erosionFilter, nil]; | ||
self.terminalFilter = dilationFilter; | ||
|
||
return self; | ||
} | ||
|
||
@end |