Skip to content

Commit

Permalink
added approximate poisson image blending
Browse files Browse the repository at this point in the history
  • Loading branch information
iansimon committed Jan 30, 2013
1 parent 850ebf1 commit c6dad1b
Show file tree
Hide file tree
Showing 9 changed files with 389 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case GPUIMAGE_SATURATIONBLEND: cell.textLabel.text = @"Saturation blend"; break;
case GPUIMAGE_LUMINOSITYBLEND: cell.textLabel.text = @"Luminosity blend"; break;
case GPUIMAGE_NORMALBLEND: cell.textLabel.text = @"Normal blend"; break;
case GPUIMAGE_POISSONBLEND: cell.textLabel.text = @"Poisson blend"; break;
case GPUIMAGE_OPACITY: cell.textLabel.text = @"Opacity adjustment"; break;
case GPUIMAGE_KUWAHARA: cell.textLabel.text = @"Kuwahara"; break;
case GPUIMAGE_VIGNETTE: cell.textLabel.text = @"Vignette"; break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef enum {
GPUIMAGE_SATURATIONBLEND,
GPUIMAGE_LUMINOSITYBLEND,
GPUIMAGE_NORMALBLEND,
GPUIMAGE_POISSONBLEND,
GPUIMAGE_OPACITY,
GPUIMAGE_CUSTOM,
GPUIMAGE_UIELEMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,18 @@ - (void)setupFilter;

filter = [[GPUImageNormalBlendFilter alloc] init];
}; break;
case GPUIMAGE_POISSONBLEND:
{
self.title = @"Poisson Blend";
self.filterSettingsSlider.hidden = NO;
needsSecondImage = YES;

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

filter = [[GPUImagePoissonBlendFilter alloc] init];
}; break;

case GPUIMAGE_OPACITY:
{
Expand Down Expand Up @@ -1477,6 +1489,7 @@ - (IBAction)updateFilterFromSlider:(id)sender;
case GPUIMAGE_ADAPTIVETHRESHOLD: [(GPUImageAdaptiveThresholdFilter *)filter setBlurSize:[(UISlider*)sender value]]; break;
case GPUIMAGE_AVERAGELUMINANCETHRESHOLD: [(GPUImageAverageLuminanceThresholdFilter *)filter setThresholdMultiplier:[(UISlider *)sender value]]; break;
case GPUIMAGE_DISSOLVE: [(GPUImageDissolveBlendFilter *)filter setMix:[(UISlider *)sender value]]; break;
case GPUIMAGE_POISSONBLEND: [(GPUImagePoissonBlendFilter *)filter setMix:[(UISlider *)sender value]]; break;
case GPUIMAGE_LOWPASS: [(GPUImageLowPassFilter *)filter setFilterStrength:[(UISlider *)sender value]]; break;
case GPUIMAGE_HIGHPASS: [(GPUImageHighPassFilter *)filter setFilterStrength:[(UISlider *)sender value]]; break;
case GPUIMAGE_MOTIONDETECTOR: [(GPUImageMotionDetector *)filter setLowPassFilterStrength:[(UISlider *)sender value]]; break;
Expand Down
24 changes: 16 additions & 8 deletions framework/GPUImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
4308B1D815F7EED30014437A /* GPUImageNormalBlendFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4308B1D615F7EED20014437A /* GPUImageNormalBlendFilter.m */; };
4686952F155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4686952D155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.h */; };
46869530155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4686952E155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.m */; };
46A8097816B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A8097616B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.h */; };
46A8097916B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A8097716B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.m */; };
46A8097816B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A8097616B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.h */; };
46A8097916B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A8097716B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.m */; };
46A8097D16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A8097B16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.h */; };
46A8097E16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A8097C16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.m */; };
6D13DBE6151AA804000B23BA /* GPUImageHazeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D13DBE4151AA804000B23BA /* GPUImageHazeFilter.h */; };
6D13DBE7151AA804000B23BA /* GPUImageHazeFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D13DBE5151AA804000B23BA /* GPUImageHazeFilter.m */; };
6EE27493150E8FC60040DDB6 /* GPUImageGrayscaleFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE27491150E8FC50040DDB6 /* GPUImageGrayscaleFilter.h */; };
Expand Down Expand Up @@ -355,8 +357,10 @@
4308B1D615F7EED20014437A /* GPUImageNormalBlendFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageNormalBlendFilter.m; path = Source/GPUImageNormalBlendFilter.m; sourceTree = SOURCE_ROOT; };
4686952D155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageSourceOverBlendFilter.h; path = Source/GPUImageSourceOverBlendFilter.h; sourceTree = SOURCE_ROOT; };
4686952E155AACAC0060BA43 /* GPUImageSourceOverBlendFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageSourceOverBlendFilter.m; path = Source/GPUImageSourceOverBlendFilter.m; sourceTree = SOURCE_ROOT; };
46A8097616B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageTwoInput3x3TextureSamplingFilter.h; path = Source/GPUImageTwoInput3x3TextureSamplingFilter.h; sourceTree = SOURCE_ROOT; };
46A8097716B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageTwoInput3x3TextureSamplingFilter.m; path = Source/GPUImageTwoInput3x3TextureSamplingFilter.m; sourceTree = SOURCE_ROOT; };
46A8097616B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageTwoInputCrossTextureSamplingFilter.h; path = Source/GPUImageTwoInputCrossTextureSamplingFilter.h; sourceTree = SOURCE_ROOT; };
46A8097716B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageTwoInputCrossTextureSamplingFilter.m; path = Source/GPUImageTwoInputCrossTextureSamplingFilter.m; sourceTree = SOURCE_ROOT; };
46A8097B16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImagePoissonBlendFilter.h; path = Source/GPUImagePoissonBlendFilter.h; sourceTree = SOURCE_ROOT; };
46A8097C16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImagePoissonBlendFilter.m; path = Source/GPUImagePoissonBlendFilter.m; sourceTree = SOURCE_ROOT; };
6D13DBE4151AA804000B23BA /* GPUImageHazeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageHazeFilter.h; path = Source/GPUImageHazeFilter.h; sourceTree = SOURCE_ROOT; };
6D13DBE5151AA804000B23BA /* GPUImageHazeFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageHazeFilter.m; path = Source/GPUImageHazeFilter.m; sourceTree = SOURCE_ROOT; };
6EE27491150E8FC50040DDB6 /* GPUImageGrayscaleFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageGrayscaleFilter.h; path = Source/GPUImageGrayscaleFilter.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -814,6 +818,8 @@
B80171FD16312800001C8D16 /* GPUImageSaturationBlendFilter.m */,
B801722D16313151001C8D16 /* GPUImageLuminosityBlendFilter.h */,
B801722E16313151001C8D16 /* GPUImageLuminosityBlendFilter.m */,
46A8097B16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.h */,
46A8097C16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.m */,
);
name = Blends;
sourceTree = "<group>";
Expand Down Expand Up @@ -890,8 +896,8 @@
BCC1E5B7151E83700006EFA5 /* GPUImageFilterGroup.m */,
BC01E830155CA5E1004C75C3 /* GPUImage3x3TextureSamplingFilter.h */,
BC01E831155CA5E1004C75C3 /* GPUImage3x3TextureSamplingFilter.m */,
46A8097616B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.h */,
46A8097716B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.m */,
46A8097616B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.h */,
46A8097716B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.m */,
BCBCE9D3159944AB00E0ED33 /* GPUImageBuffer.h */,
BCBCE9D4159944AB00E0ED33 /* GPUImageBuffer.m */,
BC1B715D14F4AFFF00ACA2AB /* Color processing */,
Expand Down Expand Up @@ -1270,7 +1276,8 @@
B80171E616311FCB001C8D16 /* GPUImageHueBlendFilter.h in Headers */,
B80171FE16312800001C8D16 /* GPUImageSaturationBlendFilter.h in Headers */,
B801722F16313151001C8D16 /* GPUImageLuminosityBlendFilter.h in Headers */,
46A8097816B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.h in Headers */,
46A8097816B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.h in Headers */,
46A8097D16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1533,7 +1540,8 @@
B80171E716311FCB001C8D16 /* GPUImageHueBlendFilter.m in Sources */,
B80171FF16312800001C8D16 /* GPUImageSaturationBlendFilter.m in Sources */,
B801723016313151001C8D16 /* GPUImageLuminosityBlendFilter.m in Sources */,
46A8097916B8A48E000C29ED /* GPUImageTwoInput3x3TextureSamplingFilter.m in Sources */,
46A8097916B8A48E000C29ED /* GPUImageTwoInputCrossTextureSamplingFilter.m in Sources */,
46A8097E16B8A6A2000C29ED /* GPUImagePoissonBlendFilter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions framework/Source/GPUImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@
#import "GPUImageParallelCoordinateLineTransformFilter.h"
#import "GPUImageThresholdSketchFilter.h"
#import "GPUImageLineGenerator.h"
#import "GPUImageTwoInputCrossTextureSamplingFilter.h"
#import "GPUImagePoissonBlendFilter.h"
26 changes: 26 additions & 0 deletions framework/Source/GPUImagePoissonBlendFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// GPUImagePoissonBlendFilter.h
// GPUImage
//
// Created by Ian Simon on 1/29/13.
// Copyright (c) 2013 Brad Larson. All rights reserved.
//

#import "GPUImageTwoInputCrossTextureSamplingFilter.h"
#import "GPUImageFilterGroup.h"

@interface GPUImagePoissonBlendFilter : GPUImageTwoInputCrossTextureSamplingFilter
{
GLint mixUniform;

GLuint secondFilterOutputTexture;
GLuint secondFilterFramebuffer;
}

// Mix ranges from 0.0 (only image 1) to 1.0 (only image 2 gradients), with 1.0 as the normal level
@property(readwrite, nonatomic) CGFloat mix;

// The number of times to propagate the gradients.
@property(readwrite, nonatomic) NSUInteger numIterations;

@end
Loading

0 comments on commit c6dad1b

Please sign in to comment.