An image processing method, apparatus, and storage medium

By introducing transparency channels and the second layer in the image processing, the problem of low color filling efficiency in irregular areas is solved, and more efficient image processing is achieved, reducing image hysteresis and lag.

CN113989419BActive Publication Date: 2025-07-01PACTERA INTELLIGENCE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111326941.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2025-07-01
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

When the prior art fills the irregular areas in color, the boundaries of the areas need to be calculated multiple times, resulting in low image processing efficiency and prone to image hysteresis and lag.

Method used

By introducing transparency channels in image processing and creating a second layer for filling operations, algorithm processing near boundaries is streamlined and filling efficiency is improved.

Benefits of technology

When filling the fill area to be filled, this method significantly improves processing efficiency, reduces image hysteresis and lags, and improves the overall image processing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113989419B_ABST
    Figure CN113989419B_ABST
Patent Text Reader

Abstract

The present application discloses an image processing method, apparatus, and storage medium, including: determining a first area to be filled in an image to be processed; displaying, on a second layer, a second area to be filled corresponding to the first area to be filled in a first layer, wherein the channel value of the transparency channel of each pixel point in the second area to be filled is set to a first value, determining a target external area of the second area to be filled according to the second area to be filled, and setting the channel value of the transparency channel of each pixel point in the target external area to a second value; receiving a filling operation performed on the second area to be filled on the second layer to obtain a filled area; and obtaining a processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer. When filling the area to be filled through the present application, the algorithm processing for color filling near the boundary of the area to be filled is streamlined, and the filling efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing. Specifically, it relates to an image processing method, apparatus, and storage medium. Background Art

[0002] With the development of image acquisition technology, more and more images can be obtained through image acquisition devices. However, after obtaining an image, the color of some or all areas in the image may not be what the user wants; or, the color effect of some or all areas in the image is not good, resulting in poor overall image quality. For example, when an image includes a person, the hair color, clothing color, etc. of the person may not meet the user's expectations or have a poor effect. In this case, it is necessary to adjust the color of some or all areas in the image.

[0003] The areas in the image that need to be adjusted are often irregular graphic areas, such as the hair area. In the prior art, when filling an irregular area, the boundary of the irregular area needs to be calculated multiple times. Therefore, problems such as image lag and stuttering are likely to occur during the filling of irregular areas, greatly reducing the efficiency of image filling. Summary of the Invention

[0004] The purpose of the embodiments of this application is to provide an image processing method, apparatus, and storage medium. When filling a to-be-filled area through this application, the algorithm processing for color filling near the boundary of the to-be-filled area is streamlined, improving the filling efficiency.

[0005] To achieve the above purpose, the technical solutions adopted in the embodiments of this application are as follows:

[0006] In a first aspect, the embodiments of this application propose an image processing method, which includes: determining a first to-be-filled area in a to-be-processed image according to the contour drawing result of the to-be-processed image and / or the recognition result of character recognition in the to-be-processed image received in a first layer; creating a second layer above the first layer, where the second layer is in a target display mode, and the target display mode includes an alpha channel; determining a second to-be-filled area in the second layer corresponding to the first to-be-filled area; setting the channel value of the alpha channel of each pixel point in the second to-be-filled area to a first value; determining a target external area of the second to-be-filled area according to the second to-be-filled area, and setting the channel value of the alpha channel of each pixel point in the target external area to a second value; receiving a filling operation performed on the second to-be-filled area on the second layer to obtain a filled area; and obtaining a processed to-be-processed image based on the to-be-processed image in the first layer and the filled area in the second layer.

[0007] Optionally, a first area to be filled in the image to be processed is determined according to the result of drawing the contour of the image to be processed received in the first layer, including: generating a first virtual brush on the first layer in response to a selection operation performed on the first brush control; obtaining the first area to be filled from the corresponding contour of the image to be processed on the first layer in response to a drawing operation performed on the first virtual brush.

[0008] Optionally, the first value indicates that the transparency of each pixel point in the second area to be filled is completely opaque, and the second value indicates that the transparency of each pixel point in the target external area is completely transparent; and / or, the first area to be filled is irregular in shape.

[0009] Optionally, the channel value of the transparency channel of the second layer is set to the second value.

[0010] Optionally, the image processing method further includes: determining the circumscribed rectangle of the first area to be filled; while displaying the second area to be filled on the second layer, also displaying the circumscribed rectangle, and the transparency of each pixel point in the area within the circumscribed rectangle and outside the second area to be filled is completely transparent.

[0011] Optionally, receiving a filling operation performed on the second area to be filled on the second layer to obtain a filled area, including: determining the circumscribed rectangle of the first area to be filled on the second layer according to the coordinates of all pixel points in the first area to be filled; determining the drawing operation area according to the selection operation on the second brush control; determining the effective filling area according to the circumscribed rectangle and the drawing operation area; filling the effective filling area with the target color corresponding to the filling operation, and taking the filled effective filling area as the filled area.

[0012] Optionally, the circumscribed rectangle of the first area to be filled is determined by the following method: traversing the coordinates of all pixel points in the first area to be filled; obtaining the maximum abscissa value, minimum abscissa value, maximum ordinate value, and minimum ordinate value among the coordinates of all pixel points in the first area to be filled; taking the minimum abscissa value and minimum ordinate value among all pixel points as the upper left vertex coordinates of the circumscribed rectangle; taking the maximum abscissa value and maximum ordinate value among all pixel points as the lower right vertex coordinates of the circumscribed rectangle; determining the circumscribed rectangle from the lower right vertex coordinates and upper left vertex coordinates of the circumscribed horizontal rectangle.

[0013] Optionally, the steps of determining the drawing operation area according to the selection operation for the second brush control include: The steps of obtaining the filled area include: responding to the selection operation for the second brush control, generating a second virtual brush on the second layer; responding to the color configuration operation for the fill color selection control, determining the target fill color corresponding to the second virtual brush; responding to the drawing operation performed on the second virtual brush, determining the drawing operation area, and filling the target fill color corresponding to the drawing operation area into the second area to be filled, so that the channel values of the color channels of the second area to be filled are replaced with the channel values of the color channels corresponding to the target fill color, and obtaining the filled area.

[0014] Optionally, the method further includes: responding to the configuration operation for the stroke width configuration control, and responding to the drawing operation performed on the second virtual brush, the steps of determining the drawing operation area include: determining the abscissa value, ordinate value of the drawing point of the second virtual brush on the second layer, and the stroke width value of the second virtual brush; determining the abscissa value of the upper left vertex of the drawing operation area by subtracting half of the stroke width value from the abscissa value of the drawing point of the second virtual brush, and determining the ordinate value of the upper left vertex of the drawing operation area by subtracting half of the stroke width value from the ordinate value of the drawing point of the second virtual brush.

[0015] In a second aspect, an image processing apparatus is further provided in an embodiment of the present application. The image processing apparatus includes: a first determination module, configured to determine a first area to be filled in the image to be processed according to the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer; a creation module, configured to create a second layer above the first layer, and the second layer is in a target display mode, and the target display mode includes a transparency channel; a second determination module, configured to determine the area corresponding to the first area to be filled in the second layer as the second area to be filled; a first setting module, configured to set the channel value of the transparency channel of each pixel point in the second area to be filled to a first value; a second setting module, configured to determine the second area to be filled according to the second area to be filled, and set the channel value of the transparency channel of each pixel point in the target external area of the target external area to a second value; a filling module, configured to receive the filling operation for the second area to be filled performed on the second layer, and obtain the filled area; an acquisition module, configured to obtain the processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer.

[0016] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, it executes the steps of the image processing method as described above.

[0017] The present application discloses an image processing method, apparatus, and storage medium, including: determining a first area to be filled in the image to be processed according to the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer; creating a second layer above the first layer, where the second layer is in a target display mode, and the target display mode includes an alpha channel; determining the area corresponding to the first area to be filled in the second layer as the second area to be filled; setting the channel value of the alpha channel of each pixel point in the second area to be filled to a first value; determining the target external area of the second area to be filled according to the second area to be filled, and setting the channel value of the alpha channel of each pixel point in the target external area to a second value; receiving a filling operation performed on the second area to be filled on the second layer to obtain a filled area; and obtaining the processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer. Through the present application, when filling the area to be filled, the algorithm processing for color filling near the boundary of the area to be filled is streamlined, and the filling efficiency is improved.

[0018] Other features and advantages of the present application will be described in the subsequent specification, and, in part, will be obvious from the specification, or can be understood by implementing the embodiments of the present application. The objectives and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written specification, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 The flowchart of the image processing method provided by the embodiments of the present application is shown.

[0021] Figure 2 The flowchart of the steps for determining the first area to be filled provided by the embodiments of the present application is shown.

[0022] Figure 3 The flowchart of the steps for obtaining the filled area provided by the embodiments of the present application is shown.

[0023] Figure 4 The schematic diagram of the first embodiment for determining the overlapping area provided by the embodiments of the present application is shown.

[0024] Figure 5Shows a schematic diagram of the second embodiment of determining the overlapping area provided by the embodiments of the present application.

[0025] Figure 6 Shows a schematic diagram of the third embodiment of determining the overlapping area provided by the embodiments of the present application.

[0026] Figure 7 Shows a schematic diagram of the fourth embodiment of determining the overlapping area provided by the embodiments of the present application.

[0027] Figure 8 Shows a schematic diagram of the fifth embodiment of determining the overlapping area provided by the embodiments of the present application.

[0028] Figure 9 Shows a schematic diagram of the structure of the image processing device provided by the embodiments of the present application. Detailed implementation manners

[0029] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Usually, the components of the embodiments of the present application described and shown in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents the selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.

[0030] It should be noted that: similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present disclosure, the terms "first", "second", etc. are only used for distinguishing descriptions, and cannot be understood as indicating or implying relative importance.

[0031] The present application proposes an image processing method, see Figure 1 , Figure 1 Shows a flowchart of the image processing method provided by the embodiments of the present application. Specifically, this method is applied to a terminal device, such as Figure 1 shown, this image processing method includes:

[0032] S100. Determine a first area to be filled in the image to be processed according to the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer.

[0033] The method provided by the embodiment of the present invention can be applied to a terminal device. For example, it can be any terminal device with image processing functions, such as a desktop computer, a portable computer, a smart mobile terminal, etc.

[0034] In a preferred embodiment, the graphical user interface of the terminal device includes an image display area. The graphical user interface can obtain the image to be processed and display it in the image display area. At this time, the layer where the obtained image to be processed is located can be defined as the first layer of the graphical user interface, and the user can create a new layer in the graphical user interface as needed to meet different processing requirements.

[0035] Specifically, the user can determine the first area to be filled on the first layer according to the coloring requirement. The user can perform an editing operation on the image to be processed on the first layer, and draw the outline of the first area to be filled that the user wants to fill on the image to be processed, so as to determine the first area to be filled in the image to be processed according to the outline drawing result.

[0036] Specifically, refer to Figure 2 , Figure 2 shows a flowchart of the steps for determining the first area to be filled provided by the embodiment of the present application. The first area to be filled in the image to be processed is specifically determined in the following manner:

[0037] S110. Respond to the selection operation performed on the first paint control, and generate a first virtual paintbrush on the first layer.

[0038] When the user needs to adjust the color of a certain area of the image to be processed, the corresponding area needs to be selected first. For example, when the user needs to adjust the color of the bow in a certain image to be processed, at this time, the area where the bow is located needs to be determined as the first area to be filled in the image to be processed. Specifically, the graphical user interface provided by the embodiment of the present application includes a first paint control. The selection operation performed on the first paint control can be a single click, a double click, or a long press on the first paint control. By performing the selection operation on the first paint control, a first virtual paintbrush will be generated on the image to be processed located on the first layer.

[0039] S120. Respond to the drawing operation performed on the first virtual paintbrush, and draw a contour corresponding to the image to be processed on the first layer to obtain the first area to be filled.

[0040] In a preferred embodiment, the user can draw a closed contour of the first area to be filled on the first layer by dragging the first virtual paintbrush to form the first area to be filled. The first area to be filled is an irregular area. For example, the contour of the first area to be filled can be in the shape of a bow.

[0041] In an alternative embodiment, the user can specify the first area to be filled by using the first virtual paintbrush to sequentially increase or decrease or move vertices as needed. After the vertices are confirmed and specified, the vertices are connected in the specified order, and the last vertex is automatically connected to the initial vertex to form a closed first area to be filled. Secondly, the user can also directly place a polygon with the first virtual paintbrush to determine the first area to be filled. The shape of the first virtual paintbrush is not limited here. It can be directly used to draw the desired shape, or the paintbrush itself can directly be a closed figure surrounded by vector curves, which is not specifically limited here.

[0042] In another specific embodiment of the present application, if filling a text area, the text area to be filled can also be determined by OCR (Optical Character Recognition), and the returned text area is determined as the first area to be filled. The first area to be filled can also be determined by using a convolution algorithm to obtain the boundary of the color block. The method for determining the first area to be filled in the to-be-processed image is not specifically limited here.

[0043] Return Figure 1 , S200, Create a second layer above the first layer.

[0044] Specifically, the second layer is in the target display mode. The target display mode includes an alpha channel. After the first area to be filled is drawn, a second layer is automatically created on the basis of the first layer, and the display mode of the second layer is set to the target display mode. The target display mode also includes a color channel. In the target display mode, the transparency of the second layer can be determined by setting the value of the alpha channel of the second layer.

[0045] S300, Determine the area corresponding to the first area to be filled in the second layer as the second area to be filled.

[0046] Here, after the first area to be filled is determined in the first layer, the second area to be filled corresponding to the first area to be filled can be directly displayed at the position corresponding to the first area to be filled in the second layer.

[0047] S400, Set the channel value of the alpha channel of each pixel point in the second area to be filled to a first value.

[0048] Specifically, the first value indicates that the transparency of each pixel point in the second area to be filled is completely opaque.

[0049] S500, Determine the target external area of the second area to be filled according to the second area to be filled, and set the channel value of the alpha channel of each pixel point in the target external area to a second value.

[0050] Here, the second value indicates that the transparency of each pixel in the target external area is completely transparent.

[0051] Specifically, setting the channel value of the transparency channel of each pixel in the target external area of the second area to be filled can be divided into the following two methods:

[0052] In the first method, before displaying the second area to be filled on the second layer, first set the channel values of the transparency channels of all pixels in the second layer to be completely transparent, then display the second area to be filled, and then set the transparency of each pixel in the second area to be filled to be completely opaque. At this time, the target external area of the second area to be filled is the entire area on the second layer except the second area to be filled.

[0053] Specifically, the transparency corresponding to each pixel can be changed by setting the channel value of the transparency channel of each pixel in the second layer. When the transparency of a pixel is completely opaque, the color corresponding to the color channel is displayed. When the transparency of a pixel is completely transparent, the pixel does not display the color corresponding to its own color channel, and at this time the entire pixel is in a transparent state. For example, when the first value is 1, it can indicate that the pixel is completely opaque, and when the first value is 0, it can indicate that the pixel is completely transparent. Here, first set the channel values of the transparency channels of all pixels in the second layer to the value corresponding to complete transparency, and then display the second area to be filled.

[0054] Then, display the second area to be filled corresponding to the first area to be filled drawn in the first layer in the created second layer. The second area to be filled has exactly the same shape as the first area to be filled and covers the first area to be filled. Then set the transparency of each pixel in the second area to be filled to be completely opaque. At this time, since the transparency of the pixels on the second layer except the second area to be filled is completely transparent, there is no need to change the channel value of the transparency channel of the target external area of the second area to be filled.

[0055] In the second method, do not set the transparency of the second layer. First, display the second area to be filled on the second layer, then set the channel value of the transparency channel of each pixel to be completely opaque, and then set the pixels in the target external area of the second area to be filled to be completely transparent.

[0056] In the second method, it is necessary to first clarify the target external area of the second area to be filled. Specifically, the target external area of the second area to be filled can be determined by the following method:

[0057] In a preferred embodiment, while the second area to be filled is displayed on the second layer, the circumscribed rectangle of the first area to be filled is also displayed. The area within the circumscribed rectangle and outside the second area to be filled is used as the target external area of the second area to be filled, and the transparency of each pixel point in the target external area is set to completely transparent.

[0058] In another preferred embodiment, the target external area of the second area to be filled can also be determined in the following way:

[0059] In a preferred embodiment, while the second area to be filled is displayed on the second layer, the circumscribed rectangle of the first area to be filled is also displayed. The area within the circumscribed rectangle and outside the second area to be filled is used as the target external area of the second area to be filled, and the transparency of each pixel point in the target external area is set to completely transparent.

[0060] In a preferred embodiment, on the second layer, it can be determined whether a certain pixel point belongs to the second area to be filled by determining the channel value of the transparency channel corresponding to each pixel point. For example, if the channel value of the transparency channel of a certain pixel point on the second layer is equal to 0, that is, the pixel point is completely transparent, indicating that the pixel point is in the target external area of the second area to be filled. When the channel value of the transparency channel of a certain pixel point on the second layer is equal to 1, that is, the pixel point is completely opaque, indicating that the pixel point is inside the second area to be filled.

[0061] S600. Receive the filling operation on the second layer for the second area to be filled to obtain the filled area.

[0062] Specifically, the graphical user interface further includes a second brush control and a filling color selection control corresponding to the second brush control. The user can fill the second area to be filled with a specified color by using the second brush control. Specifically, see Figure 3 , Figure 3 which shows the flowchart of the steps for obtaining the filled area provided by the embodiments of the present application.

[0063] S610. Determine the circumscribed rectangle of the first area to be filled on the second layer according to the pixel coordinates of the first area to be filled.

[0064] Specifically, in the embodiments of the present application, after determining the first area to be filled, the circumscribed rectangle of the first area to be filled will be determined. Specifically, the circumscribed rectangle of the first area to be filled can be determined in the following way:

[0065] Traverse the coordinates of all pixel points in the first area to be filled. Specifically, after determining the first area to be filled, obtain the coordinates of all pixel points located inside the first area to be filled in the entire image to be processed, traverse these coordinates, and obtain the maximum abscissa value, minimum abscissa value, maximum ordinate value, and minimum ordinate value among the coordinates of all pixel points in the first area to be filled. Use the minimum abscissa value and minimum ordinate value among all pixel points in the first area to be filled as the coordinates of the upper left vertex of the circumscribed rectangle, and use the maximum abscissa value and maximum ordinate value among all pixel points in the first area to be filled as the coordinates of the lower right vertex of the circumscribed rectangle. Use the coordinates of the lower right vertex and upper left vertex of the circumscribed horizontal rectangle as the diagonal of the circumscribed rectangle to determine the circumscribed rectangle.

[0066] In a specific embodiment, if the user specifies the first area to be filled by editing the vertices, the user only needs to traverse the vertex coordinates of the first area to be filled to confirm the circumscribed rectangle.

[0067] S620. Determine the drawing operation area according to the selection operation for the second brush control.

[0068] Specifically, the steps of determining the drawing operation area according to the selection operation for the second brush control include:

[0069] Respond to the selection operation for the second brush control and generate a second virtual brush on the second layer.

[0070] In a preferred embodiment, the selection operation can be a single click, double click, or drag of the second brush control, which is not limited here. For example, when the user clicks the second virtual brush, a second virtual brush can be generated correspondingly on the second layer. The second virtual brush is used to fill the second area to be filled.

[0071] Respond to the color configuration operation for the fill color selection control and determine the target fill color corresponding to the second virtual brush.

[0072] In a preferred embodiment, the user needs to specify a target fill color for the second virtual brush according to the filling requirement. Specifically, the user can display a primary color palette on the graphical user interface by means of single clicking, double clicking, or dragging the fill color selection control, etc., and specify a color for the second virtual brush through the primary color palette, and determine this color as the target fill color.

[0073] In another preferred embodiment, the graphical user interface further includes a fill effect selection control. The user can specify a target fill effect for the second virtual brush according to the filling requirement. Specifically, the user can specify the target fill effect for the second virtual brush by means of single clicking or double clicking the fill effect selection control, etc. The target fill effects include texture effects, gradient effects, etc., which are not specifically limited here.

[0074] Determine the drawing operation area in response to the drawing operation performed on the second virtual brush.

[0075] Specifically, the drawing operation can be point-by-point filling or box selection filling. Specifically, in a preferred embodiment, when the drawing operation is point-by-point filling, the drawing operation area is determined in the following manner:

[0076] Determine the abscissa value, ordinate value of the drawing point of the second virtual brush on the second layer, and the stroke width value of the second virtual brush. Specifically, the graphical user interface further includes a stroke width configuration control corresponding to the second brush control. The user can determine the stroke width value corresponding to the second virtual brush through the stroke width configuration control. After generating the second virtual brush, the user controls the second virtual brush to click or double-click a point within the second area to be filled to obtain the abscissa value and ordinate value of the current drawing point of the second virtual brush. The drawing point is the center point of the pen-down position of the second virtual brush.

[0077] Determine the abscissa value of the upper left vertex of the drawing operation area by subtracting half of the stroke width value from the abscissa value of the drawing point of the second virtual brush, and determine the ordinate value of the upper left vertex of the drawing operation area by subtracting half of the stroke width value from the ordinate value of the drawing point of the second virtual brush.

[0078] A diagonal line is formed by the coordinates of the upper left vertex of the drawing operation area and the coordinates of the lower right vertex of the drawing operation area, thereby determining a horizontally placed drawing operation area.

[0079] In another preferred embodiment, when the drawing operation is box selection filling, the drawing operation area is determined in the following manner:

[0080] In response to the drag-and-drop operation on the second virtual brush, obtain the starting point abscissa, starting point ordinate, ending point abscissa, and ending point ordinate of the drag-and-drop operation.

[0081] Compare the abscissa values of the starting point and the ending point of the drag-and-drop operation, take the larger one as the maximum drag-and-drop abscissa, and the smaller one as the minimum drag-and-drop abscissa. Compare the ordinate values of the starting point and the ending point of the drag-and-drop operation, take the larger one as the maximum drag-and-drop ordinate, and the smaller one as the minimum drag-and-drop ordinate.

[0082] Determine the abscissa value of the first vertex of the diagonal of the drawing operation area by subtracting half of the stroke width value from the minimum drag-and-drop abscissa value of the second virtual brush, and determine the ordinate value of the first vertex of the diagonal of the drawing operation area by subtracting half of the stroke width value from the minimum drag-and-drop ordinate value of the second virtual brush.

[0083] Determine the abscissa value of the second vertex of the diagonal of the drawing operation area as the sum of the maximum abscissa value of the drag-and-drop of the second virtual brush and half of the stroke width value, and determine the ordinate value of the second vertex of the diagonal of the drawing operation area as the sum of the maximum ordinate value of the drag-and-drop of the second virtual brush and half of the stroke width value.

[0084] The diagonal is composed of the coordinates of the first vertex of the diagonal of the drawing operation area and the coordinates of the second vertex of the diagonal of the drawing operation area, and thus a horizontally placed drawing operation area can be determined.

[0085] S630. Determine the effective filling part according to the circumscribed rectangle and the drawing operation area.

[0086] In a preferred embodiment, the target filling color corresponding to the drawing operation area is filled into the second area to be filled in the following manner:

[0087] Determine the effective filling area corresponding to the second area to be filled according to the positional relationship between the drawing operation area and the second area to be filled.

[0088] Specifically, when the drawing operation area is located inside the second area to be filled, the effective filling area is the drawing operation area.

[0089] When a part of the drawing operation area is located inside the second area to be filled and a part is located in the target external area of the second area to be filled, it includes:

[0090] When the target external area of the second area to be filled is all areas on the second layer except the second area to be filled, that is, when the pixels of the second layer are completely transparent except for the second area to be filled, the effective filling area is the drawing operation area.

[0091] When the target external area of the second area to be filled is the area inside the circumscribed rectangle on the second layer and outside the second area to be filled, that is, when the transparency of the second layer is not set to be completely transparent at this time, the effective filling area is the overlapping area of the drawing operation area and the circumscribed rectangle.

[0092] In a preferred embodiment, the overlapping area of the drawing operation area and the circumscribed rectangle can be determined in the following manner:

[0093] Compare the coordinates of the upper left vertex of the drawing operation area, the coordinates of the lower right vertex of the drawing operation area, the coordinates of the upper left vertex of the circumscribed rectangle, and the coordinates of the lower right vertex of the circumscribed rectangle to obtain the coordinates of the upper left vertex of the overlapping area and the coordinates of the lower right vertex of the overlapping area.

[0094] Refer to Figure 4 , Figure 4 shows a schematic diagram of the first embodiment of determining the overlapping area provided by the embodiment of the present application. As Figure 4As shown, the second area to be filled 430 and the corresponding circumscribed rectangle 420 are located on the second layer. The upper left vertex coordinates of the drawing operation area are (X1, Y1), the lower right vertex coordinates of the drawing operation area are (X2, Y2), the upper left vertex coordinates of the circumscribed rectangle 420 are (X3, Y3), and the lower right vertex coordinates of the circumscribed rectangle 420 are (X4, Y4). As Figure 4 shown, it is known that X1 < X2, X3 < X4, Y1 < Y2, and Y3 < Y4.

[0095] When X1 < X2 < X3 < X4, X3 < X4 < X1 < X2, Y1 < Y2 < Y3 < Y4, or Y3 < Y4 < Y1 < Y2, there is no overlapping area between the drawing operation area and the circumscribed rectangle 420.

[0096] When X1 ≤ X3 < X2 < X4, there is an overlapping area at this time. And the abscissa of the upper left vertex of the overlapping area is X3, and the abscissa of the lower right vertex of the overlapping area is X2. The drawing operation area that forms the overlapping area with the circumscribed rectangle 420 includes the first drawing operation area 401, the second drawing operation area 402, and the third drawing operation area 403.

[0097] In a preferred embodiment, when Y1 < Y3 < Y2 < Y4, the first drawing operation area 401 can be generated. At this time, the upper left vertex coordinates of the overlapping area can be determined as (X3, Y3), and the lower right vertex coordinates of the overlapping area can be determined as (X2, Y2).

[0098] In a preferred embodiment, when Y3 ≤ Y1 < Y2 ≤ Y4, the second drawing operation area 402 can be generated. At this time, the upper left vertex coordinates of the overlapping area can be determined as (X3, Y1), and the lower right vertex coordinates of the overlapping area can be determined as (X2, Y2).

[0099] In a preferred embodiment, when Y3 < Y1 < Y4 < Y2, the third drawing operation area 403 can be generated. At this time, the upper left vertex coordinates of the overlapping area can be determined as (X3, Y1), and the lower right vertex coordinates of the overlapping area can be determined as (X2, Y4).

[0100] Referring to Figure 5 , Figure 5 shows a schematic diagram of the second embodiment of determining the overlapping area provided by the embodiment of the present application. As Figure 5 shown, when Y1 < Y3 < Y4 < Y2, the fourth drawing operation area 404 can be generated. At this time, the upper left vertex coordinates of the overlapping area can be determined as (X3, Y3), and the lower right vertex coordinates of the overlapping area can be determined as (X2, Y4).

[0101] Referring to Figure 6 , Figure 6 shows a schematic diagram of the third embodiment of determining the overlapping area provided by the embodiment of the present application. As Figure 6As shown, when X3 < X1 < X2 ≤ X4, there is also an overlapping area at this time. The abscissa of the upper left vertex of the overlapping area is X1, and the abscissa of the lower right vertex of the overlapping area is X2. The drawing operation area that forms the overlapping area with the circumscribed rectangle 420 further includes a fifth drawing operation area 405 and a sixth drawing operation area 406.

[0102] In a preferred embodiment, when Y1 ≤ Y3 < Y2 < Y4, the fifth drawing operation area 405 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y3), and the coordinates of the lower right vertex of the overlapping area can be determined as (X2, Y2).

[0103] In a preferred embodiment, when Y3 < Y1 < Y4 < Y2, the sixth drawing operation area 406 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y1), and the coordinates of the lower right vertex of the overlapping area can be determined as (X2, Y2).

[0104] Refer to Figure 7 , Figure 7 shows a schematic diagram of the fourth embodiment for determining the overlapping area provided by the embodiment of the present application. As Figure 7 shown, when X3 ≤ X1 < X4 < X2, there is also an overlapping area at this time. The abscissa of the upper left vertex of the overlapping area is X1, and the abscissa of the lower right vertex of the overlapping area is X4. The drawing operation area that forms the overlapping area with the circumscribed rectangle 420 further includes a seventh drawing operation area 407, an eighth drawing operation area 408, and a ninth drawing operation area 409.

[0105] In a preferred embodiment, when Y1 < Y3 < Y2 < Y4, the seventh drawing operation area 407 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y4), and the coordinates of the lower right vertex of the overlapping area can be determined as (X4, Y2).

[0106] In a preferred embodiment, when Y3 ≤ Y1 < Y2 ≤ Y4, the eighth drawing operation area 408 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y1), and the coordinates of the lower right vertex of the overlapping area can be determined as (X4, Y2).

[0107] In a preferred embodiment, when Y3 < Y1 < Y4 < Y2, the ninth drawing operation area 409 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y1), and the coordinates of the lower right vertex of the overlapping area can be determined as (X4, Y4).

[0108] Refer to Figure 8 , Figure 8 shows a schematic diagram of the fifth embodiment for determining the overlapping area provided by the embodiment of the present application. As Figure 8As shown, when Y1 < Y3 < Y4 < Y2, the tenth drawing operation area 410 can be generated. At this time, the coordinates of the upper left vertex of the overlapping area can be determined as (X1, Y1), and the coordinates of the lower right vertex of the overlapping area can be determined as (X4, Y4).

[0109] Return Figure 3 , S640, Fill the effective filling area with the target color corresponding to the filling operation, and use the filled effective filling area as the filled area.

[0110] After obtaining the effective filling area, fill the target filling color corresponding to the drawing operation area into the effective filling area, that is, replace the channel value of the color channel of the second area to be filled with the channel value of the color channel corresponding to the target filling color, thereby obtaining the filled area.

[0111] Return Figure 1 , S700, Obtain the processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer.

[0112] Specifically, superimpose the image to be processed in the first layer and the filled area in the second layer to obtain the processed image.

[0113] The image processing method provided by the embodiments of the present application can streamline the algorithm processing when filling colors near the boundary of the area to be filled, improving the filling efficiency.

[0114] Based on the same technical concept, the embodiments of the present application also provide an image processing device, which provides a graphical user interface through a terminal device. See Figure 9 , Figure 9 shows a schematic structural diagram of the image processing device provided by the embodiments of the present application. The device includes:

[0115] The first determination module 910 is configured to determine the first area to be filled in the image to be processed according to the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer.

[0116] The creation module 920 is configured to create a second layer above the first layer. The second layer is in a target display mode, and the target display mode includes an alpha channel.

[0117] The second determination module 930 is configured to use the area corresponding to the first area to be filled in the second layer as the second area to be filled.

[0118] The first setting module 940 is configured to set the channel value of the alpha channel of each pixel point in the second area to be filled to a first value.

[0119] A second setting module 950 is configured to determine a second area to be filled according to the second area to be filled, and set the channel value of the transparency channel of each pixel point in the target external area of the target external area to a second value.

[0120] A filling module 960 is configured to receive a filling operation performed on the second layer for the second area to be filled, and obtain a filled area.

[0121] An obtaining module 970 is configured to obtain a processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer.

[0122] Optionally, the determining module 910 is configured to determine the first area to be filled in the image to be processed in the following manner: in response to a selection operation performed on the first brush control, generate a first virtual brush on the first layer; in response to a drawing operation performed on the first virtual brush, draw a contour corresponding to the image to be processed on the first layer to obtain the first area to be filled.

[0123] Optionally, the first value indicates that the transparency of each pixel point in the second area to be filled is completely opaque, and the second value indicates that the transparency of each pixel point in the target external area is completely transparent; and / or, the first area to be filled is an irregular shape.

[0124] Optionally, the channel value of the transparency channel of the second layer is set to the second value.

[0125] Optionally, the graphical user interface further includes a second brush control, and the filling module 960 is configured to obtain the filled area in the following manner: determine a circumscribed rectangle of the first area to be filled on the second layer according to the coordinates of all pixel points of the first area to be filled; determine a drawing operation area according to a selection operation on the second brush control; determine an effective filling area according to the circumscribed rectangle and the drawing operation area; fill the effective filling area with the target color corresponding to the filling operation, and use the filled effective filling area as the filled area.

[0126] Optionally, the device further includes a third display module (not shown in the figure), and the third display module is configured to:

[0127] Optionally, the filling module 960 is configured to determine the circumscribed rectangle of the first area to be filled in the following manner:

[0128] Traverse the coordinates of all pixel points of the first area to be filled;

[0129] Obtain the maximum abscissa value, the minimum abscissa value, the maximum ordinate value, and the minimum ordinate value among the coordinates of all pixel points in the first area to be filled;

[0130] Use the minimum abscissa value and the minimum ordinate value among all the pixel points as the coordinates of the upper left vertex of the circumscribed rectangle;

[0131] Use the maximum abscissa value and the maximum ordinate value among all the pixel points as the coordinates of the lower right vertex of the circumscribed rectangle;

[0132] Determine the circumscribed rectangle from the coordinates of the lower right vertex and the upper left vertex of the circumscribed rectangle.

[0133] Optionally, the filling module 960 is further configured to:

[0134] In response to a selection operation on the second brush control, generate a second virtual brush on the second layer;

[0135] In response to a color configuration operation on the fill color selection control, determine the target fill color corresponding to the second virtual brush;

[0136] In response to a drawing operation performed on the second virtual brush, determine the drawing operation area.

[0137] Optionally, the graphical user interface further includes a stroke width configuration control corresponding to the second brush control, and the device further includes a configuration response module (not shown in the figure). The configuration response module is configured to: in response to a configuration operation on the stroke width configuration control, determine the stroke width value corresponding to the second virtual brush, and determine the drawing operation area in the following manner: determine the abscissa value, the ordinate value of the drawing point of the second virtual brush on the second layer, and the stroke width value of the second virtual brush; determine the difference between the abscissa value of the drawing point of the second virtual brush and half of the stroke width value as the abscissa value of the upper left vertex of the drawing operation area, and determine the difference between the ordinate value of the drawing point of the second virtual brush and half of the stroke width value as the ordinate value of the upper left vertex of the drawing operation area.

[0138] The image processing device provided by the embodiments of the present application can streamline the algorithm processing when filling colors near the boundary of the area to be filled, and improve the filling efficiency when filling the area to be filled.

[0139] It should be noted that, in this document, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that includes a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or apparatus that includes the element.

[0140] Finally, it should be noted that the above embodiments are only specific embodiments of the present application, used to illustrate the technical solutions of the present application, rather than limiting it. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present application can still modify the technical solutions described in the foregoing embodiments or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. An image processing method, characterized in that, The method includes: Determining a first area to be filled in the image to be processed based on the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer; Creating a second layer above the first layer, where the second layer is in a target display mode, and the target display mode includes an alpha channel; Determining an area in the second layer corresponding to the first area to be filled as a second area to be filled; Setting the channel value of the alpha channel of each pixel point in the second area to be filled to a first value; Determining a target external area of the second area to be filled based on the second area to be filled, and setting the channel value of the alpha channel of each pixel point in the target external area to a second value; Receiving a filling operation performed on the second area to be filled on the second layer to obtain a filled area; Obtaining the processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer; Obtaining the filled area in the second layer by: Determining a target external area of the second area to be filled according to the circumscribed rectangle corresponding to the second area to be filled and / or the first area to be filled; Determining an effective filling area according to the drawing operation area corresponding to the second brush control, the target external area, and the positional relationship between the drawing operation area and the second area to be filled; Filling the effective filling area with the target color corresponding to the filling operation, and taking the filled effective filling area as the filled area.

2. The image processing method according to claim 1, wherein The determining the first area to be filled in the image to be processed based on the contour drawing result of the image to be processed received in the first layer includes: Responding to a selection operation performed on the first brush control, and generating a first virtual brush on the first layer; Responding to a drawing operation performed on the first virtual brush, and drawing a contour corresponding to the image to be processed on the first layer to obtain a first area to be filled.

3. The image processing method according to claim 1, wherein The first value indicates that the transparency of each pixel point in the second area to be filled is completely opaque, and the second value indicates that the transparency of each pixel point in the target external area is completely transparent; And / or, the first area to be filled is an irregular shape.

4. The image processing method according to claim 3, wherein The channel value of the alpha channel of the second layer is set to the second value.

5. The image processing method according to claim 1, wherein The receiving the filling operation performed on the second area to be filled on the second layer to obtain a filled area includes: Determining the circumscribed rectangle of the first area to be filled on the second layer according to the pixel point coordinates of the first area to be filled; Determining a drawing operation area according to a selection operation on the second brush control; Determining an effective filling area according to the circumscribed rectangle and the drawing operation area; Filling the effective filling area with the target color corresponding to the filling operation, and taking the filled effective filling area as the filled area.

6. The image processing method according to claim 5, wherein Determining the circumscribed rectangle of the first area to be filled by: Traversing the coordinates of all pixel points in the first area to be filled; Obtain the maximum abscissa value, minimum abscissa value, maximum ordinate value, and minimum ordinate value among all the pixel point coordinates in the first area to be filled; Use the minimum abscissa value and minimum ordinate value among all the pixel points in the first area to be filled as the coordinates of the upper left corner vertex of the circumscribed rectangle; Use the maximum abscissa value and maximum ordinate value among all the pixel points in the first area to be filled as the coordinates of the lower right corner vertex of the circumscribed rectangle; Determine the circumscribed rectangle from the coordinates of the lower right corner vertex and the upper left corner vertex of the circumscribed rectangle.

7. The image processing method according to claim 5, characterized in that The steps of determining the drawing operation area according to the selection operation on the second brush control include: Respond to the selection operation on the second brush control and generate a second virtual brush on the second layer; Respond to the color configuration operation on the fill color selection control and determine the target fill color corresponding to the second virtual brush; Respond to the drawing operation performed on the second virtual brush and determine the drawing operation area.

8. The image processing method according to claim 7, characterized in that The steps of the above-mentioned responding to the drawing operation performed on the second virtual brush and determining the drawing operation area include: Respond to the configuration operation on the stroke width configuration control and determine the stroke width value corresponding to the second virtual brush, Determine the drawing operation area in the following way: Determine the abscissa value, ordinate value of the drawing point of the second virtual brush on the second layer, and the stroke width value of the second virtual brush; Determine the abscissa value of the upper left corner vertex of the drawing operation area by subtracting half of the stroke width value from the abscissa value of the drawing point of the second virtual brush, and determine the ordinate value of the upper left corner vertex of the drawing operation area by subtracting half of the stroke width value from the ordinate value of the drawing point of the second virtual brush.

9. An image processing apparatus, characterized in that, The image processing device includes: A first determination module, configured to determine a first area to be filled in the image to be processed according to the contour drawing result of the image to be processed and / or the recognition result of character recognition in the image to be processed received in the first layer; A creation module, configured to create a second layer above the first layer, where the second layer is in a target display mode, and the target display mode includes an alpha channel; A second determination module, configured to determine a second area to be filled as the area corresponding to the first area to be filled in the second layer; A first setting module, configured to set the channel value of the alpha channel of each pixel point in the second area to be filled to a first value; A second setting module, configured to determine a target external area of the second area to be filled according to the second area to be filled, and set the channel value of the alpha channel of each pixel point in the target external area to a second value; A filling module, configured to receive a filling operation on the second area to be filled performed on the second layer and obtain a filled area; An obtaining module, configured to obtain the processed image to be processed based on the image to be processed in the first layer and the filled area in the second layer; Wherein, the filling module is further configured to: Determine the target external area of the second area to be filled according to the circumscribed rectangle corresponding to the second area to be filled and / or the first area to be filled; Determine the effective filling area according to the drawing operation area corresponding to the second brush control, the target external area, and the positional relationship between the drawing operation area and the second area to be filled; Use the target color corresponding to the filling operation to fill the effective filling area, and use the filled effective filling area as the filled area.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the steps of the image processing method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Image processing method and device, electronic device and storage medium

    CN108492348A