Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BradLarson/GPUImage
Browse files Browse the repository at this point in the history
  • Loading branch information
William LaFrance committed May 10, 2012
2 parents 04f258a + 8fb09eb commit 79bdb2e
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Exclude the build directory
build/*
examples/FilterShowcase/build*

# Exclude temp nibs and swap files
*~.nib
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Documentation is generated from header comments using appledoc. To build the doc

- **GPUImageVignetteFilter**: Performs a vignetting effect, fading out the image at the edges
- *x*:
- *y*: The directional intensity of the vignetting, with a default of x = 0.5, y = 0.75
- *y*: The directional intensity of the vignetting, with a default of x = 0.75, y = 0.5

- **GPUImageKuwaharaFilter**: Kuwahara image abstraction, drawn from the work of Kyprianidis, et. al. in their publication "Anisotropic Kuwahara Filtering on the GPU" within the GPU Pro collection. This produces an oil-painting-like image, but it is extremely computationally expensive, so it can take seconds to render a frame on an iPad 2. This might be best used for still images.
- *radius*: In integer specifying the number of pixels out from the center pixel to test when applying the filter, with a default of 4. A higher value creates a more abstracted image, but at the cost of much greater processing time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case GPUIMAGE_CONTRAST: cell.textLabel.text = @"Contrast"; break;
case GPUIMAGE_BRIGHTNESS: cell.textLabel.text = @"Brightness"; break;
case GPUIMAGE_EXPOSURE: cell.textLabel.text = @"Exposure"; break;
case GPUIMAGE_RGB: cell.textLabel.text = @"RGB"; break;
case GPUIMAGE_SHARPEN: cell.textLabel.text = @"Sharpen"; break;
case GPUIMAGE_UNSHARPMASK: cell.textLabel.text = @"Unsharp mask"; break;
case GPUIMAGE_GAMMA: cell.textLabel.text = @"Gamma"; break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ typedef enum {
GPUIMAGE_CONTRAST,
GPUIMAGE_BRIGHTNESS,
GPUIMAGE_EXPOSURE,
GPUIMAGE_RGB,
GPUIMAGE_SHARPEN,
GPUIMAGE_UNSHARPMASK,
GPUIMAGE_TRANSFORM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ - (void)setupFilter;

filter = [[GPUImageBrightnessFilter alloc] init];
}; break;
case GPUIMAGE_RGB:
{
self.title = @"RGB";
self.filterSettingsSlider.hidden = NO;

[self.filterSettingsSlider setMinimumValue:0.0];
[self.filterSettingsSlider setMaximumValue:2.0];
[self.filterSettingsSlider setValue:1.0];

filter = [[GPUImageRGBFilter alloc] init];
}; break;
case GPUIMAGE_EXPOSURE:
{
self.title = @"Exposure";
Expand Down Expand Up @@ -764,6 +775,7 @@ - (IBAction)updateFilterFromSlider:(id)sender;
case GPUIMAGE_CONTRAST: [(GPUImageContrastFilter *)filter setContrast:[(UISlider *)sender value]]; break;
case GPUIMAGE_BRIGHTNESS: [(GPUImageBrightnessFilter *)filter setBrightness:[(UISlider *)sender value]]; break;
case GPUIMAGE_EXPOSURE: [(GPUImageExposureFilter *)filter setExposure:[(UISlider *)sender value]]; break;
case GPUIMAGE_RGB: [(GPUImageRGBFilter *)filter setGreen:[(UISlider *)sender value]]; break;
case GPUIMAGE_SHARPEN: [(GPUImageSharpenFilter *)filter setSharpness:[(UISlider *)sender value]]; break;
case GPUIMAGE_HISTOGRAM: [(GPUImageHistogramFilter *)filter setDownsamplingFactor:round([(UISlider *)sender value])]; break;
case GPUIMAGE_UNSHARPMASK: [(GPUImageUnsharpMaskFilter *)filter setIntensity:[(UISlider *)sender value]]; break;
Expand Down
8 changes: 8 additions & 0 deletions framework/GPUImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
BCF3D723153E0E0C009A1FE5 /* GPUImageThresholdEdgeDetection.m in Sources */ = {isa = PBXBuildFile; fileRef = BCF3D721153E0E0B009A1FE5 /* GPUImageThresholdEdgeDetection.m */; };
BCF3D730153F0D6F009A1FE5 /* GPUImageSmoothToonFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF3D72E153F0D6E009A1FE5 /* GPUImageSmoothToonFilter.h */; };
BCF3D731153F0D6F009A1FE5 /* GPUImageSmoothToonFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCF3D72F153F0D6F009A1FE5 /* GPUImageSmoothToonFilter.m */; };
BEBE83B5155C092A00EEF8C3 /* GPUImageRGBFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BEBE83B3155C092A00EEF8C3 /* GPUImageRGBFilter.h */; };
BEBE83B6155C092A00EEF8C3 /* GPUImageRGBFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BEBE83B4155C092A00EEF8C3 /* GPUImageRGBFilter.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -379,6 +381,8 @@
BCF3D721153E0E0B009A1FE5 /* GPUImageThresholdEdgeDetection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageThresholdEdgeDetection.m; path = Source/GPUImageThresholdEdgeDetection.m; sourceTree = SOURCE_ROOT; };
BCF3D72E153F0D6E009A1FE5 /* GPUImageSmoothToonFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageSmoothToonFilter.h; path = Source/GPUImageSmoothToonFilter.h; sourceTree = SOURCE_ROOT; };
BCF3D72F153F0D6F009A1FE5 /* GPUImageSmoothToonFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageSmoothToonFilter.m; path = Source/GPUImageSmoothToonFilter.m; sourceTree = SOURCE_ROOT; };
BEBE83B3155C092A00EEF8C3 /* GPUImageRGBFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageRGBFilter.h; path = Source/GPUImageRGBFilter.h; sourceTree = SOURCE_ROOT; };
BEBE83B4155C092A00EEF8C3 /* GPUImageRGBFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageRGBFilter.m; path = Source/GPUImageRGBFilter.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -421,6 +425,8 @@
BC1B715D14F4AFFF00ACA2AB /* Color processing */ = {
isa = PBXGroup;
children = (
BEBE83B3155C092A00EEF8C3 /* GPUImageRGBFilter.h */,
BEBE83B4155C092A00EEF8C3 /* GPUImageRGBFilter.m */,
BC982B7714F098CC0001FF6F /* GPUImageBrightnessFilter.h */,
BC982B7814F098CC0001FF6F /* GPUImageBrightnessFilter.m */,
BCB6B833150400030041703B /* GPUImageExposureFilter.h */,
Expand Down Expand Up @@ -788,6 +794,7 @@
BCAD0985154F931C00278521 /* GPUImageAlphaBlendFilter.h in Headers */,
BCAD099F15506F6F00278521 /* GPUImageNonMaximumSuppressionFilter.h in Headers */,
BC114898155AF65400F107AF /* GPUImageTwoInputFilter.h in Headers */,
BEBE83B5155C092A00EEF8C3 /* GPUImageRGBFilter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -982,6 +989,7 @@
BCAD0986154F931C00278521 /* GPUImageAlphaBlendFilter.m in Sources */,
BCAD09A015506F6F00278521 /* GPUImageNonMaximumSuppressionFilter.m in Sources */,
BC114899155AF65400F107AF /* GPUImageTwoInputFilter.m in Sources */,
BEBE83B6155C092A00EEF8C3 /* GPUImageRGBFilter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions framework/Source/GPUImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@
#import "GPUImageHarrisCornerDetectionFilter.h"
#import "GPUImageAlphaBlendFilter.h"
#import "GPUImageNonMaximumSuppressionFilter.h"
#import "GPUImageRGBFilter.h"
14 changes: 14 additions & 0 deletions framework/Source/GPUImageRGBFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import "GPUImageFilter.h"

@interface GPUImageRGBFilter : GPUImageFilter
{
GLint redUniform;
GLint greenUniform;
GLint blueUniform;
}

@property (readwrite, nonatomic) CGFloat red;
@property (readwrite, nonatomic) CGFloat green;
@property (readwrite, nonatomic) CGFloat blue;

@end
77 changes: 77 additions & 0 deletions framework/Source/GPUImageRGBFilter.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#import "GPUImageRGBFilter.h"

NSString *const kGPUImageRGBFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;

uniform sampler2D inputImageTexture;
uniform highp float red;
uniform highp float green;
uniform highp float blue;

void main()
{
highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);

gl_FragColor = vec4(textureColor.r * red, textureColor.g * green, textureColor.b * blue, 1.0);
}
);

@implementation GPUImageRGBFilter

@synthesize red = _red, blue = _blue, green = _green;

#pragma mark -
#pragma mark Initialization and teardown

- (id)init;
{
if (!(self = [super initWithFragmentShaderFromString:kGPUImageRGBFragmentShaderString]))
{
return nil;
}

redUniform = [filterProgram uniformIndex:@"red"];
self.red = 1.0;

greenUniform = [filterProgram uniformIndex:@"green"];
self.green = 1.0;

blueUniform = [filterProgram uniformIndex:@"blue"];
self.blue = 1.0;

return self;
}

#pragma mark -
#pragma mark Accessors

- (void)setRed:(CGFloat)newValue;
{
_red = newValue;

[GPUImageOpenGLESContext useImageProcessingContext];
[filterProgram use];
glUniform1f(redUniform, _red);
}

- (void)setGreen:(CGFloat)newValue;
{
_green = newValue;

[GPUImageOpenGLESContext useImageProcessingContext];
[filterProgram use];
glUniform1f(greenUniform, _green);
}


- (void)setBlue:(CGFloat)newValue;
{
_blue = newValue;

[GPUImageOpenGLESContext useImageProcessingContext];
[filterProgram use];
glUniform1f(blueUniform, _blue);
}

@end

0 comments on commit 79bdb2e

Please sign in to comment.