色阶是表示图像亮度强弱的指数标准,图像的色彩丰满度和精细度是由色阶决定的。在GPUImage中GPUImageLevelsFilter提供了此功能。
GPUImageLevelsFilter定义了修改红色,绿色,蓝色,和所有通道的方法,有效值范围时0.0-1.0之间,如果你想想像ps中那样,你必须先转为[0,1]。
/** Set levels for the red channel */
- (void)setRedMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max minOut:(CGFloat)minOut maxOut:(CGFloat)maxOut;
- (void)setRedMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max;
/** Set levels for the green channel */
- (void)setGreenMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max minOut:(CGFloat)minOut maxOut:(CGFloat)maxOut;
- (void)setGreenMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max;
/** Set levels for the blue channel */
- (void)setBlueMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max minOut:(CGFloat)minOut maxOut:(CGFloat)maxOut;
- (void)setBlueMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max;
/** Set levels for all channels at once */
- (void)setMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max minOut:(CGFloat)minOut maxOut:(CGFloat)maxOut;
- (void)setMin:(CGFloat)min gamma:(CGFloat)mid max:(CGFloat)max;
filter = [[GPUImageLevelsFilter alloc] init]; [filter setMin:[[(UITextField *)[self viewWithTag:1001] text] floatValue] gamma:[[(UITextField *)[self viewWithTag:1002] text] floatValue] max: [[(UITextField *)[self viewWithTag:1003] text] floatValue] minOut:[[(UITextField *)[self viewWithTag:1004] text] floatValue] maxOut:[[(UITextField *)[self viewWithTag:1005] text] floatValue]]; [filter forceProcessingAtSize:img.size]; GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:img]; [pic addTarget:filter]; [pic processImage]; [filter useNextFrameForImageCapture]; self.imgView.image = [filter imageFromCurrentFramebuffer];