GPUImage簡單濾鏡使用(二)


  GPUImage中,提供了許多簡單的的常用的濾鏡。在上一篇文章講了如何調節圖像的亮度這片文章講一下如何通過GPUImage調節圖像的對比度,飽和度,曝光度,和白平衡(美圖秀秀中的色溫)。

原圖像

  調整圖像的對比度

  GPUImageContrastFilter類提供了此功能。該類中有一個屬性contrast,我們可以通過修改此屬性值(最大值4.0,最小值0.0,正常值1.0)來達到修改圖像對比度的目的,使用方法:

    GPUImageContrastFilter *filter = [[GPUImageContrastFilter alloc] init];
    filter.contrast = self.sliderView.value;
    [filter forceProcessingAtSize:img.size];
    GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:img];
    [pic addTarget:filter];
    
    [pic processImage];
    [filter useNextFrameForImageCapture];
    self.imgView.image = [filter imageFromCurrentFramebuffer];

效果如下

                                

  調整圖像的飽和度

  GPUImageSaturationFilter類提供了此功能,我們通過修改此類的saturation的屬性值(最大值2.0,最小值0.0,正常值1.0)來達到調整圖像飽和度的目的

  

    GPUImageSaturationFilter *filter = [[GPUImage
    SaturationFilter alloc] init];

 

 

 

  調整圖像的曝光度

  GPUImageExposureFilter類提供了此功能。該類中有一個屬性exposure,我們可以通過修改此屬性值(最大值10.0,最小值-10.0,正常值0.0)來達到修改圖像曝光度的目的,使用方法

    GPUImageExposureFilter *filter = [[GPUImageExposureFilter alloc] init];
    filter.exposure = self.sliderView.value;

 

  調整圖像的色溫

  GPUImageWhiteBalanceFilter類提供了此功能。該類中有2個屬性temperature(最大值10000,最小值1000,正常值5000)和tint(最大值1000,最小值-1000,正常值0.0).我們可以通過修改它們的屬性值來達到修改圖像色溫的目的,使用方法

 
    GPUImageWhiteBalanceFilter *filter = [[GPUImageWhiteBalanceFilter alloc] init];
    filter.temperature = self.sliderView.value;
    filter.tint = 0.0;

 

 

 

 

    GPUImageWhiteBalanceFilter *filter = [[GPUImageWhiteBalanceFilter alloc] init];
    filter.temperature = 5000;
    filter.tint = self.sliderView.value;

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM