0

画像のフィルタリングに BradLarson の GPUImage ライブラリを使用しています。私は自分のプロジェクトでこのコードを使用しています。

 GPUImagePicture *staticPicture;

フィルターの適用はこのようなものです -

 -(void) setFilter:(int) index {
   switch (index) {
      case 1:{
        filter = [[GPUImageContrastFilter alloc] init];
        [(GPUImageContrastFilter *) filter setContrast:1.75];
    } break;
    case 2: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"crossprocess"];
       } break;
       case 3: {
          filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"02"];
      } break;
      case 4: {
        filter = [[GrayscaleContrastFilter alloc] init];
      } break;
      case 5: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"17"];
      } break;
      case 6: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"aqua"];
      } break;
      case 7: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"yellow-red"];
      } break;
      case 8: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"06"];
      } break;
      case 9: {
        filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"purple-green"];
      } break;
      default:
        filter = [[GPUImageFilter alloc] init];
        break;
  }

現在適用されているフィルターを変更せずに GPUImage の明るさを上げたいと思います。これを行う方法は?

4

1 に答える 1

0

以下のメソッドを含めます

-(UIImage*)applyFilterForImage:(UIImage*)img value:(NSNumber*)filterValue
{
    switch (type) {
        case kPhotoBrightness:
            self.filterImage = [self applyBrightnessForImage:img value:filterValue];
            break;

        case kPhotoContrast:
            self.filterImage = [self applyContrastForImage:img value:filterValue];
            break;

        case kPhotoSaturation:
            self.filterImage = [self applySaturationForimage:img value:filterValue];
            break;

        case kPhotoHue:
            self.filterImage = [self applyHueForImage:img value:filterValue];
            break;

        case kPhotoSharpness:
            self.filterImage = [self applySharpnessForImage:img value:filterValue];
            break;

        default:
            break;
    }
    return self.filterImage;
}

-(UIImage*)applyBrightnessForImage:(UIImage*)img value:(NSNumber*)filterValue   {
    GPUImageBrightnessFilter *brightnessFilter = (GPUImageBrightnessFilter*)self.filter;
    [brightnessFilter setBrightness:[filterValue floatValue]];
    return [self outputImageForFilter:brightnessFilter andImage:img];
}

//output the filtered image
-(UIImage*)outputImageForFilter:(GPUImageOutput<GPUImageInput>*)_filter andImage:(UIImage*)_image   {

    GPUImagePicture *filteredImage = [[GPUImagePicture alloc]initWithImage:_image];
    [filteredImage addTarget:_filter];
    [filteredImage processImage];
    return [_filter imageFromCurrentlyProcessedOutputWithOrientation:_image.imageOrientation];
}
于 2013-11-12T11:24:58.133 に答える