GPUImage濾鏡之銳利化,gpuimage濾鏡

來源:互聯網
上載者:User

GPUImage濾鏡之銳利化,gpuimage濾鏡

  應用銳利化工具可以快速聚焦模糊邊緣,提高映像中某一部位的清晰度或者焦距程度,使映像特定地區的色彩更加鮮明。 在應用銳利化工具時,若勾選器選項欄中的“對所有圖層取樣”複選框,則可對所有可見圖層中的映像進行銳利化。但一定要適度。銳利化不是萬能的,很容易使東西不真實。

  在GPUImage中使用GPUImageSharpenFilter類來實現映像的銳利化效果

  片段著色

 precision highp float;  varying highp vec2 textureCoordinate; varying highp vec2 leftTextureCoordinate; varying highp vec2 rightTextureCoordinate;  varying highp vec2 topTextureCoordinate; varying highp vec2 bottomTextureCoordinate;  varying highp float centerMultiplier; varying highp float edgeMultiplier; uniform sampler2D inputImageTexture;  void main() {     mediump vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;     mediump vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;     mediump vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;     mediump vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;     mediump vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;     gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w); }

 

   具體應用

  

+ (UIImage *)changeValueForSharpenilter:(float)value image:(UIImage *)image{    GPUImageSharpenFilter *filter = [[GPUImageSharpenFilter alloc] init];    filter.sharpness = value;    [filter forceProcessingAtSize:image.size];    GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image];    [pic addTarget:filter];        [pic processImage];    [filter useNextFrameForImageCapture];    return [filter imageFromCurrentFramebuffer];}

 

  效果

  

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.