如何在Android的图像模糊图像、模糊、如何在、Android

2023-09-06 05:10:06 作者:遇。

您好我试着去实现对图像有一定的影响如图片边框和一些颜色不同 现在即时通讯试图让这样的模糊图像

hi i m trying to implement some effect on image like image border and some color various and now i m trying to make blur image like this

图像的中心部分是清晰可见的和其他部分被模糊

the center part of image is clearly visible and other part are blur

听到的是链接巫婆我指 http://www.jhlabs.com/ip/filters/VariableBlurFilter.html

hear is the link witch i refer http://www.jhlabs.com/ip/filters/VariableBlurFilter.html

但其不同于此图像中(此lib目录中的java,所以我转换BufferdImage位图,但现在这是我的脑海)任何一个可以帮助我在此。

but its different from this image(this lib in java so i convert BufferdImage to bitmap but now it's out of my mind) can any one help me in this..

推荐答案

抱歉这么晚才回复。我忘了检查计算器本周末。

Sorry for the late reply. I forgot to check stackoverflow this weekend.

总之,我认为你应该做的是这样的(它被简化为灰度,但应该很容易作出的工作于RGB):

Anyway, what I think you should do is something like this (it's been simplified to grayscale, but should be easily made to work for RGB):

oim = original image
xc, yc = center point
d = distance from center point for in-focus
fval = zeros, matrix size of oim
max_blur = maximum blur radius
for all pixels (xp,yp) in oim
    dist = sqrt((xp-xc)^2+(yp-yc)^2)
    dist = dist-d // we only care about the area beyond the clear area
    if dist>0
       blur = dist
    end
    if blur>max_blur
       blur = max_blur // this can also be scaled or whatever works for your needs
    end
    blur = round(blur)
    fval(xp,yp) = blur
end
nim = oim
for b=1:max_blur
    blurred = blur_function(oim,b)
    for all pixels (xp,yp) in fval
       if fval(xp,yp) == b
          nim(xp,yp) = blurred(xp,yp)
       end
     end
end

净息差现在是新的形象

nim is now new image

所以基本上这里发生的事情是,我们首先做一个排序查找表,告诉我们有多少模糊一个给定的像素。聚焦值是从透明区域中的每个像素的距离的函数的。这是矩阵未来值。然后,我们图像模糊多次,每次更新从模糊图像的新像素数据的新形象,只更新给定像素,如果我们正在更新为散焦水平。

So basically what happens here is that we first make a sort of lookup table that tells us how much to blur a given pixel. The focus values are a function of each pixel's distance from the clear area. This is the matrix fval. We then blur the image multiple times and each time update the new image with the new pixel data from the blurred image, and only update a given pixel if we are updating for that de-focus level.

该blur_function可以是任何东西。当我测试了我自己,我在Matlab使用平均模糊。

The blur_function can be anything. When I tested this myself, I used average blur in MatLab.

希望这有助于!