title: GPUImage + Touch Blurring effect
body: <p>I need to implement a touch blur effect in my app.  I'm using <a href="https://github.com/BradLarson/GPUImage/" rel="nofollow">GPUImage</a> for basic filtering but I also need to include the ability to blur any area in the image.  I've struggled for a few days on this and couldn't find any other questions/answers that helped.</p>
  
  <p>My current (pseudocode) implementation, which doesn't take advantage of GPUImage is as follows:</p>
  
  <pre><code>In the pan gesture recognizer, I'm collecting the pan gesture objects and saving them to an array.  When UIGestureRecognizerStateEnded, I attempt to apply the blur using:
  
  1. Get image from GPUImagePicture.
  2. Create a "CIGaussianBlur" CIFilter to create a blurred image.
  3. Loop through the gesture taps
  4. Create a CIFilter mask with a CIRadialGradient with the location as center.
  5. Composite the masks into 1 mask: 
  maskImage = [[CIFilter filterWithName:@"CISourceOverCompositing" keysAndValues:
               kCIInputImageKey, gassBlur, kCIInputBackgroundImageKey, maskImage, nil] valueForKey:kCIOutputImageKey];
  
  6. Crop the mask:
  CIVector *rect = [CIVector vectorWithCGRect:origImage.extent];
  maskImage = [CIFilter filterWithName:@"CICrop" keysAndValues:kCIInputImageKey, maskImage, @"inputRectangle", rect, nil].outputImage;
  
  7. Use a CIBlendWithMask filter to combine the original image, the mask, and the blurred image:
  CIFilter *blendedFilter = [CIFilter filterWithName:@"CIBlendWithMask" keysAndValues:
                             @"inputImage", pixellateFilter.outputImage,
                             @"inputBackgroundImage", origImage,
                             @"inputMaskImage", maskImage,
                             nil];
  
  8. Update the image view with the new image:
  [self.tempImgView setImage:[UIImage imageWithCIImage:pixellateFilter.outputImage]];
  </code></pre>
  
  <p>How can I make the blur effect real-time, as if the user is "painting" the image with a blurring brush?  A perfect example of this is the app <a href="https://itunes.apple.com/ca/app/touch-blur/id545958271" rel="nofollow">Touch Blur</a>.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>My filter chain is like this:</p>
  
  <pre><code>[self.staticPicture addTarget:self.filter]; // self.filter is some B&amp;W, sepia, etc filter
  [self.filter addTarget:self.blurFilter];    // I think the blur filter should be modified somehow
  [self.blurFilter addTarget:self.gpuImageView];
  [self.staticPicture processImage];
  </code></pre>
  
  <p>I need to update self.blurFilter in the pan gesture event somehow and then call processImage each time to update the gpuImageView.</p>