iOS實現映像的反色,懷舊,色彩長條圖效果,ios長條圖

來源:互聯網
上載者:User

iOS實現映像的反色,懷舊,色彩長條圖效果,ios長條圖

  反色是與原色疊加可以變為白色的顏色,即用白色(RGB:1.0,1.0,1.0)減去原色的顏色。比如說紅色(RGB:1.0,0,0)的反色是青色(0,1.0,1.0)。在OPENGL ES中為1.

  通過匯入GPUImage庫的GPUImageColorInvertFilter來實現iOS的映像反色處理

 1 ( 2  varying highp vec2 textureCoordinate; 3   4  uniform sampler2D inputImageTexture; 5   6  void main() 7  { 8     lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); 9     10     gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);11  }12 );

  lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);

   我們首先使用texture2D函數來擷取映像的顏色RGBA空間

 

  gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);

  使用1-對應的RGB值來得到新的RGB值。產生新的顏色,然後著色。

+ (UIImage *)applyColorInvertFilter:(UIImage *)image{    GPUImageColorInvertFilter *filter = [[GPUImageColorInvertFilter alloc] init];    [filter forceProcessingAtSize:image.size];    GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image];    [pic addTarget:filter];    [pic processImage];    [filter useNextFrameForImageCapture];        return [filter imageFromCurrentFramebuffer];}

 

  

 

  

 

  

 

灰色的RGB值是(0.5,0.5,0.5) 使用GPUImageSepiaFilter對象來實現映像的灰色處理

+ (UIImage *)applySepiaFilter:(UIImage *)image{    GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];    [filter forceProcessingAtSize:image.size];    GPUImagePicture *pic = [[GPUImagePicture alloc] initWithImage:image];    [pic addTarget:filter];    [pic processImage];    [filter useNextFrameForImageCapture];        return [filter imageFromCurrentFramebuffer];}

  

 

   色彩長條圖

   色彩長條圖是在許多映像檢索系統中被廣泛採用的顏色特徵。它所描述的是不同色彩在整幅映像中所佔的比例,而並不關心每種色彩所處的空間位置,即無法描述映像中的對象或物體。顏色長條圖特別適於描述那些難以進行自動分割的映像。

GPUImageHistogramGenerator對象產生映像的色彩長條圖

+ (UIImage *)applyHistogramFilter:(UIImage *)image{    GPUImageHistogramGenerator *filter = [[GPUImageHistogramGenerator alloc] init];    [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.