Not much nonsense, first.
Source image
Circular clear area
Clear horizontal area
Vertical clear area
Hey, it looks okay ~~ The background we are talking about here is virtualized. Naturally, we cannot automatically identify the background and prospects. Therefore, it can only be regarded as a semi-automated process: Which region is clearly specified by users, which region is blurred, and then make a simple transition between a clear region and a blurred region.
Here we provide three modes: Circular clear area, vertical clear area, and horizontal clear area. As shown below
Circle
Horizontal
Vertical
If you want to make other shapes, you can refer to the code behind me to do it yourself.
I don't want to talk about Gaussian blur or other things here. I believe that the existing blog has already written down Gaussian blur. I just borrowed an idea in Image Blur: I used the average value of surrounding pixels to replace the current pixel. In Gaussian blur, different weights are assigned to pixels at different locations around the pixels. For simplicity, all weights are the same. The results are also good.
All the code is provided below.
Package algorithm. blur; import Java. AWT. color; import Java. AWT. image. bufferedimage; public class interactiveblur {// minimum value of the mask public static final int min_mask_size = 3; // maximum value of the mask public static final int max_mask_size = 15; // public static final int half_max_mask_size = 7; // difference between the minimum and maximum values public static final int diff_mask_size = max_mask_size-min_mask_size; // point in the blur area public static final int area_blur = 1; // point in the clear area public static final int area_clear = 2; // point in the transition area public static final int area_tran = 3; // The Circular clear area public static final int type_circle = 1; // vertical clear area public static final int type_vertcial = 2; // horizontal clear area public static final int type_horizontal = 3; // The external areas are all non-fuzzy Private Static int outsize; // The internal areas are all clear Private Static int innersize; // The Private Static int area; private Static color [] [] colormatrix; /***** obtain the image ** @ Param image * Source image * @ Param x * x coordinate * @ Param y * Y coordinate * @ Param size * function range * @ Param type * type **/public static bufferedimage getimage (bufferedimage image, int X, int y, int size, int type) {interactiveblur. innersize = size; interactiveblur. outsize = (INT) (size * 1.5); // obtain the RGB matrix colormatrix = getcolormatrix (image); Switch (type) {Case type_vertcial: Return getvecticalimage (image, X, size); Case type_horizontal: Return gethozizontalimage (image, Y, size); default: Return getcircleimage (image, X, Y, size );}} /*** obtain the clear area of the circle ** @ Param image * Source image * @ Param x * x coordinate * @ Param y coordinate * @ Param size * scope of action ** /Private Static bufferedimage getcircleimage (bufferedimage image, int centerx, int centery, int size) {int width = image. getwidth (); int Height = image. getheight (); bufferedimage outputimage = new bufferedimage (width, height, bufferedimage. type_int_rgb); For (INT y = half_max_mask_size; y
Blur background of Image Processing