I phonedevws20121028ci filter
- 5. これまでの画像処理
Sepiatone(セピア)変換の例
UIImageからCGImageに変換しピクセ
ルデータにアクセスする
ピクセルデータからRGBを取得し変換
SepiatoneNotCIFilterViewControllerのapplyFilterメソッドを参照
- 6. 画像処理の问题点
コードが長い
コードを読んでも意味がわかりにくい
画像処理のロジックを学習する必要
もう少し簡単で心理的ハードルが低いものはないか?
Core ImageのCIFilter
- 9. CIFilterでのコード
CIImage *ciImage = [[CIImage alloc] initWithImage:self.originalImageView.image];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat: 0.9f] forKey:@"inputIntensity"];
CIImage *outputImage = filter.outputImage;
CIContext *context = [CIContext contextWithOptions: nil];
CGImageRef cgImage = [context createCGImage: outputImage fromRect:
outputImage.extent];
UIImage *resultUIImage = [UIImage imageWithCGImage: cgImage];
CGImageRelease(cgImage);
self.filterImageView.image = resultUIImage;
SepiatoneCIFilterViewControllerのapplyFilterメソッドを参照
- 11. CISepiatoneコード改良
CIImage *ciImage = [[CIImage alloc] initWithImage:self.originalImageView.image];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat: self.slider.value]
forKey:@"inputIntensity"];
CIImage *outputImage = filter.outputImage;
CIContext *context = [CIContext contextWithOptions: nil];
CGImageRef cgImage = [context createCGImage: outputImage fromRect:
outputImage.extent];
UIImage *resultUIImage = [UIImage imageWithCGImage: cgImage];
CGImageRelease(cgImage);
self.filterImageView.image = resultUIImage;
SepiatoneCIFilterInputIntensityViewControllerのapplyFilterメ
ソッドを参照
- 13. CIMonochromeのコード
CIImage *ciImage = [[CIImage alloc] initWithImage:self.originalImageView.image];
CIFilter *filter = [CIFilter filterWithName:@"CIMonochrome"];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat: 0.9f] forKey:@"inputIntensity"];
[filter setValue:[CIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1.0f]
forKey: @"inputColor"];
CIImage *outputImage = filter.outputImage;
CIContext *context = [CIContext contextWithOptions: nil];
CGImageRef cgImage = [context createCGImage: outputImage fromRect:
outputImage.extent];
UIImage *resultUIImage = [UIImage imageWithCGImage: cgImage];
CGImageRelease(cgImage);
self.filterImageView.image = resultUIImage;
MonochoromeViewControllerのapplyFilterメソッドを参照
- 15. CIColorInvert + CIHueAdjust
CIImage *ciImage = [[CIImage alloc] initWithImage:self.originalImageView.image];
CIFilter *colorInvertfilter = [CIFilter filterWithName:@"CIColorInvert"];
[colorInvertfilter setDefaults];
[colorInvertfilter setValue:ciImage forKey: @"inputImage"];
CIFilter *hueAdjustFilter = [CIFilter filterWithName:@"CIHueAdjust"];
[hueAdjustFilter setDefaults];
[hueAdjustFilter setValue:[colorInvertfilter valueForKey:@"outputImage"]
forKey:@"inputImage"];
[hueAdjustFilter setValue:[NSNumber numberWithFloat:1.62] forKey:@"inputAngle"];
CIImage *outputImage = [hueAdjustFilter valueForKey:@"outputImage"];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage: outputImage fromRect:
outputImage.extent];
UIImage *resultUIImage = [UIImage imageWithCGImage: cgImage];
CGImageRelease(cgImage);
self.colorInvertAndHueAdjustFilterImageView.image = resultUIImage;
CororInvertAndHueAdjustViewControllerの
applyColorInvertAndHueAdjustFilterメソッドを参照
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n