title: Trying to modify brightness/contrast using CIFilter crashes the app
body: <p>I have two UIImageViews, each containing a UIImage. The UIImageView that's on top has a UIImage whose contrast/brightness I want to modify according to which of two buttons is pressed. I put the CIFilter, CIContext and CIImage in the @implementation of my ViewController, initialised them in viewDidLoad like this:</p>
  
  <pre><code>controlsFilter = [CIFilter filterWithName:@"CIColorControls"];
  newContext = [CIContext contextWithOptions:nil];
  beginImage = [[CIImage alloc] initWithImage:imageView.image];
  [controlsFilter setValue:beginImage forKey: kCIInputImageKey];
  </code></pre>
  
  <p>Then, the buttons that I press for either Contrast or Brightness have the following implementation of actions:</p>
  
  <pre><code>- (IBAction) contrast
  {
      [slider setMaximumValue:4.0];
      [slider setMinimumValue:0.25];
      [slider setValue:1.0];
      if (contrast == NO) {
          contrast = YES;
          brightness = NO;
          [slider setHidden:NO];
      }
      else {
          contrast = NO;
          [slider setHidden:YES];
      }    
  }
  
  - (IBAction) brightness {
  
      [slider setMaximumValue:1.0];
      [slider setMinimumValue:-1.0];
      [slider setValue:0.0];
      if (brightness == NO) {
          contrast = NO;
          brightness = YES;
          [slider setHidden:NO];
      }
      else {
          brightness = NO;
          [slider setHidden:YES];
      }
  }
  </code></pre>
  
  <p>Up until here, everything seems fine, though when I try to modify the image in here:</p>
  
  <pre><code>-(IBAction)changeValue:(UISlider *)sender {
      float slideValue = [sender value];
  
      if (brightness == YES)
          [controlsFilter setValue:[NSNumber numberWithFloat:slideValue]  forKey:@"inputBrightness"];
      if (contrast == YES)
          [controlsFilter setValue:[NSNumber numberWithFloat:slideValue] forKey:@"inputContrast"];
      CIImage *outputImage = [controlsFilter outputImage];
  
      CGImageRef cgimg = [newContext createCGImage:outputImage fromRect:[outputImage extent]];
  
      UIImage *newImg = [UIImage imageWithCGImage:cgimg];    
      [imageView setImage:newImg];
  
      CGImageRelease(cgimg);
  }
  </code></pre>
  
  <p>Apparently, if I remove the UIImageView that's at the bottom, all works fine. When I have two UIImageViews, it crashes and I don't know how to fix it. I only want to get the context for the second view, not all of it.</p>