A color comparison method for video images, terminal equipment and storage medium

By using the color comparison method in the video image cutting processing, using the preorder frame data and the preset distance range, the problem of insufficient cutout accuracy and anti-interference in the prior art is solved, and a more stable and efficient video image processing is achieved.

CN113487689BActive Publication Date: 2025-03-28XIAMEN ZONGHENG GRP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110854850.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-28
Publication Date
2025-03-28
Estimated Expiration
2041-07-28

AI Technical Summary

Technical Problem

The prior art fails to effectively utilize pre-order frame data in video image cutting processing, resulting in low accuracy of cutout results and insufficient anti-interference.

Method used

A color comparison method for video images is adopted. By constructing an address list, the color distance of pixel points is calculated frame by frame, and the address list is updated according to the preset maximum and minimum distance ranges, and the judgment stability is improved in combination with the preset frame data.

Benefits of technology

By setting a judgment range with a certain width, disturbances around the threshold are overcome, the stability of judgment is significantly enhanced, and the accuracy and anti-interference of video image cutouts are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113487689B_ABST
    Figure CN113487689B_ABST
Patent Text Reader

Abstract

The present invention relates to a color comparison method for video images, a terminal device and a storage medium, wherein the method comprises: constructing an address list according to the number of pixels contained in the video image to be compared, wherein each address in the address list corresponds to each pixel in the video image to be compared, and each address is used to store the color comparison result of each pixel and the color to be compared; initializing and setting the value of each address; reading the video image to be compared frame by frame, and for each frame of the video image to be compared read in, sequentially calculating the distance between the color of each pixel and the color to be compared, and according to the size relationship between the calculated distance and the preset maximum distance and minimum distance, directly determining whether the color of each pixel in the video image to be compared in the frame is the same as the color to be compared according to the judgment result saved by the corresponding address of the point in the previous frame under specific conditions, and then updating the address list. The present invention increases the accuracy of the color comparison of the video image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image analysis, and particularly to a color comparison method, a terminal device, and a storage medium for video images. Background Art

[0002] Currently, in daily work and life, it is often necessary to perform matting processing on the people in video images to replace the background where the people are located. In the prior art, only each frame of video image can be separately matted, lacking the utilization of the data of the previous frames, resulting in the disadvantages of low accuracy and insufficient anti-interference ability of the matting result. Summary of the Invention

[0003] In order to solve the above problems, the present invention provides a color comparison method, a terminal device, and a storage medium for video images.

[0004] The specific solutions are as follows:

[0005] A color comparison method for video images includes:

[0006] Construct an address list according to the number of pixel points included in the video image to be compared. Each address in the address list corresponds to each pixel point in the video image to be compared one by one, and each address is used to store the color comparison result between the color of each pixel point and the color to be compared; initialize and set the value of each address;

[0007] Read in the video image to be compared frame by frame. For each frame of the video image to be compared read in, sequentially calculate the distance between the color of each pixel point and the color to be compared, and determine whether the color of each pixel point in the frame of the video image to be compared is the same as the color to be compared according to the size relationship between the calculated distance and the preset maximum distance and minimum distance, and then update the address list.

[0008] Further, the method for updating the address list according to the size relationship between the calculated distance Di and the preset maximum distance Dmax and minimum distance Dmin is:

[0009] When Di > Dmax, make the value of the corresponding address in the address list update to indicate that the comparison result is that the colors are different;

[0010] When Di < Dmin, make the value of the corresponding address in the address list update to indicate that the comparison result is that the colors are the same;

[0011] When Dmin ≤ Di ≤ Dmax, keep the value of the corresponding address in the address list unchanged.

[0012] Further, the calculation method for the distance between the color of the pixel point and the color to be compared is: calculate the distance between the chromaticity of the pixel point and the chromaticity of the color to be compared.

[0013] Furthermore, the chromaticity is calculated by the UV value in the LUV color space; if the video image to be compared is not in the LUV color space, it is first transformed in color space, converted into the LUV color space, and then calculated according to the UV value.

[0014] Furthermore, the UV value of a pixel is an original UV value of the pixel or an average of UV values ​​of surrounding pixels of the pixel.

[0015] Furthermore, the method for calculating the distance between the color of the pixel point and the color to be compared is: calculating the Euclidean distance between the color of the pixel point and the color to be compared.

[0016] Furthermore, the value of each address in the address list is 0 or 1, where 0 indicates different colors and 1 indicates the same colors.

[0017] Furthermore, the value of each address is initialized to indicate that the comparison result is that the colors are different.

[0018] A color comparison terminal device for video images comprises a processor, a memory and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described above in the embodiment of the present invention are implemented.

[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above in an embodiment of the present invention are implemented.

[0020] The present invention adopts the above technical solution to overcome the shortcomings of the existing method that only the current image is compared without combining the data of the previous frame image, which causes insufficient anti-interference ability. After calculating the distance, it is not compared with a certain threshold, but a judgment range with a certain width is set. When it is within the judgment range, the judgment result of the previous frame is maintained, thereby overcoming the disturbance around the threshold and greatly enhancing the stability of the judgment. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 Shown is a flow chart of Embodiment 1 of the present invention. DETAILED DESCRIPTION

[0022] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.

[0023] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.

[0024] Embodiment 1:

[0025] The embodiment of the present invention provides a color comparison method for video images, such as Figure 1 As shown, the method comprises the following steps:

[0026] S1: construct an address list according to the number of pixels contained in the video image to be compared, each address in the address list corresponds to each pixel in the video image to be compared, and each address is used to store the color comparison result of each pixel with the color to be compared.

[0027] The video image is an image corresponding to each frame in the video. The video image can be a real-time video stream captured by a camera or a recorded and stored video file.

[0028] In this embodiment, the address list is represented by Buffer, and Buffer (Pi) represents the value of the i-th address in the address list, which corresponds to the comparison result of the i-th pixel point in the video image to be compared.

[0029] S2: Initialize and set the value of each address.

[0030] Since the values ​​initialized in each address in the address list have an impact on the comparison result of the first frame, in order to make the judgment of each point in the first frame more accurate, the values ​​in the address list are all 0 in this embodiment. 0 indicates different colors, and 1 indicates the same colors. In other embodiments, other values ​​can also be used to indicate the same and different colors, which is not limited here.

[0031] S3: Read in a frame of video image to be compared.

[0032] S4: Calculate the distance Di between the color of each pixel in the read-in video image to be compared and the color to be compared in sequence.

[0033] In this embodiment, the distance between colors is preferably calculated by calculating the distance between chromaticity values, and the distance is calculated by using the Euclidean distance.

[0034] Furthermore, in order to better calculate the distance between chromaticity values, it is preferred to use the UV value in the LUV color space for calculation. In the LUV color space, L represents the brightness of the object, and U and V represent the chromaticity. If the video image to be compared is not in the LUV color space, it is first converted to a color space (such as from an RGB color space to a LUV color space), and then calculated according to the UV value after conversion to the LUV color space.

[0035] S5: Determine whether the color of each pixel in the video image to be compared in this frame is the same as the color to be compared according to the magnitude relationship between the calculated distance Di and the preset maximum distance Dmax and minimum distance Dmin, and then update the address list.

[0036] The update method of the address list in this embodiment is as follows: when Di > Dmax, it is determined that the colors are different, and the value of the corresponding address in the address list is updated to 0; when Di < Dmin, it is determined that the colors are the same, and the value of the corresponding address in the address list is updated to 1; when Dmin ≤ Di ≤ Dmax, the value of the corresponding address in the address list remains unchanged, that is, the determination result of the pixel at the same position in the video image to be compared in the previous frame is maintained.

[0037] In practical applications, for each frame, if a certain pixel satisfies Dmin ≤ Di ≤ Dmax, the value of the corresponding address in its address list remains unchanged. If it is the first frame, it remains the initial value; otherwise, it remains the comparison result of the corresponding pixel in the previous frame. If Di > Dmax is satisfied, the value of the corresponding address in its address list, whether it is 0 or 1, is still forced to be updated to 0. If Di < Dmin is satisfied, the value of the corresponding address in its address list, whether it is 0 or 1, is still forced to be updated to 1. Through this processing method, the situation of repeated flipping due to small changes in Di during single-threshold comparison can be avoided, and the comparison results of subsequent frames can be combined with the data characteristics of the previous frames, improving the anti-interference ability.

[0038] Those skilled in the art can set the maximum distance Dmax and the minimum distance Dmin according to their needs, and there is no limitation here.

[0039] Judge whether the colors are the same by the values of 0 or 1 of each address in the updated address list corresponding to the video image to be compared in this frame.

[0040] S6: Determine whether there is a next frame of video image to be compared. If so, return to S3 and read in the next frame of video image to be compared; otherwise, end.

[0041] The embodiment of the present invention overcomes the shortcoming of insufficient anti-interference caused by only comparing the current image and not combining the data of the previous frame image in the existing method. After calculating the distance, instead of comparing with a certain threshold, a determination range with a certain width is set. When within the determination range, the determination result of the previous frame is maintained, thus overcoming the perturbation around the threshold and greatly enhancing the stability of the judgment.

[0042] The method of this embodiment can be applied to a variety of usage scenarios, such as extracting the foreground from the green background of a video image. In this application, the color to be compared is green. When the judgment result is that the colors are the same, the corresponding pixel point is considered to be the background, and the corresponding pixel point is replaced with a specific pixel; when the judgment result is that the colors are different, the corresponding pixel point is considered to be the foreground, and the corresponding pixel point is retained. The final result is that the green background is replaced with a specific image corresponding to a specific pixel.

[0043] Embodiment 2:

[0044] The present invention also provides a color comparison terminal device for video images, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned method embodiment of the first embodiment of the present invention when executing the computer program.

[0045] Further, as an executable solution, the color comparison terminal device for video images can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The color comparison terminal device for video images may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the composition structure of the color comparison terminal device for video images is only an example of a color comparison terminal device for video images, and does not constitute a limitation on the color comparison terminal device for video images. It may include more or less components than the above, or a combination of certain components, or different components. For example, the color comparison terminal device for video images may also include input and output devices, network access devices, buses, etc., and the embodiments of the present invention do not limit this.

[0046] Further, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the color comparison terminal device for video images, and uses various interfaces and lines to connect various parts of the entire color comparison terminal device for video images.

[0047] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the color comparison terminal device for video images by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and an application required for at least one function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0048] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.

[0049] If the module / unit integrated in the color comparison terminal device for video images is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.

[0050] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.

Claims

1. A color comparison method for video images, characterized in that: Comprising: Construct an address list according to the number of pixel points included in the video image to be compared. Each address in the address list corresponds one by one to each pixel point in the video image to be compared, and each address is used to store the color comparison result between the color of each pixel point and the color to be compared; Initialize and set the value of each address. Read in the video image to be compared frame by frame. For each frame of the video image to be compared read in, sequentially calculate the distance between the color of each pixel point and the color to be compared, and determine whether the color of each pixel point in this frame of the video image to be compared is the same as the color to be compared according to the magnitude relationship between the calculated distance and the preset maximum distance and minimum distance, and then update the address list. The method for updating the address list according to the magnitude relationship between the calculated distance Di and the preset maximum distance Dmax and minimum distance Dmin is as follows: When Di > Dmax, make the value of the corresponding address in the address list updated to indicate that the comparison result is that the colors are different. When Di < Dmin, make the value of the corresponding address in the address list updated to indicate that the comparison result is that the colors are the same. When Dmin ≤ Di ≤ Dmax, make the value of the corresponding address in the address list remain unchanged.

2. The color comparison method for video images according to claim 1, characterized in that: The calculation method for the distance between the color of a pixel point and the color to be compared is: Calculate the distance between the chromaticity of the pixel point and the chromaticity of the color to be compared.

3. The color comparison method for video images according to claim 2, characterized in that: The chromaticity is calculated through the UV values in the LUV color space; If the video image to be compared is not in the LUV color space, first perform a color space transformation on it, and after converting it to the LUV color space, then calculate according to the UV values.

4. The color comparison method for video images according to claim 3, characterized in that: The UV value of a pixel point is the original UV value of the pixel point or the average value of the UV values of the surrounding pixel points of the pixel point.

5. The color comparison method for video images according to claim 1, characterized in that: The calculation method for the distance between the color of a pixel point and the color to be compared is: Calculate the Euclidean distance between the color of the pixel point and the color to be compared.

6. The color comparison method for video images according to claim 1, characterized in that: The values of the addresses in the address list are 0 or 1, where 0 indicates that the colors are different and 1 indicates that the colors are the same.

7. The color comparison method for video images according to claim 1, characterized in that: Initialize and set the value of each address to indicate that the comparison result is that the colors are different.

8. A color comparison terminal device for video images, characterized in that: Comprising a processor, a memory, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, it implements the steps of the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Compression method capable of precisely expressing difference between two images of video file

    CN108540799A

  • Background-foreground module for video analysis system

    US20090087096A1