A mosaic implementation method, device and terminal equipment
Patent Information
- Application Number
- CN202211397541.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2042-11-09
AI Technical Summary
[0005]本发明提供了一种马赛克实现方法、装置和终端设备,以解决现有实现方式比较复杂、计算量过大、开发难度较大的技术问题
Smart Images

Figure CN115761055B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more particularly to a mosaic implementation method, apparatus, and terminal device. Background Technology
[0002] During the screenshot process, if a user does not want others to see certain content in the screenshot, or if the user needs to cover up important information in certain parts, they will use the mosaic function. This function degrades the color gradation details of a specific area of the image and creates a disordered color block effect.
[0003] In existing technologies, the steps for mosaic processing of images generally involve obtaining the mosaic selection area, first calculating the color values of the surrounding pixels in the area, and then modifying the RGB color values of the pixels. The underlying principle is to replace all points within a certain range of a pixel in the image with the color of a randomly selected pixel within that range.
[0004] The drawback of the existing technology is that the implementation method is relatively complex, requiring a large amount of calculation and modification of the color values of several pixels, which makes development difficult. Summary of the Invention
[0005] This invention provides a mosaic implementation method, apparatus, and terminal device to solve the technical problems of existing implementation methods being relatively complex, computationally intensive, and difficult to develop.
[0006] To address the aforementioned technical problems, this invention provides a mosaic implementation method, comprising the following steps: Receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image; Respond to the first path input by the user through the brush object, and obtain the first path effect corresponding to the first path; Adjust the brush object according to the blending mode of the first layer to obtain a layer blending brush; The global mosaic image is overlaid with the first path effect, making the global mosaic image the upper layer of the two layers. The intersection of the global mosaic image and the first path effect is obtained according to the layer blending brush to obtain the mosaic effect image. The mosaic image is obtained according to the mosaic effect image and the canvas object. The canvas object is obtained according to the image to be processed.
[0007] This invention provides a method for implementing a mosaic effect. By performing simple processing on the image to be processed, a global mosaic image is obtained. Responding to the user's input of a first path and its corresponding effect based on a brush object, the brush object is adjusted according to a first layer blending mode. Furthermore, the effect of the first path is adjusted based on the global mosaic image and the layer blending brush. This allows for the creation of a mosaic effect on irregular areas of the original image (the image to be processed) simply by touching the screen, forming a mosaic image. Compared to existing technologies, this method eliminates the need for extensive calculations and modifications to the positional information and RGB color values of numerous pixels, simplifying implementation and significantly reducing development difficulty. Furthermore, the reduced computational complexity results in faster processing and a lower probability of errors during processing.
[0008] As a preferred example, the step of receiving the image to be processed and performing global mosaic processing on the image to be processed specifically includes: Based on the first specified multiplier input by the user, the image to be processed is sequentially reduced in size and enlarged in size to obtain the global mosaic image.
[0009] This invention embodiment reduces the size of the original image (the image to be processed) by a first specified factor, and then enlarges it by the same factor. This simple operation of first reducing and then enlarging causes the image to lose some pixels, resulting in a blurred image due to distortion, thus achieving a simple global mosaic effect. Furthermore, the first specified factor can be set by the user based on the clarity and pixel values of the image to be processed.
[0010] By performing this simple operation of first reducing the size and then enlarging it, the global mosaic image can be obtained. This reduces the amount of calculation required for pixel positions and their corresponding RGB color values, improving processing speed and reducing the possibility of errors during processing.
[0011] As a preferred example, the response to the user inputting a first path through a brush object, and obtaining the first path effect corresponding to the first path, specifically involves: In response to the user's instruction to create a transparent layer, the system listens for touch events on the transparent layer, generates the first path based on several touch events input by the user through a brush object, and obtains the effect of the first path based on the transparent layer and the first path.
[0012] In this embodiment of the invention, the first path is formed by responding to the user's transparent layer creation operation and based on the detected touch event. The first path is then combined with the transparent layer to form the first path effect, ensuring that there are no other graphics on the layer except for the path drawn by the touch, thereby achieving a mosaic effect display in a specified area.
[0013] As a preferred example, listening to touch events on the transparent layer includes the following steps: Listen for touch events on the transparent layer and the coordinate points formed by the touch events; The touch events include: drop events, move events, and lift events.
[0014] The touch events monitored in this embodiment of the invention include, but are not limited to, drop events, move events, and lift events. At the same time, it also monitors several coordinate points formed by the above touch events to prepare for the subsequent path drawing.
[0015] As a preferred example, the step of generating the first path based on several touch events input by the user through a brush object, and obtaining the effect of the first path based on the transparent layer and the first path, specifically involves: The first path is obtained by connecting the coordinate points formed by the several touch events using a Bézier curve; The first path is combined with the transparent layer to obtain the effect of the first path.
[0016] The embodiments of the present invention use Bézier curves to draw paths, which can maximize the formation of paths that fit the user's movement trajectory.
[0017] As a preferred example, adjusting the brush object according to the first layer blending mode to obtain a layer blending brush specifically involves: The first layer blending mode includes: layer blending, anti-aliasing, and graphics filtering smoothing; Set the layer blending and anti-aliasing to on mode, and the graphic filtering and smoothing to off mode to obtain the layer blending brush; The layer blending involves obtaining the intersection of two layers and displaying the upper layer of the intersection.
[0018] In this embodiment of the invention, the brush object is adjusted according to the first layer blending mode, including layer blending, anti-aliasing, and graphic filtering smoothing. The layer blending and anti-aliasing are adjusted to the on mode, and the graphic filtering smoothing is adjusted to the off mode to obtain a layer blending brush.
[0019] The anti-aliasing is used to combat edge jaggedness; it is turned on to prevent edge jaggedness from affecting the image. The graphic filtering smoothing is turned off, meaning the bilinear filtering function is disabled, while the nearest zero interpolation filtering function is turned on to display the mosaic effect. Furthermore, because the zero interpolation filtering algorithm is simple, it also improves the image rendering speed. Adjusting the brush object according to the first layer blending mode prepares the brush object for later touch-based mosaic effects on irregular areas.
[0020] As a preferred example, obtaining the mosaic image based on the mosaic effect image and the canvas object specifically involves: The mosaic effect image is combined with the canvas object so that the mosaic effect image is the upper layer of the two layers above, thus obtaining the mosaic image.
[0021] In this embodiment of the invention, the mosaic image is obtained by combining the mosaic effect image with the canvas object, thereby realizing mosaic processing of irregular areas of the image.
[0022] Accordingly, this invention also provides a mosaic implementation device, including the following modules: a global mosaic processing module, a brush object adjustment module, and a mosaic image generation module; The global mosaic processing module is used to receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image. The brush object adjustment module is used to respond to the first path input by the user through the brush object, obtain the first path effect corresponding to the first path, and adjust the brush object according to the first layer blending mode to obtain a layer blending brush. The mosaic image generation module is used to overlap the global mosaic image with the first path effect, so that the global mosaic image is the upper layer of the two layers above. The module obtains the intersection of the global mosaic image and the first path effect according to the layer blending brush to obtain the mosaic effect image, and obtains the mosaic image according to the mosaic effect image and the canvas object.
[0023] This invention also provides an apparatus that can implement the above methods. It can be set automatically without manual user settings, and users can modify the parameters themselves if needed.
[0024] Accordingly, embodiments of the present invention also provide a terminal device, which includes the apparatus as described above and can realize the functions of all modules of the apparatus. Attached Figure Description
[0025] Figure 1: A flowchart illustrating one embodiment of a mosaic implementation method provided by the present invention; Figure 2 Another embodiment of the mosaic implementation method provided by the present invention is a flowchart; Figure 3 : A flowchart illustrating one embodiment of a method for adjusting a brush object provided by the present invention; Figure 4 This is a flowchart illustrating an embodiment of a method for obtaining a mosaic effect image and a mosaic image provided by the present invention. Figure 5 : A schematic diagram of one embodiment of a mosaic implementation device provided by the present invention. Detailed Implementation
[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] Example 1 Please refer to Figure 1 This is a flowchart illustrating one embodiment of a mosaic implementation method provided by the present invention. The method includes steps 101 to 104, each step being as follows: Step 101: Receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image.
[0028] In this embodiment, compared to existing technologies that require obtaining the mosaic selection area, calculating the color values around the pixels in the area, and then modifying the RGB color values of the pixels, the present invention obtains a global mosaic image by simply processing the image to be processed. Responding to the user's input of a first path and its corresponding effect based on the brush object, the brush object is adjusted according to the first layer blending mode. Furthermore, the effect of the first path is adjusted based on the global mosaic image and the layer blending brush. This allows for the creation of a mosaic effect on the original image (the image to be processed) by simply touching the screen, thus forming a mosaic image. This process is not only simpler to implement, greatly reducing development difficulty, but also faster due to the reduction in computational steps, and also reduces the possibility of errors during processing.
[0029] In this embodiment, the received image to be processed is the original image. The technical solution of the present invention first obtains the global mosaic image of the original image, and then obtains the mosaic effect image of the irregular area, making the implementation method simpler.
[0030] Step 102: Respond to the first path input by the user through the brush object and obtain the first path effect corresponding to the first path.
[0031] In this embodiment, the first path corresponds to the irregular area drawn by the user by touching the screen, and the effect of the first path is the position basis for obtaining the mosaic effect image of the irregular area later.
[0032] Step 103: Adjust the brush object according to the blending mode of the first layer to obtain the layer blending brush.
[0033] In this embodiment, the blending mode of the first layer can be adjusted according to the user's needs.
[0034] Step 104: Adjust the first path effect according to the global mosaic image and the layer blending brush to obtain a mosaic effect image, and obtain the mosaic map according to the mosaic effect image and the canvas object.
[0035] In this embodiment, the canvas object is obtained based on the image to be processed.
[0036] As another example of an embodiment of the present invention, see Figure 2 , Figure 2 Another embodiment of the mosaic implementation method provided by the present invention is a flowchart. For example... Figure 2 The above, Figure 2 and Figure 1 The difference lies in the fact that when performing global mosaic processing on the image to be processed, the method used in this example is to sequentially reduce and enlarge the image to be processed according to the first specified multiple input by the user, and obtain the global mosaic image.
[0037] In this example, the first specified multiplier is 8x. This multiplier was determined through multiple verifications. When using this multiplier, the mosaic effect on the image to be processed after global mosaic processing can achieve a suitable level of blur. Since the first specified multiplier is proportional to the degree of mosaic blur, users can define this multiplier as needed for images with different resolutions and pixel values.
[0038] In this example, by performing a simple operation of first shrinking and then enlarging the image to be processed according to a first specified multiple, some pixels are lost from the image, thus causing resolution distortion and achieving global mosaic processing. This simple operation achieves global mosaic processing of the image, reducing the amount of calculation required for pixel positions and their corresponding RGB color values, improving processing speed while also reducing the possibility of errors during processing.
[0039] As another example of an embodiment of the present invention, see Figure 3 , Figure 3 This is a flowchart illustrating an embodiment of a method for obtaining path effects and adjusting a brush object provided by the present invention. The method includes steps 301 to 303, each step being as follows: Step 301: Respond to the user's transparent layer creation command, listen for touch events on the transparent layer and several coordinate points formed by several touch events.
[0040] In this example, the touch events being monitored include, but are not limited to, drop events, move events, and lift events. At the same time, several coordinate points formed by the above touch events will also be monitored to prepare for the subsequent path drawing.
[0041] Step 302: Connect the coordinate points formed by the several touch events using a Bézier curve to obtain the first path, and combine the first path with the transparent layer to obtain the effect of the first path.
[0042] In this example, by connecting several coordinate points using a Bézier curve, a path that best fits the user's movement trajectory can be formed.
[0043] Step 303: Adjust the brush object according to the first layer blending mode, including: adjusting the layer blending and anti-aliasing to the on mode, and adjusting the graphic filtering and smoothing to the off mode, to obtain the layer blending brush.
[0044] In this example, the first layer blending mode includes, but is not limited to, anti-aliasing, layer blending, and graphic filtering smoothing. Anti-aliasing is used to combat edge jaggedness; setting it to "on" prevents edge jaggedness from affecting the image. Graphic filtering smoothing is set to "off," meaning bilinear filtering is disabled while nearest-zero interpolation filtering is enabled, allowing the mosaic effect to be displayed. Furthermore, the simple algorithm of zero-interpolation filtering also improves the image rendering speed. Layer blending is enabled, allowing the brush object to capture the intersection of two layers and display the upper layer of the intersection. Through these adjustments, the brush object achieves the effect of obtaining a mosaic image later.
[0045] In this example, the user can adjust the brush width of the brush object as needed. Once the brush width is determined, the size of the mosaic in the specified area can be determined.
[0046] As another example of this embodiment, see Figure 4 , Figure 4 This is a flowchart illustrating an embodiment of a method for obtaining a mosaic effect image and a mosaic image provided by the present invention. Figure 4 As shown, steps 401 and 402 are Figure 1 In one specific implementation of step 104, the layer blending brush is used to find the intersection of the global mosaic image and the transparent layer of the carrier of the first path effect, and the upper image of the intersection portion, i.e., the global mosaic image, is displayed, thereby obtaining the mosaic effect image. The mosaic effect image is then combined with the canvas object to obtain the mosaic map.
[0047] Meanwhile, in this example, using this method to obtain a mosaic effect image of a specified irregular area is simple and convenient. Compared with existing technologies, it eliminates most of the color selection process and RGB color value calculation process.
[0048] To better illustrate the working principle and steps of the mosaic implementation method and system of the present invention, please refer to the relevant descriptions above, but not limited to.
[0049] Accordingly, see Figure 5 , Figure 5 A schematic diagram of an embodiment of a mosaic implementation device provided by the present invention includes the following modules: a global mosaic processing module 501, a brush object adjustment module 502, and a mosaic image generation module 503. The global mosaic processing module 501 is used to receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image. The brush object adjustment module 502 is used to respond to the first path input by the user through the brush object, obtain the first path effect corresponding to the first path, and adjust the brush object according to the first layer blending mode to obtain a layer blending brush. The mosaic image generation module 503 is used to adjust the first path effect according to the global mosaic image and the layer blending brush to obtain a mosaic effect image, and to obtain the mosaic image according to the mosaic effect image and the canvas object.
[0050] Similarly, this embodiment of the invention also provides a terminal device, which includes the apparatus described above and can implement the functions of all modules of the apparatus. Both the apparatus and the terminal device require no manual user setup and can be automatically configured. If the user needs to modify any parameters, they can do so themselves.
[0051] In summary, this invention provides a mosaic implementation method, apparatus, and terminal device. By using a layer blending brush and a global mosaic image, a mosaic effect is achieved on a specified irregular area of the image to be processed. The implementation method is simpler, greatly reducing the difficulty of development. At the same time, because a large number of calculation processes are reduced, the processing is faster, and the possibility of errors generated during processing is also reduced.
[0052] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for implementing mosaic effects, characterized in that, Includes the following steps: Receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image; Respond to the first path input by the user through the brush object, and obtain the first path effect corresponding to the first path; Adjust the brush object according to the blending mode of the first layer to obtain a layer blending brush; The global mosaic image is overlaid with the first path effect, making the global mosaic image the upper layer of the two layers above. The intersection of the global mosaic image and the first path effect is obtained according to the layer blending brush to obtain the mosaic effect image. The mosaic image is obtained according to the mosaic effect image and the canvas object. The canvas object is obtained according to the image to be processed.
2. The mosaic implementation method as described in claim 1, characterized in that, The process of receiving the image to be processed and performing global mosaic processing on the image to be processed specifically includes: Based on the first specified multiplier input by the user, the image to be processed is sequentially reduced in size and enlarged in size to obtain the global mosaic image.
3. The mosaic implementation method as described in claim 1, characterized in that, The response to the user inputting a first path through a brush object, and obtaining the first path effect corresponding to the first path, specifically involves: In response to the user's instruction to create a transparent layer, the system listens for touch events on the transparent layer, generates the first path based on several touch events input by the user through a brush object, and obtains the effect of the first path based on the transparent layer and the first path.
4. The mosaic implementation method as described in claim 3, characterized in that, Listening for touch events on the transparent layer includes the following steps: Listen for touch events on the transparent layer and the coordinate points formed by the touch events; The touch events include: drop events, move events, and lift events.
5. A mosaic implementation method as described in claim 4, characterized in that, The process of generating the first path based on several touch events input by the user through a brush object, and obtaining the effect of the first path based on the transparent layer and the first path, specifically involves: The first path is obtained by connecting the coordinate points formed by the several touch events using a Bézier curve; The first path is combined with the transparent layer to obtain the effect of the first path.
6. A mosaic implementation method as described in claim 4, characterized in that, The step of adjusting the brush object according to the blending mode of the first layer to obtain a layer blending brush is as follows: The first layer blending mode includes: layer blending, anti-aliasing, and graphics filtering smoothing; Set the layer blending and anti-aliasing to on mode, and the graphic filtering and smoothing to off mode to obtain the layer blending brush; The layer blending involves obtaining the intersection of two layers and displaying the upper layer of the intersection.
7. A mosaic implementation method as described in claim 1, characterized in that, The process of obtaining the mosaic image based on the mosaic effect image and the canvas object specifically involves: The mosaic effect image is combined with the canvas object so that the mosaic effect image is the upper layer of the two layers above, thus obtaining the mosaic image.
8. A mosaic rendering device, characterized in that, It includes the following modules: global mosaic processing module, brush object adjustment module, and mosaic image generation module; The global mosaic processing module is used to receive the image to be processed and perform global mosaic processing on the image to be processed to obtain a global mosaic image. The brush object adjustment module is used to respond to the first path input by the user through the brush object, obtain the first path effect corresponding to the first path, and adjust the brush object according to the first layer blending mode to obtain a layer blending brush. The mosaic image generation module is used to overlap the global mosaic image with the first path effect, so that the global mosaic image is the upper layer of the two layers above. The module obtains the intersection of the global mosaic image and the first path effect according to the layer blending brush to obtain the mosaic effect image, and obtains the mosaic image according to the mosaic effect image and the canvas object.
9. A terminal device, characterized in that, The device includes the apparatus as described in claim 8 and is capable of performing the functions of all modules of the apparatus.
Citation Information
Patent Citations
Method and device for conducting mosaic processing on picture
CN104299186A
Screenshot processing method and device based on instant communication tool
CN105892839A