简体   繁体   English

如何在Android中达到像Photoshop的平均模糊效果?

[英]how to achieve effect like photoshop's average blur in android?

I want to do a function like photoshop's average blur (Filter>Blue>Average) 我想做一个像photoshop的平均模糊功能(滤镜>蓝色>平均)

but I tried something like get average color from image in android, but really buggy. 但我尝试了类似的操作,例如从android中的图像中获取平均颜色,但确实有问题。 most image turn out to be black or gray or white. 大多数图像显示为黑色或灰色或白色。

any lib available? 有没有可用的库? or Is there any app can do this? 或是否有任何应用程序可以做到这一点?

the effect just like this. 这样的效果。

目标:

If you don't like the color you are getting from the average of the color values, you could try Android's Palette class. 如果您不喜欢从颜色平均值得到的颜色,可以尝试使用Android的Palette类。 The class was made to generate a palette of colors based on the prominent colors of an image to create something like this: 创建该类是基于图像的突出颜色生成调色板,以创建如下所示的内容:

在此处输入图片说明

This would have to be done asynchronously from the UI thread: 这必须从UI线程异步完成:

Palette.from(bitmap).generate(new PaletteAsyncListener() {
    public void onGenerated(Palette palette) {
        // Use generated palette
    }
});

You can try the different methods available from the Palette class (ie getVibrantColor , getMutedColor , getDarkVibrantColor , etc.) to see which returns values you like. 您可以尝试使用Palette类中可用的其他方法(即getVibrantColorgetMutedColorgetDarkVibrantColor等),以查看喜欢的返回值。

您可以使用此库使背景或图像模糊不清https://github.com/faradaj/BlurBehind

An interesting question. 一个有趣的问题。 And the answer is not a straight forward one. 答案并非直截了当。

  1. Looking around I've found this article: How does photoshop calculate the "average blur" (average color) of an image? 环顾四周,我发现了这篇文章: photoshop如何计算图像的“平均模糊”(平均颜色)?
  2. Which points to this article, which has code: http://blog.soulwire.co.uk/code/actionscript-3/extract-average-colours-from-bitmapdata 指向本文的代码,其代码为: http : //blog.soulwire.co.uk/code/actionscript-3/extract-average-colours-from-bitmapdata
  3. This shouldn't be hard to implement on Android. 这在Android上应该不难实现。
  4. However, I do suggest you do not implement this in Java, which is very slow. 但是,我建议您不要在Java中实现它,这非常慢。 Rather do this on RenderScript , which is a Google technology designed for this type of missions - a cross architecture, highly optimized C code to handle graphic tasks and image manipulation. 而是在RenderScript上执行此操作, RenderScript是针对此类任务而设计的Google技术-跨体系结构,高度优化的C代码,用于处理图形任务和图像处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM