Method, apparatus and medium for covering video image
By determining the area to be filled in the video image and expanding the dilated area, selecting and updating the pixel values, the problem of obvious masking traces is solved and a smoother masking effect is achieved.
Patent Information
- Application Number
- CN202210513722.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-05-12
AI Technical Summary
Existing video image masking methods leave obvious masking traces when masking areas, affecting the integrity of the image.
By determining the area to be filled in the video image to be processed, expanding the area to obtain the dilated area, selecting filling pixels in the dilated area, and updating the pixel value of the area to be filled according to the filling pixel value, it is ensured that the pixel value after masking is more consistent with the surrounding image.
The filling traces of the masked area are reduced, making the transition of the masked area smoother and improving the harmony of the picture.
Smart Images

Figure CN114862988B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a video image covering method, device, equipment and medium. BACKGROUND
[0002] In the video production link, the demand of covering part of the area in the video picture is often encountered, and the existing scheme usually adopts the mosaic method to process, so that part of the area in the picture is blurred, however, obvious covering traces are left on the picture, the color of part of the area is very conspicuous in the whole picture, which affects the integrity of the picture. SUMMARY
[0003] The main purpose of the present application is to provide a video image covering method, device, equipment and medium, which aims to solve the problem of how to reduce the covering traces of the video image.
[0004] To achieve the above purpose, the present application provides a video image covering method, which comprises the following steps:
[0005] Determine the to-be-filled area of the to-be-processed video image;
[0006] Enlarging the to-be-filled area to obtain an inflation area;
[0007] Selecting a filling pixel point corresponding to a pixel point in the to-be-filled area in the inflation area;
[0008] Updating the pixel value of the pixel point in the to-be-filled area according to the filling pixel value of the filling pixel point.
[0009] In an embodiment, the step of enlarging the to-be-filled area to obtain an inflation area comprises:
[0010] Sliding a sliding window with a preset size on the to-be-processed video image to determine a first set of pixel points located in the sliding window and outside the to-be-filled area;
[0011] Determining the inflation area according to the first set.
[0012] In an embodiment, the step of determining the inflation area according to the first set comprises:
[0013] Determining a second set of pixel points located within a preset range of the edge of the to-be-filled area and outside the to-be-filled area;
[0014] If the intersection of the first set and the second set is greater than a preset proportion, the pixel points in the first set are taken as the pixel points in the inflation area.
[0015] In an embodiment, the step of selecting the filling pixel corresponding to the pixel in the to-be-filled region in the expansion region comprises:
[0016] determining a first boundary and a second boundary of the expansion region, the first boundary being a boundary at which the to-be-filled region and the expansion region meet, and the second boundary being a peripheral boundary of the expansion region;
[0017] determining a first distance between the pixel in the to-be-filled region and the first boundary;
[0018] determining the filling pixel corresponding to the pixel in the to-be-filled region according to the first distance between the first boundary and the second boundary.
[0019] In an embodiment, the step of determining the filling pixel corresponding to the pixel in the to-be-filled region according to the first distance between the first boundary and the second boundary comprises:
[0020] determining a second distance between the first boundary and the second boundary;
[0021] determining the filling pixel corresponding to the pixel in the to-be-filled region according to a size relationship between the first distance and the second distance between the first boundary and the second boundary.
[0022] In an embodiment, the step of updating the pixel value of the pixel in the to-be-filled region according to the filling pixel value of the filling pixel comprises:
[0023] when the filling pixel comprises a plurality of pixels in a preset direction, determining a pixel difference value between the filling pixel values of the filling pixel and a third distance between the filling pixels;
[0024] determining the pixel value of the pixel in the to-be-filled region according to the pixel difference value and the third distance.
[0025] In an embodiment, the preset direction comprises the first direction and the second direction, and the first direction and the second direction are perpendicular, and the step of determining the pixel value of the pixel in the to-be-filled region according to the pixel difference value and the third distance comprises:
[0026] comparing the pixel difference value in the first direction with the pixel difference value in the second direction to determine a minimum difference value;
[0027] taking the direction corresponding to the minimum difference value as a target direction, and determining a channel weight parameter of the pixel difference value according to the third distance corresponding to the target direction;
[0028] Determine a pixel value of a pixel point of the to-be-filled region according to the pixel difference and the corresponding channel weight parameter.
[0029] To achieve the above object, the application further provides a video image covering device, which comprises:
[0030] A determining module is configured to determine a to-be-filled region of a to-be-processed video image.
[0031] A calculating module is configured to expand the to-be-filled region to obtain an inflation region.
[0032] A selecting module is configured to select, in the inflation region, a filling pixel point corresponding to a pixel point in the to-be-filled region.
[0033] A covering module is configured to update a pixel value of the pixel point in the to-be-filled region according to a filling pixel value of the filling pixel point.
[0034] To achieve the above object, the application further provides a video image covering device, which comprises a memory, a processor and a video image covering program stored in the memory and executable on the processor, and the video image covering program is used to implement each step of the video image covering method.
[0035] To achieve the above object, the application further provides a computer readable storage medium, which stores a video image covering program, and the video image covering program is used to implement each step of the video image covering method when executed by a processor.
[0036] The application provides a video image covering method, device, equipment and medium, which determines a to-be-filled region of a to-be-processed video image, expands the to-be-filled region to obtain an inflation region, selects, in the inflation region, a filling pixel point corresponding to a pixel point in the to-be-filled region, and updates a pixel value of the pixel point in the to-be-filled region according to a filling pixel value of the filling pixel point. The pixel value of the pixel point in the to-be-filled region is updated by the filling pixel value of the filling pixel point in the inflation region, so that the pixel value of the pixel point in the to-be-filled region is more consistent with the surrounding image of the to-be-filled region, the pixel value of the pixel point in the updated to-be-filled region is more smooth and has lower discomfort, and the filling trace of the to-be-filled region is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0037] Figure 1 The hardware structure of the video image covering device is shown in the figure.
[0038] Figure 2Flowchart of the first embodiment of the video image covering method involved in the embodiments of the present application;
[0039] Figure 3 Schematic diagram of the region to be filled in the video image covering method involved in the embodiments of the present application;
[0040] Figure 4 Schematic diagram of the region to be filled and the expanded region in the video image covering method involved in the embodiments of the present application;
[0041] Figure 5 Refined flowchart of step S20 of the second embodiment of the video image covering method involved in the embodiments of the present application;
[0042] Figure 6 Schematic diagram of the region to be filled in the binary image of the video image covering method involved in the embodiments of the present application;
[0043] Figure 7 Schematic diagram of the region to be filled and the expanded region in the binary image of the video image covering method involved in the embodiments of the present application;
[0044] Figure 8 Refined flowchart of step S30 of the third embodiment of the video image covering method involved in the embodiments of the present application;
[0045] Figure 9 Schematic diagram of the first boundary and the second boundary of the video image covering method involved in the embodiments of the present application;
[0046] Figure 10 Schematic diagram of the positions of two filling pixel points in the horizontal direction of the video image covering method involved in the embodiments of the present application;
[0047] Figure 11 Schematic diagram of the positions of two filling pixel points in the vertical direction of the video image covering method involved in the embodiments of the present application;
[0048] Figure 12 Refined flowchart of step S40 of the fourth embodiment of the video image covering method involved in the embodiments of the present application;
[0049] Figure 13 Schematic diagram of the logic structure of the video image covering device involved in the embodiments of the present application.
[0050] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
[0052] The main solution of the embodiment of the present application is: determining a to-be-filled region of a to-be-processed video image; expanding the to-be-filled region to obtain an inflation region; selecting a filling pixel point corresponding to a pixel point in the to-be-filled region in the inflation region; and updating a pixel value of the pixel point in the to-be-filled region according to a filling pixel value of the filling pixel point.
[0053] The pixel value of the pixel point in the to-be-filled region is updated through the filling pixel value of the filling pixel point in the inflation region, so that the pixel value of the pixel point in the to-be-filled region is more consistent with the surrounding image of the to-be-filled region, the pixel value of the pixel point in the updated to-be-filled region is more smooth and has lower discomfort, and the filling trace of the to-be-filled region is reduced.
[0054] As an implementation scheme, the covering device of the video image can be as shown in Figure 1 .
[0055] The embodiment of the present application relates to a covering device of a video image, and the covering device of the video image comprises a processor 101, such as a CPU, a memory 102, and a communication bus 103. The communication bus 103 is used to realize the connection and communication between the components.
[0056] The memory 102 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. As shown in Figure 1 , the memory 102 as a computer readable storage medium can include a covering program of a video image; and the processor 101 can be used to call the covering program of the video image stored in the memory 102 and perform the following operations:
[0057] determining a to-be-filled region of a to-be-processed video image;
[0058] expanding the to-be-filled region to obtain an inflation region;
[0059] selecting a filling pixel point corresponding to a pixel point in the to-be-filled region in the inflation region;
[0060] updating a pixel value of the pixel point in the to-be-filled region according to a filling pixel value of the filling pixel point.
[0061] In an embodiment, the processor 101 can be used to call the covering program of the video image stored in the memory 102 and perform the following operations:
[0062] sliding a preset size sliding window on the video image to be processed to determine a first set of pixel points located in the sliding window and outside the region to be filled;
[0063] determining the expanded region according to the first set.
[0064] In an embodiment, the processor 101 can be configured to invoke a concealing program of the video image stored in the memory 102, and perform the following operations:
[0065] determining a second set of pixel points located within a preset range of the edge of the region to be filled and outside the region to be filled;
[0066] if an intersection of the first set and the second set is greater than a preset proportion, the pixel points in the first set are determined as the pixel points in the expanded region.
[0067] In an embodiment, the processor 101 can be configured to invoke a concealing program of the video image stored in the memory 102, and perform the following operations:
[0068] determining a first boundary and a second boundary of the expanded region, the first boundary being a boundary at which the region to be filled and the expanded region meet, and the second boundary being a peripheral boundary of the expanded region;
[0069] determining a first distance between the pixel points in the region to be filled and the first boundary;
[0070] determining a filling pixel point corresponding to the pixel points in the region to be filled between the first boundary and the second boundary according to the first distance.
[0071] In an embodiment, the processor 101 can be configured to invoke a concealing program of the video image stored in the memory 102, and perform the following operations:
[0072] determining a second distance between the first boundary and the second boundary;
[0073] determining a filling pixel point corresponding to the pixel points in the region to be filled between the first boundary and the second boundary according to a size relationship between the first distance and the second distance.
[0074] In an embodiment, the processor 101 can be configured to invoke a concealing program of the video image stored in the memory 102, and perform the following operations:
[0075] when the filling pixel point includes a plurality of pixel points in a preset direction, determining a pixel difference value between filling pixel values of the filling pixel points and a third distance between the filling pixel points;
[0076] Determine pixel values of pixels in the area to be filled according to the pixel difference and the third distance.
[0077] In one embodiment, the processor 101 may be configured to call a video image masking program stored in the memory 102 and perform the following operations:
[0078] Comparing the pixel difference in the first direction with the pixel difference in the second direction to determine a minimum difference;
[0079] Taking the direction corresponding to the minimum difference as the target direction, and determining the channel weight parameter of the pixel difference according to the third distance corresponding to the target direction;
[0080] The pixel values of the pixel points in the area to be filled are determined according to the pixel difference and the corresponding channel weight parameter.
[0081] Based on the hardware architecture of the above-mentioned video image covering device, an embodiment of the video image covering method of the present invention is proposed.
[0082] Reference Figure 2 , Figure 2 This is a first embodiment of the video image masking method of the present invention, and the video image masking method includes the following steps:
[0083] Step S10: determining the area to be filled in the video image to be processed.
[0084] Specifically, the video image to be processed is a video image that needs to be covered or filled in the video, wherein the area that needs to be covered or filled is the area to be filled, for example, Figure 3 As shown, area a is the area to be filled.
[0085] Step S20: enlarging the area to be filled to obtain an expanded area.
[0086] Specifically, the area to be filled is expanded to obtain an expanded area, wherein the expanded area is outside the area to be filled, for example, Figure 4 As shown, the area to be filled is area b, and the expanded area is area c. Optionally, each pixel point on the outer boundary of the expanded area can be equidistant from the corresponding pixel point on the boundary of the corresponding area to be filled. For example, if the area to be filled is a circle with a radius of 2 and a center at (x, y), the expanded area is a ring obtained by subtracting the area to be filled from the circle with a radius of 4 and a center at (x, y).
[0087] Step S30 : selecting filling pixel points corresponding to the pixel points in the area to be filled in the expansion area.
[0088] Specifically, the filling pixel points corresponding to the pixel points in the to-be-filled region are selected in the expansion region, wherein each pixel point in the expansion region corresponds to a filling pixel point. Optionally, each pixel point in the expansion region corresponds to a plurality of filling pixel points, for example, two filling pixel points in the horizontal direction and two filling pixel points in the vertical direction.
[0089] In step S40, the pixel value of the pixel point in the to-be-filled region is updated according to the filling pixel value of the filling pixel point.
[0090] Specifically, the pixel value of the pixel point in the to-be-filled region is updated according to the filling pixel value of the filling pixel point. Optionally, when the filling pixel point corresponding to the pixel point in the expansion region is one, the pixel value of the corresponding pixel point in the to-be-filled region is determined according to the filling pixel value.
[0091] Optionally, when the filling pixel point corresponding to the pixel point in the expansion region is two, the two filling pixel points are located on both sides of the pixel point in the to-be-filled region, the pixel difference value of the filling pixel values of the two filling pixel points is determined, the distance between the two filling pixel points is determined, and the pixel value of the corresponding pixel point in the to-be-filled region is determined according to the pixel difference value and the distance.
[0092] In the technical scheme of the embodiment, the to-be-filled region of the to-be-processed video image is determined, the to-be-filled region is expanded to obtain an expansion region, the filling pixel points corresponding to the pixel points in the to-be-filled region are selected in the expansion region, and the pixel value of the pixel point in the to-be-filled region is updated according to the filling pixel value of the filling pixel point. The pixel value of the pixel point in the to-be-filled region is updated by the filling pixel value of the filling pixel point in the expansion region, so that the pixel value of the pixel point in the to-be-filled region is more consistent with the surrounding image of the to-be-filled region, the pixel value of the pixel point in the updated to-be-filled region is more smooth and has lower discomfort, and the filling trace of the to-be-filled region is reduced.
[0093] Reference Figure 5 , Figure 5 For the second embodiment of the video image covering method of the application, based on the first embodiment, the step S20 comprises:
[0094] In step S21, a preset size sliding window is used to slide on the to-be-processed video image to determine a first set of pixel points located in the sliding window and outside the to-be-filled region.
[0095] In step S22, the expansion region is determined according to the first set.
[0096] Specifically, the preset size of the sliding window can be 8*8, and the preset size of the sliding window is used to slide on the video image to be processed. When the sliding window includes both the pixel points in the region to be filled and the pixel points outside the region to be filled, a first set of pixel points located in the sliding window and outside the region to be filled is determined.
[0097] An expansion region is determined according to the first set. Optionally, the pixel points corresponding to the first set are taken as the pixel points in the expansion region. A second set of pixel points located in a preset range of the edge of the region to be filled and outside the region to be filled is determined. If an intersection of the first set and the second set is greater than a preset proportion, the pixel points in the first set are taken as the pixel points in the expansion region. If the intersection of the first set and the second set is less than or equal to the preset proportion, the pixel points in the sliding window are discarded.
[0098] Optionally, a first number N of the pixel points in the first set is determined, and a second number C of the pixel points in the intersection of the first set and the second set is determined. When a ratio of the second number C to the first number N is less than a preset threshold, it is determined that the intersection of the first set and the second set is greater than the preset proportion. Exemplarily, the preset threshold is one fifth.
[0099] Optionally, the video image to be processed is converted into a binary image, as shown in Figure 6 The region to be filled b in the binary image is white, and the remaining regions are black. A first set of pixel points of the black region in the sliding window is obtained. A first number of the pixel points in the first set is N. A second set of the black region in the preset range of the edge of the region to be filled is determined. A number of the pixel points in the second set is B. A second number of the intersection of the first set and the second set is C. If C>(N / 5), the sliding window region is marked as expandable. The above process is repeated until no expandable region is found, and a final expansion region is obtained. Exemplarily, the total region b+c of the expansion region and the region to be filled is as shown in Figure 7 .
[0100] In the technical solution of the embodiment, the preset size of the sliding window is used to slide on the video image to be processed, and a first set of pixel points located in the sliding window and outside the region to be filled is determined. The expansion region is determined according to the first set. The preset size of the sliding window is used to slide on the video image to be processed, and the expansion region is accurately determined. The pixel values of the expansion region are more consistent with the pixel values of the region to be filled, so that the pixel values of the pixel points in the region to be filled are updated by filling the pixel points in the expansion region. The pixel values of the updated region to be filled are more smooth and have lower discomfort, and the filling trace of the region to be filled is reduced.
[0101] Refer toFigure 8 , Figure 8 For a third embodiment of the video image covering method of the present application, based on the first or second embodiment, the step S30 comprises:
[0102] Step S31, determining the first boundary and the second boundary of the expanded region, the first boundary being the boundary at the junction of the to-be-filled region and the expanded region, and the second boundary being the peripheral boundary of the expanded region;
[0103] Step S32, determining the first distance between the pixel point in the to-be-filled region and the first boundary;
[0104] Step S33, determining the filling pixel point corresponding to the pixel point in the to-be-filled region according to the first distance between the first boundary and the second boundary.
[0105] Specifically, the first boundary and the second boundary of the expanded region are determined, the first boundary being the boundary at the junction of the to-be-filled region and the expanded region, and the second boundary being the peripheral boundary of the expanded region. For example, as shown in FIG. 3, q1 is the first boundary and q2 is the second boundary. Figure 9
[0106] The first distance between the first pixel point in the to-be-filled region and the first boundary of the to-be-filled region in a preset direction is determined, and the second distance between the first pixel point and the second boundary of the expanded region is determined.
[0107] The first distance between the pixel point in the to-be-filled region and the first boundary is determined; and the filling pixel point corresponding to the pixel point in the to-be-filled region is determined according to the first distance between the first boundary and the second boundary. Optionally, the filling pixel point corresponding to the pixel point in the to-be-filled region is determined by reciprocating between the first boundary and the second boundary according to the first distance. For example, the distance from the pixel point a in the to-be-filled region to the first boundary has 3 pixel points, and there are 6 pixel points between the first boundary and the second boundary in turn. The third pixel point is determined as the filling pixel point. The distance from the pixel point b in the to-be-filled region to the first boundary has 7 pixel points, and there are 6 pixel points between the first boundary and the second boundary in turn. Since 7 is greater than 6, the fifth pixel point is determined as the filling pixel point after turning back at the second boundary. The distance from the pixel point c in the to-be-filled region to the first boundary has 25 pixel points. Since 25 is greater than 6, the fifth pixel point is determined as the filling pixel point after reciprocating twice between the first boundary and the second boundary.
[0108] Optionally, a first distance between the pixel point in the to-be-filled region and the first boundary in a preset direction is determined, the preset direction including a first direction and a second direction, and the first direction can be a horizontal direction and the second direction can be a vertical direction.
[0109] Optionally, the pixel point in the to-be-filled region corresponds to four filling pixel points, as shown in the following table: Figure 10 The filling pixel point in the positive direction of the first direction is (x1, y1), wherein, in the positive direction of the first direction, the first distance from the pixel point in the to-be-filled region to the first boundary is A1, the third distance from the pixel point in the to-be-filled region to the second boundary is B1, and the second distance from the first boundary to the second boundary is C1, C1 = B1 - A1; the filling pixel point in the negative direction of the first direction is (x2, y2), wherein, in the negative direction of the first direction, the first distance from the pixel point in the to-be-filled region to the first boundary is A2, the third distance from the pixel point in the to-be-filled region to the second boundary is B2, and the second distance from the first boundary to the second boundary is C2, C2 = B2 - A2; as shown in the following table: Figure 11 The filling pixel point in the positive direction of the second direction is (x3, y3), wherein, in the positive direction of the second direction, the first distance from the pixel point in the to-be-filled region to the first boundary is A3, the third distance from the pixel point in the to-be-filled region to the second boundary is B3, and the second distance from the first boundary to the second boundary is C3, C3 = B3 - A3; the filling pixel point in the negative direction of the second direction is (x4, y4), wherein, in the negative direction of the second direction, the first distance from the pixel point in the to-be-filled region to the first boundary is A4, the third distance from the pixel point in the to-be-filled region to the second boundary is B4, and the second distance from the first boundary to the second boundary is C4, C4 = B4 - A4.
[0110] When the first distance is less than the second distance, the multiple of the first distance divided by the second distance is 0, and the first distance is 3 and the second distance is 4, for example, and the multiple is 0.
[0111] When the multiple of the first distance and the second distance is less than 1, the filling pixel point determined between the first boundary and the second boundary is a pixel point that is mirror-symmetric to the pixel point in the to-be-filled region with the first boundary as a symmetric center.
[0112] The filling pixel point in the positive direction of the first direction is shown in the following formula, for example:
[0113] x1 = x + 2A1;
[0114] y1 = y;
[0115] Wherein, (x1, y1) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel in the region to be filled, and A1 is the first distance of the pixel in the region to be filled to the first boundary in the positive direction of the first direction.
[0116] The pixel to be filled in the negative direction of the first direction is shown in the following formula:
[0117] x2 = x - 2A2;
[0118] y2 = y;
[0119] Wherein, (x2, y2) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel in the region to be filled, and A2 is the first distance of the pixel in the region to be filled to the first boundary in the negative direction of the first direction.
[0120] The pixel to be filled in the positive direction of the second direction is shown in the following formula:
[0121] x3 = x;
[0122] y3 = y + 2A3;
[0123] Wherein, (x3, y3) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel in the region to be filled, and A3 is the first distance of the pixel in the region to be filled to the first boundary in the positive direction of the second direction.
[0124] The pixel to be filled in the negative direction of the second direction is shown in the following formula:
[0125] x4 = x;
[0126] y4 = y + 2A4;
[0127] Wherein, (x4, y4) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel in the region to be filled, and A4 is the first distance of the pixel in the region to be filled to the first boundary in the negative direction of the second direction.
[0128] When the first distance is greater than or equal to the second distance, for example, the first distance is 6 and the second distance is 4, the multiple is 1 and the remainder is 2, and the multiple of the first distance divided by the second distance is determined to be 1.
[0129] When the multiple of the first distance and the second distance is equal to 1, the pixel to be filled between the first boundary and the second boundary is a pixel with a target distance from the pixel in the region to be filled, and the target distance is twice the second distance.
[0130] For example, the pixel to be filled in the positive direction of the first direction is shown in the following formula:
[0131] x1=x+2C1;
[0132] y1=y;
[0133] Among them, (x1, y1) is the coordinate of the pixel point to be filled, (x, y) is the coordinate of the pixel point in the area to be filled, and C1 is the second distance between the first boundary and the second boundary of the pixel point in the area to be filled in the positive direction of the first direction.
[0134] The filling pixel points in the negative direction of the first direction are shown in the following formula:
[0135] x2=x-2C2;
[0136] y2=y;
[0137] Among them, (x2, y2) are the coordinates of the pixel to be filled, (x, y) are the coordinates of the pixel in the area to be filled, and C2 is the second distance between the first boundary and the second boundary of the pixel in the area to be filled in the negative direction of the first direction.
[0138] The filling pixel points in the positive direction of the second direction are shown in the following formula:
[0139] x3=x;
[0140] y3=y+2C3;
[0141] Among them, (x3, y3) are the coordinates of the pixel to be filled, (x, y) are the coordinates of the pixel in the area to be filled, and C3 is the second distance between the first boundary and the second boundary of the pixel in the area to be filled in the positive direction of the second direction.
[0142] The filling pixel points in the negative direction of the second direction are shown in the following formula:
[0143] x4=x;
[0144] y4=y-2C4;
[0145] Among them, (x4, y4) are the coordinates of the pixel to be filled, (x, y) are the coordinates of the pixel in the area to be filled, and C4 is the second distance between the first boundary and the second boundary of the pixel in the area to be filled in the negative direction of the second direction.
[0146] When the first distance is greater than or equal to the second distance, for example, when the first distance is 9 and the second distance is 4, the multiple is 2 and the remainder is 1, and the multiple of the first distance divided by the second distance is determined to be 2; when the first distance is 13 and the second distance is 4, the multiple is 3 and the remainder is 1, and the multiple of the first distance divided by the second distance is determined to be 3.
[0147] When the multiple of the first distance and the second distance is greater than 1, a remainder is determined according to the first distance and the second distance; when the multiple is even, the filling pixel point between the first boundary and the second boundary is determined as: a pixel point determined according to the first distance and the remainder;
[0148] For example, the filling pixel point in the positive direction of the first direction is determined according to the following formula:
[0149] x1=x+A1+A1modC1;
[0150] y1=y;
[0151] wherein (x1, y1) is the coordinate of the pixel point to be filled, (x, y) is the coordinate of the pixel point in the region to be filled, A1 is the first distance from the pixel point in the region to be filled to the first boundary in the positive direction of the first direction, and C1 is the second distance between the first boundary and the second boundary in the positive direction of the first direction.
[0152] The filling pixel point in the negative direction of the first direction is determined according to the following formula:
[0153] x2=x-A2-A2modC2;
[0154] y2=y;
[0155] wherein (x2, y2) is the coordinate of the pixel point to be filled, (x, y) is the coordinate of the pixel point in the region to be filled, A2 is the first distance from the pixel point in the region to be filled to the first boundary in the negative direction of the first direction, and C2 is the second distance between the first boundary and the second boundary in the negative direction of the first direction.
[0156] The filling pixel point in the positive direction of the second direction is determined according to the following formula:
[0157] x3=x;
[0158] y3=y+A3+A3modC3;
[0159] wherein (x3, y3) is the coordinate of the pixel point to be filled, (x, y) is the coordinate of the pixel point in the region to be filled, A3 is the first distance from the pixel point in the region to be filled to the first boundary in the positive direction of the second direction, and C3 is the second distance between the first boundary and the second boundary in the positive direction of the second direction.
[0160] The filling pixel point in the negative direction of the second direction is determined according to the following formula:
[0161] x4=x;
[0162] y4=y-A4-A4modC4;
[0163] wherein (x4, y4) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel within the region to be filled, A4 is the first distance from the pixel within the region to be filled to the first boundary in the negative direction of the first direction, and C4 is the second distance between the first boundary and the second boundary in the negative direction of the second direction.
[0164] When the multiple is odd, the pixel to be filled determined between the first boundary and the second boundary is: the pixel determined according to the first distance, the second distance and the difference value.
[0165] For example, the pixel to be filled in the positive direction of the first direction is as follows:
[0166] x1 = x + A1 + C1 - A1 mod C1;
[0167] y1 = y;
[0168] wherein (x1, y1) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel within the region to be filled, A1 is the first distance from the pixel within the region to be filled to the first boundary in the positive direction of the first direction, and C1 is the second distance between the first boundary and the second boundary in the positive direction of the first direction.
[0169] The pixel to be filled in the negative direction of the first direction is as follows:
[0170] x2 = x - A2 - C2 + A2 mod C2;
[0171] y2 = y;
[0172] wherein (x2, y2) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel within the region to be filled, A2 is the first distance from the pixel within the region to be filled to the first boundary in the negative direction of the first direction, and C2 is the second distance between the first boundary and the second boundary in the negative direction of the first direction.
[0173] The pixel to be filled in the positive direction of the second direction is as follows:
[0174] x3 = x;
[0175] y3 = y + A3 + C3 - A3 mod C3;
[0176] wherein (x3, y3) is the coordinate of the pixel to be filled, (x, y) is the coordinate of the pixel within the region to be filled, A3 is the first distance from the pixel within the region to be filled to the first boundary in the positive direction of the second direction, and C3 is the second distance between the first boundary and the second boundary in the positive direction of the second direction.
[0177] The filling pixel point in the negative direction of the second direction is shown in the following formula:
[0178] x4=x;
[0179] y4=y-A4-C4+A4modC4;
[0180] wherein (x4, y4) is the coordinate of the filling pixel point, (x, y) is the coordinate of the pixel point in the filling region, A4 is the first distance between the pixel point in the filling region and the first boundary in the negative direction of the second direction, and C4 is the second distance between the first boundary and the second boundary in the negative direction of the second direction.
[0181] In the technical scheme of the embodiment, the first boundary and the second boundary of the expansion region are determined, the first boundary is the boundary at the junction of the filling region and the expansion region, and the second boundary is the peripheral boundary of the expansion region; the first distance between the pixel point in the filling region and the first boundary is determined; and the filling pixel point corresponding to the pixel point in the filling region is determined according to the first distance between the first boundary and the second boundary. The filling pixel point is determined between the first boundary and the second boundary, the pixel value of the pixel point in the filling region is updated by the filling pixel value of the filling pixel point, the pixel value of the updated filling region is more smoothly and has lower discomfort, and the filling trace of the filling region is reduced.
[0182] Referring to Figure 12 , Figure 12 The fourth embodiment of the video image covering method is based on any one of the first to third embodiments, and the step S40 comprises:
[0183] In step S41, when the filling pixel point comprises a plurality of pixel points in a preset direction, a pixel difference value between the filling pixel values of the filling pixel point is determined, and a third distance between the filling pixel points is determined.
[0184] In step S42, the pixel value of the pixel point in the filling region is determined according to the pixel difference value and the third distance.
[0185] Specifically, the preset direction comprises a first direction and a second direction, the first direction and the second direction are perpendicular, and for example, the first direction is a horizontal direction and the second direction is a vertical direction.
[0186] When the filling pixel point comprises a plurality of pixel points in a preset direction, a pixel difference value between the filling pixel values of the filling pixel point is determined. Optionally, when the filling pixel point comprises only two pixel points in the first direction, and the two pixel points are located on both sides of the pixel point in the filling region, a pixel difference value between the filling pixel values of the two filling pixel points is determined.
[0187] Optionally, when the filling pixel points include two pixel points in the first direction and two pixel points in the second direction, and the four pixel points are located at four directions of the pixel points in the region to be filled, the pixel difference value of the two filling pixel points in the first direction is determined, and the pixel difference value of the two filling pixel points in the second direction is determined.
[0188] The pixel difference value of the two filling pixel points in the preset direction is determined, and the R value difference, the G value difference and the B value difference between the two filling pixel points are determined respectively; the pixel difference value of the two filling pixel points is determined according to the R value difference, the G value difference and the B value difference, wherein the R value represents the gray value of the red channel, the G value represents the gray value of the green channel, and the B value represents the gray value of the blue channel. Optionally, as shown in the following formula:
[0189]
[0190] The pixel difference value of the two filling pixel points in the preset direction is determined, and the R value difference, the G value difference and the B value difference between the two filling pixel points are determined respectively; the pixel difference value of the two filling pixel points is determined according to the R value difference, the G value difference and the B value difference, wherein the R value represents the gray value of the red channel, the G value represents the gray value of the green channel, and the B value represents the gray value of the blue channel. Optionally, as shown in the following formula:
[0191] Optionally, as shown in the following formula:
[0192]
[0193] The pixel difference value of the two filling pixel points in the preset direction is determined, and the R value difference, the G value difference and the B value difference between the two filling pixel points are determined respectively; the pixel difference value of the two filling pixel points is determined according to the R value difference, the G value difference and the B value difference, wherein the R value represents the gray value of the red channel, the G value represents the gray value of the green channel, and the B value represents the gray value of the blue channel. Optionally, as shown in the following formula:
[0194] The third distance between the filling pixel points is determined, and optionally, when the filling pixel points include only two pixel points in the first direction, and the two pixel points are located at two sides of the pixel points in the region to be filled, the third distance between the two filling pixel points is determined.
[0195] Optionally, when the filling pixel points include two pixel points in the first direction and two pixel points in the second direction, and the four pixel points are located at four directions of the pixel points in the region to be filled, the pixel difference value of the two filling pixel points in the first direction is determined, and the pixel difference value of the two filling pixel points in the second direction is determined.
[0196]
[0197] D1 is the third distance between the pixel point in the positive direction of the first direction and the pixel point in the to-be-filled region, (x, y) is the coordinate of the pixel point in the to-be-filled region, and (x1, y1) is the coordinate of the pixel point in the positive direction of the first direction.
[0198]
[0199] D2 is the third distance between the pixel point in the negative direction of the first direction and the pixel point in the to-be-filled region, (x, y) is the coordinate of the pixel point in the to-be-filled region, and (x2, y2) is the coordinate of the pixel point in the negative direction of the first direction.
[0200]
[0201] D3 is the third distance between the pixel point in the positive direction of the second direction and the pixel point in the to-be-filled region, (x, y) is the coordinate of the pixel point in the to-be-filled region, and (x3, y3) is the coordinate of the pixel point in the positive direction of the second direction.
[0202]
[0203] D4 is the third distance between the pixel point in the negative direction of the second direction and the pixel point in the to-be-filled region, (x, y) is the coordinate of the pixel point in the to-be-filled region, and (x4, y4) is the coordinate of the pixel point in the negative direction of the second direction.
[0204] According to the pixel difference value and the third distance, the pixel value of the pixel point in the to-be-filled region is determined. Optionally, when the filling pixel points only include two pixel points in the first direction, and the two pixel points are located on both sides of the pixel point in the to-be-filled region, the channel weight parameter of the pixel difference value is determined according to the third distance corresponding to the first direction; and the pixel value of the pixel point in the to-be-filled region is determined according to the pixel difference value and the corresponding channel weight parameter.
[0205] For example, the channel weight parameter of the pixel difference value is determined according to the third distance corresponding to the first direction, for example, as shown in the following formula:
[0206] K1=D2 / (D1+D2);
[0207] K2=D1 / (D1+D2);
[0208] K1 and K2 are channel weight parameters, D1 is the third distance between the pixel point in the positive direction of the first direction and the corresponding pixel point in the to-be-filled region, and D2 is the third distance between the pixel point in the negative direction of the first direction and the corresponding pixel point in the to-be-filled region.
[0209] According to the pixel difference value and the corresponding channel weight parameter, the pixel value of the pixel point in the to-be-filled region is determined, and an example is as follows:
[0210] (R, G, B) = ((R2 x K1 + R1 x K1), (G2 x K1 + G1 x K2), (B2 x K1 + B1 x K2));
[0211] K1 and K2 are channel weight parameters, R1, G1, and B1 are R value, G value, and B value of the filling pixel point in the positive direction of the first direction respectively, and R2, G2, and B2 are R value, G value, and B value of the filling pixel point in the negative direction of the first direction respectively.
[0212] Optionally, when the filling pixel point includes two pixel points in the first direction and two pixel points in the second direction, and the four pixel points are located in four directions of the pixel point in the to-be-filled region, the minimum difference value is determined by comparing the pixel difference value in the first direction and the pixel difference value in the second direction; the direction corresponding to the minimum difference value is taken as a target direction, the channel weight parameter of the pixel difference value is determined according to the third distance corresponding to the target direction; and the pixel value of the pixel point in the to-be-filled region is determined according to the pixel difference value and the corresponding channel weight parameter.
[0213] For example, if the pixel difference value in the first direction is smaller, the channel weight parameter of the pixel difference value is determined according to the third distance corresponding to the target direction, and an example is as follows:
[0214] K1 = D2 / (D1 + D2);
[0215] K2 = D1 / (D1 + D2);
[0216] K1 and K2 are channel weight parameters, D1 is the third distance between the filling pixel point in the positive direction of the first direction and the pixel point in the to-be-filled region corresponding to the filling pixel point, and D2 is the third distance between the filling pixel point in the negative direction of the first direction and the pixel point in the to-be-filled region corresponding to the filling pixel point.
[0217] According to the pixel difference value and the corresponding channel weight parameter, the pixel value of the pixel point in the to-be-filled region is determined, and an example is as follows:
[0218] (R, G, B) = ((R2 x K1 + R1 x K1), (G2 x K1 + G1 x K2), (B2 x K1 + B1 x K2));
[0219] K1 and K2 are channel weight parameters, R1, G1, and B1 are R value, G value, and B value of the filling pixel point in the positive direction of the first direction respectively, and R2, G2, and B2 are R value, G value, and B value of the filling pixel point in the negative direction of the first direction respectively.
[0220] Exemplarily, if the pixel difference in the second direction is small, the channel weight parameter of the pixel difference is determined according to the third distance corresponding to the target direction, which is exemplarily shown in the following formula:
[0221] K3=D4 / (D3+D4);
[0222] K4=D3 / (D3+D4);
[0223] Among them, K3 and K4 are channel weight parameters, D3 is the third distance between the filling pixel point in the positive direction of the second direction and the corresponding pixel point in the area to be filled, and D4 is the third distance between the filling pixel point in the negative direction of the second direction and the corresponding pixel point in the area to be filled.
[0224] The pixel value of the pixel point in the area to be filled is determined according to the pixel difference and the corresponding channel weight parameter. For example, the formula is as follows:
[0225] (R,G,B)=((R4×K3+R3×K3), (G4×K3+G3×K4), (B4×K3+B3×K4));
[0226] Among them, K3 and K4 are channel weight parameters, R3, G3, and B3 are the R value, G value, and B value of the filling pixel points in the positive direction of the second direction, respectively, and R4, G4, and B4 are the R value, G value, and B value of the filling pixel points in the negative direction of the second direction, respectively.
[0227] In the technical solution of this embodiment, when the filling pixels include multiple pixels in a preset direction, the pixel difference between the filling pixel values of the filling pixels is determined, and a third distance between the filling pixels is determined; and the pixel values of the pixels in the area to be filled are determined based on the pixel difference and the third distance. By comprehensively considering the pixel difference and the third distance of the filling pixels, the pixel values of the corresponding pixels in the area to be filled are determined, so that the pixel values of the pixels in the area to be filled are more consistent with the surrounding image of the area to be filled. The updated pixel value transition of the area to be filled is smoother and less incongruous, thereby reducing the filling traces in the area to be filled.
[0228] Reference Figure 13 , a video image covering device, the video image covering device comprising:
[0229] A determination module 100 is used to determine a to-be-filled area of a video image to be processed;
[0230] A calculation module 200 is used to expand the area to be filled to obtain an expanded area;
[0231] A selection module 300 is configured to select, within the expansion region, filling pixels corresponding to pixels in the area to be filled;
[0232] The covering module 400 is configured to update the pixel value of the pixel point in the to-be-filled region according to the filling pixel value of the filling pixel point.
[0233] In an embodiment, in the process of expanding the to-be-filled region to obtain the inflation region, the calculation module 200 is specifically configured to:
[0234] sliding a sliding window with a preset size on the to-be-processed video image to determine a first set of pixel points located in the sliding window and outside the to-be-filled region;
[0235] determining the inflation region according to the first set.
[0236] In an embodiment, in the process of determining the inflation region according to the first set, the calculation module 200 is specifically configured to:
[0237] determining a second set of pixel points located in a preset range of the to-be-filled region edge and outside the to-be-filled region;
[0238] if an intersection of the first set and the second set is greater than a preset proportion, taking the pixel points in the first set as the pixel points in the inflation region.
[0239] In an embodiment, in the process of selecting the filling pixel point corresponding to the pixel point in the to-be-filled region in the inflation region, the selection module 300 is specifically configured to:
[0240] determining a first boundary and a second boundary of the inflation region, the first boundary being a boundary at which the to-be-filled region and the inflation region meet, and the second boundary being a peripheral boundary of the inflation region;
[0241] determining a first distance between the pixel point in the to-be-filled region and the first boundary;
[0242] determining the filling pixel point corresponding to the pixel point in the to-be-filled region according to the first distance between the first boundary and the second boundary.
[0243] In an embodiment, in the process of determining the filling pixel point corresponding to the pixel point in the to-be-filled region according to the first distance between the first boundary and the second boundary, the selection module 300 is specifically configured to:
[0244] determining a second distance between the first boundary and the second boundary;
[0245] determining the filling pixel point corresponding to the pixel point in the to-be-filled region according to a size relationship between the first distance and the second distance between the first boundary and the second boundary.
[0246] In an embodiment, in updating the pixel value of the pixel point in the region to be filled according to the filling pixel value of the filling pixel point, the covering module 400 is specifically configured to:
[0247] When the filling pixel point comprises a plurality of pixel points in a preset direction, a pixel difference value between the filling pixel values of the filling pixel point is determined, and a third distance between the filling pixel points is determined.
[0248] According to the pixel difference value and the third distance, the pixel value of the pixel point in the region to be filled is determined.
[0249] In an embodiment, in determining the pixel value of the pixel point in the region to be filled according to the pixel difference value and the third distance, the covering module 400 is specifically configured to:
[0250] Comparing the pixel difference value in the first direction with the pixel difference value in the second direction, a minimum difference value is determined.
[0251] Taking the direction corresponding to the minimum difference value as a target direction, a channel weight parameter of the pixel difference value is determined according to the third distance corresponding to the target direction.
[0252] According to the pixel difference value and the corresponding channel weight parameter, the pixel value of the pixel point in the region to be filled is determined.
[0253] The present application also provides a video image covering device, which comprises a memory, a processor, and a video image covering program stored in the memory and executable on the processor, and when the video image covering program is executed by the processor, each step of the video image covering method is implemented.
[0254] The present application also provides a computer readable storage medium, which stores a video image covering program, and when the video image covering program is executed by a processor, each step of the video image covering method is implemented.
[0255] The above-mentioned embodiment numbers of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0256] It should be noted that, in the present document, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, system, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, system, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, system, article, or apparatus that comprises the element.
[0257] Through the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment system can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a computer readable storage medium (such as a ROM / RAM, a magnetic disk, or an optical disc) as described above, and includes a number of instructions for causing an end device (which can be a mobile phone, a computer, a parking management device, an air conditioner, or a network device, etc.) to execute the system described in each embodiment of the present application.
[0258] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent flow transformation made by using the content of the present application specification and drawings, or directly or indirectly applied to other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method of masking a video image, characterized by, The method for covering the video image comprises: determining a to-be-filled region of a to-be-processed video image; sliding a preset-size sliding window on the to-be-processed video image to determine a first set of pixel points located within the sliding window and outside the to-be-filled region; determining an expansion region according to the first set, wherein a second set of pixel points located within a preset range of the edge of the to-be-filled region and outside the to-be-filled region is determined; if the intersection of the first set and the second set is greater than a preset proportion, the pixel points in the first set are taken as the pixel points in the expansion region; selecting, within the expansion region, a filling pixel point corresponding to a pixel point in the to-be-filled region; updating the pixel value of the pixel point in the to-be-filled region according to the filling pixel value of the filling pixel point.
2. The method of claim 1, wherein, The step of selecting, within the expansion region, a filling pixel point corresponding to a pixel point in the to-be-filled region comprises: determining a first boundary and a second boundary of the expansion region, wherein the first boundary is the boundary at the junction of the to-be-filled region and the expansion region, and the second boundary is the peripheral boundary of the expansion region; determining a first distance between the pixel point in the to-be-filled region and the first boundary; determining, according to the first distance between the first boundary and the second boundary, the filling pixel point corresponding to the pixel point in the to-be-filled region.
3. The method of claim 2, wherein, The step of determining, according to the first distance between the first boundary and the second boundary, the filling pixel point corresponding to the pixel point in the to-be-filled region comprises: determining a second distance between the first boundary and the second boundary; determining, according to the size relationship between the first distance and the second distance, the filling pixel point corresponding to the pixel point in the to-be-filled region between the first boundary and the second boundary.
4. The method of claim 1, wherein, The step of updating the pixel value of the pixel point in the to-be-filled region according to the filling pixel value of the filling pixel point comprises: when the filling pixel point comprises a plurality of pixel points in a preset direction, determining a pixel difference value between the filling pixel values of the filling pixel points and a third distance between the filling pixel points; determining the pixel value of the pixel point in the to-be-filled region according to the pixel difference value and the third distance.
5. The method of claim 4, wherein, The preset direction comprises a first direction and a second direction, the first direction and the second direction are perpendicular, and the step of determining the pixel value of the pixel point in the to-be-filled region according to the pixel difference value and the third distance comprises: comparing the pixel difference value in the first direction with the pixel difference value in the second direction to determine a minimum difference value; taking the direction corresponding to the minimum difference value as a target direction, determining a channel weight parameter of the pixel difference value according to the third distance corresponding to the target direction; and determining the pixel value of the pixel point in the to-be-filled region according to the pixel difference value and the corresponding channel weight parameter.
6. A concealing device for video images, characterized in that The device for covering the video image comprises: a determining module configured to determine a to-be-filled region of a to-be-processed video image; a calculation module configured to slide a sliding window of a preset size over the video image to be processed, determine a first set of pixel points within the sliding window and outside the area to be filled; determine a dilated area based on the first set, wherein a second set of pixel points is determined that is within a preset range of an edge of the area to be filled and outside the area to be filled; and if the intersection of the first set and the second set is greater than a preset ratio, use the pixel points in the first set as the pixel points in the dilated area; A selection module, configured to select, within the expansion region, filling pixels corresponding to pixels in the area to be filled; The masking module is used to update the pixel values of the pixels in the area to be filled according to the filling pixel values of the filling pixels.
7. A concealing device for video images, characterized in that The video image masking device includes a memory, a processor, and a video image masking program stored in the memory and executable on the processor. When the video image masking program is executed by the processor, the various steps of the video image masking method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a video image masking program, and when the video image masking program is executed by a processor, each step of the video image masking method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and apparatus for removing watermark from video
WO2017016294A1