Nothing Special   »   [go: up one dir, main page]

CN112102219B - Method and device for picking image-text in image - Google Patents

Method and device for picking image-text in image Download PDF

Info

Publication number
CN112102219B
CN112102219B CN202011243812.0A CN202011243812A CN112102219B CN 112102219 B CN112102219 B CN 112102219B CN 202011243812 A CN202011243812 A CN 202011243812A CN 112102219 B CN112102219 B CN 112102219B
Authority
CN
China
Prior art keywords
picture
channel value
image
pixel point
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011243812.0A
Other languages
Chinese (zh)
Other versions
CN112102219A (en
Inventor
何志民
宁一铮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Colorlight Cloud Technology Co Ltd
Original Assignee
Colorlight Shenzhen Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Colorlight Shenzhen Cloud Technology Co Ltd filed Critical Colorlight Shenzhen Cloud Technology Co Ltd
Priority to CN202011243812.0A priority Critical patent/CN112102219B/en
Publication of CN112102219A publication Critical patent/CN112102219A/en
Application granted granted Critical
Publication of CN112102219B publication Critical patent/CN112102219B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/30Determination of transform parameters for the alignment of images, i.e. image registration
    • G06T7/33Determination of transform parameters for the alignment of images, i.e. image registration using feature-based methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The invention relates to the technical field of picture processing, and particularly discloses a method and a device for picking pictures and texts in an image, wherein the method comprises the following steps: drawing a first picture of three channels according to a preset first picture drawing strategy; drawing a third picture of the three channels according to a preset second picture drawing strategy; drawing a third picture of the four channels according to a preset third picture drawing strategy; and correspondingly enabling the pixel points of the first picture, the second picture and the third picture to correspond one to one, and resetting each pixel point of the third picture to generate a target picture. The invention realizes the scratching of the color image-text, generates the target picture with translucency, further improves the anti-aliasing effect of the target picture, and has very good display effect when the target picture is superposed on other pictures or videos; on the other hand, the invention is not limited to the picking of patterns or characters and the color effect of the pictures and the texts, and completely reforms the current situation that the prior art can only pick single color pictures and texts.

Description

Method and device for picking image-text in image
Technical Field
The invention relates to the technical field of picture processing, in particular to a method and a device for picking pictures and texts in an image.
Background
At present, in a mode of directly fusing the picture content with the video or another picture, the picture content and the picture background need to be separated from the picture, wherein the picture content refers to the pictures and texts in the picture, and the picture background refers to the content except the picture content.
In the prior art, the image content and the image background are separated by means of image matting of an image-text engine, and a new image with the image content is generated by the image content. However, the anti-aliasing effect of the new picture with the picture content after the existing picture and text engine is separated is very poor, the display precision of the new picture with the picture content is not high, the use effect of the new picture with the picture content is obviously affected, and the image matting mode of the existing picture and text engine generally cannot support non-standard artistic characters and color characters (including gradually changed color characters and color characters with multiple colors, wherein one color character or multiple color characters can exist in the picture content), so that the situations including the non-standard artistic characters and the color characters cannot be well scratched or separated, for example, the ground color is white, the font edge in the foreground is black, the middle is also white, and the scratched foreground can have a middle full-transparency effect.
Therefore, there is a need to find a new technical solution to solve the above problems.
Disclosure of Invention
Aiming at the technical problems in the prior art, the invention provides a method and a device for picking pictures and texts in an image.
A method for picking image-text in an image comprises the following steps:
drawing a first picture of three channels according to a preset first picture drawing strategy;
drawing a third picture of the three channels according to a preset second picture drawing strategy;
drawing a third picture of the four channels according to a preset third picture drawing strategy;
the pixel points of the first picture, the second picture and the third picture are in one-to-one correspondence, and each pixel point of the third picture is reset to generate a target picture;
wherein, resetting each pixel of the third picture comprises:
for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point are respectively RedB, GreenB and BlueB;
normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the G channel value and the B channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB';
updating the alphaC ' values of all pixel points of the third picture, wherein the alphaC ' = RedA ';
and updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 315099DEST_PATH_IMAGE001
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with alpha ' 1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB ';
and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
Further, the first picture drawing strategy is as follows: and generating a first black background according to a preset picture resolution, generating a first picture and text according to a preset first picture and text generation strategy, and combining the first black background and the first picture and text according to a preset combination strategy.
Further, the second picture drawing strategy is as follows: and generating a second black background according to a preset picture resolution, generating a second image-text according to a preset second image-text generation strategy, and combining the second black background and the second image-text according to a preset combination strategy.
Further, the first image-text generation strategy is as follows: generating white pictures and texts by using preset characters and preset patterns; the second image-text generation strategy is as follows: and generating the colorful pictures and texts by combining the preset characters and the preset patterns with the pre-selected colors.
Further, the third picture drawing strategy is as follows: and generating a full transparent picture at a preset picture resolution.
Further, the combination strategy is: and superposing the image on the background according to a preset position relation.
Further, the channel values of all the pixel points of the third picture are denormalized and are taken as integers, and the method comprises the following steps: and (4) rounding the denormalized channel value.
The invention also provides a device for picking the image and the text in the image, which comprises a first image drawing module, a second image drawing module, a third image drawing module and a third image setting module, wherein:
the first picture drawing module is connected with the third picture setting module; the first picture drawing module is used for drawing a three-channel first picture according to a preset first picture drawing strategy;
the second picture drawing module is connected with the third picture setting module; the second picture drawing module is used for drawing a third picture of the three channels according to a preset second picture drawing strategy;
the third picture drawing module is connected with the third picture setting module; the third picture drawing module is used for drawing a third picture of the four channels according to a preset third picture drawing strategy;
the third picture setting module is connected with the first picture drawing module, the second picture drawing module and the third picture drawing module; the third picture setting module is used for corresponding the pixel points of the first picture, the second picture and the third picture one by one, resetting each pixel point of the third picture and generating a target picture; wherein, the third picture presumes that the module resets including to every pixel of the third picture:
for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point are respectively RedB, GreenB and BlueB;
normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the G channel value and the B channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB';
updating the alphaC ' values of all pixel points of the third picture, wherein the alphaC ' = RedA ';
and updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 14370DEST_PATH_IMAGE001
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with alpha ' 1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB ';
and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
The invention also provides a picture superposition display method, which comprises the following steps:
generating a target picture by the method;
superposing the target picture in the selected picture according to a preset superposition strategy to obtain a superposed picture;
and displaying the superposed pictures.
The invention also provides a picture superposition display device, which comprises the picture-text digging device, a picture superposition device and a display device, wherein:
the image-text digging device is connected with the image superposition device; the image-text matting device is used for generating a target image;
the picture stacking device is connected with the image-text digging device and the display device; the image superposition device is used for superposing the target image in the selected image according to a preset superposition strategy to obtain a superposed image;
the display device is connected with the picture superposition device; the display device is used for displaying the superposed pictures.
The image-text matting method in the image realizes matting of color images and texts, and finally generates a target image with translucency by setting an Alpha channel, so that the anti-aliasing effect of the target image is improved, and the target image can have a very good display effect when being overlaid in other images or videos; on the other hand, the invention is not limited to the picking of patterns or characters and the color effect of the pictures and the texts, and completely reforms the current situation that the prior art can only pick single color pictures and texts.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart illustrating steps of a method for image matting according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a display effect of a first picture according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a display effect of a second picture according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating steps of a method for image matting according to another embodiment of the present invention;
FIG. 5 is a diagram illustrating the display effect of a target picture according to an embodiment of the present invention;
FIG. 6 is a structural diagram of an image matting apparatus according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating steps of a method for displaying images in an overlay manner according to an embodiment of the present invention;
fig. 8 is a structural composition diagram of a picture overlaying display device according to an embodiment of the present invention.
Fig. 9 is a diagram of a picture superimposition effect according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings in the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, a method for image-text matting in an image according to an embodiment of the present invention includes the following steps:
step S101: and drawing a first picture of the three channels according to a preset first picture drawing strategy.
The first picture is used as a medium for subsequent image-text matting, and is generated through a preset first picture drawing strategy, where the first picture drawing strategy may include limitation on pixels (size) and content of the first picture, the first picture in this embodiment is a three-channel picture, and those skilled in the art can know that three channels are an R (red) channel, a G (green) channel, and a B (blue) channel, respectively, each pixel of the first picture is represented by three values, and the value ranges of the values are different according to the difference of channel depths, for example, when the channel depth is 8 bits, the value range of the value is 0-255. The content contained in the first picture depends on the content to be extracted. Specifically, the first picture drawing strategy in this embodiment is as follows: and generating a first black background according to a preset picture resolution, generating a first picture and text according to a preset first picture and text generation strategy, and combining the first black background and the first picture and text according to a preset combination strategy. The preset picture resolution is set for the size of the first picture, the first image-text generation strategy is used for limiting the first image-text, and the first black background and the first image-text with the preset resolution are used for generating the first picture according to the preset combination strategy. The image resolution is selected by the staff according to the specific requirements, first images and texts with specific colors and specific image and text contents are generated according to a first image and text generation strategy, and the first images and texts are combined according to a combination strategy. Specifically, the combination strategy of the combination of the present application may be: and superposing the first image and the first text on the background according to a preset position relation so as to limit the position relation between the first image and the first black background. And after the first picture is generated according to the process, executing the next step.
Step S102: and drawing a third-channel second picture according to a preset second picture drawing strategy.
The steps S102 and S101 can be performed in a reversed order during the implementation, that is, the second picture is generated first and then the first picture is generated, which does not affect the subsequent steps.
And the second picture is used as a target for subsequent image-text matting and is generated through a preset second picture drawing strategy. The method is used for realizing the scratching of the image-text in the second picture so as to be superposed with other files for application. Referring to the first picture drawing strategy in step S101, in order to achieve the best image-text matting effect, when the second picture drawing strategy and the first picture drawing strategy are preset, the basic characteristic parameters are kept the same, which facilitates correspondence in subsequent steps. Therefore, the second picture drawing policy is set to: and generating a second black background according to a preset picture resolution, generating a second image-text according to a preset second image-text generation strategy, and combining the second black background and the second image-text according to a preset combination strategy. The second picture is also a three-channel picture, wherein the second picture drawing strategy and the first picture drawing strategy adopt the same picture drawing strategy, so that the finally generated first picture and the second picture have the same size, and each pixel point can be in one-to-one correspondence. The background of the second picture is also generated as black, and the first picture differs from the second picture only in the difference between the first and second teletext strategy.
Specifically, the first image-text generation strategy is set as follows: generating white pictures and texts by using preset characters and preset patterns; the second image-text generation strategy is as follows: and generating the colorful pictures and texts by combining the preset characters and the preset patterns with the pre-selected colors. Therefore, the difference between the first picture and the second picture is that the colors of the pictures and texts are white and colored respectively, and the pictures and texts have the same preset pattern and the same preset characters. The present embodiment does not propose setting the sizes of the pattern and the text, that is, the text and the pattern in the first picture and the second picture are the same size by default. As shown in fig. 2 and 3, which are examples of a first picture and a second picture, respectively. The color in the invention can be the filling of single color of any pattern or character, and can also be the filling of multiple colors with gradual change effect, and the design scheme can be suitable for the image and text as long as the image and text are colored. And the finally extracted image-text by the method of the embodiment of the invention is the color image-text in the second picture.
In the process of generating the first picture or the second picture, no matter the color of the image and text is white or colored, when the image and text is combined with a black background, the gradual change from white to black or from colored to black appears at the position of the edge of the image and text due to the anti-aliasing effect, which is a characteristic of all graphic software in the process of generating the picture, so as to say in the background art, the effect of image and text matting is deteriorated due to the anti-aliasing factor, and the invention mainly aims at further improving the problem.
The embodiment of the invention takes the channel depth of 8 bits as an example, and the implementation of the whole scheme is explained. However, the scheme of the present invention is also applicable to 10 bits, 12 bits, 16 bits, and the like, and only "255" needs to be replaced by "1023" when the maximum value of the corresponding channel depth is replaced by "255", for example, in the case of 10 bits.
In the embodiment of the invention, the R channel value, the G channel value and the B channel value of the first picture are respectively RedA, GreenA and BlueA, and the R channel value, the G channel value and the B channel value of the pixel point of the second picture are respectively RedB, GreenB and BlueB. Due to the anti-aliasing effect, the values of RedA, GreenA and BlueA of pixel points at the black background in the first picture are the same and are all 0; the values of RedA, GreenA and BlueA of the pixels in the white image-text are the same and are 255, and the values of RedA, GreenA and BlueA of the pixels in the sawtooth area are the same and are more than 0 and less than 255. For the second picture, values of RedB, GreenB and BlueB of pixel points at the black background are the same and are all 0; RedB, GreenB and BlueB values of pixel points in the color image-text or the sawtooth area are different, and the value range is 0-255. The R channel value, the G channel value, and the B channel value of the pixel points in the sawtooth areas of the first picture and the second picture are automatically generated when the background and the image are combined, and the specific values are not limited in this embodiment. And after the first picture and the second picture are generated according to the steps, the following steps are continuously executed.
Step S103: and drawing a third picture of the four channels according to a preset third picture drawing strategy.
The third picture of this embodiment is a four-channel picture, that is, compared with the RGB three channels of the first picture and the second picture, the third picture of this embodiment also has an Alpha channel, which has a limitation on transparency. Referring to the first picture and the second picture generated in the foregoing steps, the third picture in this embodiment also has the same resolution. Since the subsequent steps involve resetting the pixel points of the third picture, the color and content displayed by the third picture are not limited in this embodiment. Preferably, the third picture drawing policy in the present embodiment is set to: and generating a full transparent picture by using a preset picture resolution, namely the RGB three channels have a value of 0 and the Alpha channel has a value of 0.
In this embodiment, media used for drawing the first picture, the second picture, and the third picture are not limited, and those skilled in the art may implement the media by using existing picture processing software, such as Photoshop, office series, or other common software, or industrial application software. And after the first picture, the second picture and the third picture are generated according to the steps, continuing to execute the issuing step.
Step S104: and correspondingly enabling the pixel points of the first picture, the second picture and the third picture to correspond one to one, and resetting each pixel point of the third picture to generate a target picture.
The first picture, the second picture and the third picture generated according to the steps have the same pixel points and have the same size, so that after the pixel points are in one-to-one correspondence, each pixel point of the third picture is redefined according to the following rule, and the picture generated according to the set Alpha channel value and the set RGB three channel value is the target picture. As shown in fig. 4, resetting each pixel point of the third picture in step S104 specifically includes the following steps:
step S1041: and for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point are respectively RedB, GreenB and BlueB.
As shown in tables 1 to 3, taking a fully transparent third picture as an example, a pixel 1, a pixel 2, and a pixel 3 are selected from the third picture, and a pixel 1A, a pixel 2A, and a pixel 3A, a pixel 1B, a pixel 2B, and a pixel 3B corresponding to the first picture and the second picture are correspondingly found and their values are listed.
TABLE 1
Figure 186332DEST_PATH_IMAGE002
TABLE 2
Figure 477636DEST_PATH_IMAGE003
TABLE 3
Figure 479090DEST_PATH_IMAGE004
According to the channel values of the pixel points in tables 1 to 3, it can be known that the pixel point 1A is at the black background of the first picture, the pixel point 2A is at the sawtooth area where the black background and the white picture and text of the first picture are intersected, the pixel point 3A is in the white picture and text of the first picture, the pixel point 1B is at the black background of the second picture, the pixel point 2B is at the sawtooth area where the black background and the color picture and text of the second picture are intersected, and the pixel point 3B is in the color picture and text of the second picture.
After the pixel points of the first picture, the second picture and the third picture are in one-to-one correspondence, the following steps are continuously executed:
step S1042: normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the G channel value and the B channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB'.
Taking a picture with a channel depth of 8 bits as an example, the normalization process is a process of dividing a channel value by 255. Normalization processing is performed on the three pixel points according to the pixel point 1, the pixel point 2 and the pixel point 3 listed in tables 1 to 3, and specific values (three bits are taken after the decimal point) are shown in tables 4 to 6 below.
TABLE 4
Figure 537045DEST_PATH_IMAGE005
TABLE 5
Figure 674765DEST_PATH_IMAGE006
TABLE 6
Figure 402550DEST_PATH_IMAGE007
After the normalization step is finished, the following steps are continuously executed:
step S1043: and updating the AlphaC ' values of all pixel points of the third picture, wherein the AlphaC ' = RedA '.
That is, the updated AlphaC' values of pixel 1, pixel 2, and pixel 3 are 0, 0.137, and 1, respectively.
Step S1044: and updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 750355DEST_PATH_IMAGE001
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with AlphaC ' =1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB '.
For a pixel with AlphaC '= 0, let red c' =0, GreenC '= 0, and BlueC' =0. That is, for pixel 1 of AlphaC ' =0, Red ' C ' =0, GreenC ' =0, and BlueC ' =0.
For alpha C'
Figure 221787DEST_PATH_IMAGE001
For the pixel (0, 1), the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '. That is, for the pixel 2 with alpha ' =0.137, the division of RedB ' and RedA ' is 0.059/0.137
Figure 338648DEST_PATH_IMAGE008
0.431; GreenB 'divided by GreenA' by 0.078/0.137
Figure 502913DEST_PATH_IMAGE008
0.569; the division of BlueB 'by BlueA' was 0.098/0.137
Figure 478959DEST_PATH_IMAGE008
0.718。
For a pixel point with AlphaC ' =1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB '. That is, for pixel 3 of AlphaC '= 1, red c' =0.667, GreenC '= 0.451, and BlueC' = 0.800.
Step S1045: and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
The inverse normalization process is opposite to the normalization process, and takes a picture with a channel depth of 8 bits as an example, the inverse normalization process is a process of multiplying a channel value by 255. After taking an integer from the obtained result, the Alpha channel value and the RGB channel value of the pixel point 1, the pixel point 2, and the pixel point 3 are as shown in table 7 below:
TABLE 7
Figure 849023DEST_PATH_IMAGE009
In table 7, the recc value of pixel 2 is 255 × (15/255)/(35/255), the GreenC value of pixel 2 is 255 × (20/255)/(35/255), and the BlueC value is 255 × (25/255)/(35/255), and this embodiment does not limit the rule of taking integers for the channel values in this step, and the rounding may be performed by a truncation method, or a carry rounding method, or preferably, a rounding method is performed. Therefore, the RedC value of pixel point 2 is 109, the GreenC value is 146; the BlueC value was 182.
As can be seen from table 7, the target picture obtained by the method of the present invention has the effects of completely transparent background, partially transparent sawtooth region, and completely opaque color image-text, so as to achieve the purpose of extracting the color image-text in the second picture, as shown in fig. 2, 3, and 5, which are the display effects of the first picture, the second picture, and the target picture, respectively.
The image-text matting method in the image realizes matting of color images and texts, and finally generates a target image with translucency by setting an Alpha channel, so that the anti-aliasing effect of the target image is improved, and the target image can have a very good display effect when being overlapped in the image or video; on the other hand, the invention is not limited to the picking of patterns or characters and the color effect of the pictures and the texts, and completely reforms the current situation that the prior art can only pick single color pictures and texts.
The present invention further provides an image-text matting device in an image, as shown in fig. 6, the image-text matting device 100 includes a first picture drawing module 101, a second picture drawing module 102, a third picture drawing module 103, and a third picture setting module 104, wherein: the first picture drawing module 101 is connected 104 with the third picture setting module; the first picture drawing module 101 is used for drawing a three-channel first picture according to a preset first picture drawing strategy; the second picture drawing module 102 is connected with the third picture setting module 104; the second picture drawing module 102 is configured to draw a third picture of the three channels according to a preset second picture drawing policy; the third picture drawing module 103 is connected with the third picture setting module 104; the third picture drawing module 103 is configured to draw a third picture of the four channels according to a preset third picture drawing policy; the third picture setting module 104 is connected with the first picture drawing module 101, the second picture drawing module 102 and the third picture drawing module 103; the third picture setting module 104 is configured to correspond the pixel points of the first picture, the second picture, and the third picture one to one, and reset each pixel point of the third picture to generate a target picture; the third picture setting module 104 resets each pixel point of the third picture, including:
for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point are respectively RedB, GreenB and BlueB;
normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the G channel value and the B channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB';
updating the alphaC ' values of all pixel points of the third picture, wherein the alphaC ' = RedA ';
and updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 226915DEST_PATH_IMAGE001
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with alpha ' 1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB ';
and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
Preferably, the denormalizing the channel values of all the pixel points of the third picture and taking an integer includes: and (4) rounding the denormalized channel value.
Wherein the first picture drawing strategy is: and generating a first black background according to a preset picture resolution, generating a first picture and text according to a preset first picture and text generation strategy, and combining the first black background and the first picture and text according to a preset combination strategy. The second picture drawing strategy is: and generating a second black background according to a preset picture resolution, generating a second image-text according to a preset second image-text generation strategy, and combining the second black background and the second image-text according to a preset combination strategy. The third picture drawing strategy is as follows: and generating a full transparent picture at a preset picture resolution. The first image-text generation strategy is as follows: generating white pictures and texts by using preset characters and preset patterns; the second image-text generation strategy is as follows: and generating the colorful pictures and texts by combining the preset characters and the preset patterns with the pre-selected colors. The combination strategy is: and superposing the image on the background according to a preset position relation.
For the generation process of the target picture in this embodiment, the method for image-text matting in the image in the above embodiment can be directly referred to for implementation, and details will not be described here.
As shown in fig. 7, the present invention further includes an embodiment, which is a method for displaying a picture in an overlapping manner, and specifically includes the following steps:
step S201: and generating a target picture by the image-text matting method in the image.
The generation process of the target picture is not repeated here, and those skilled in the art can implement the method by directly referring to the foregoing embodiment.
Step S202: and superposing the target picture in the selected picture according to a preset superposition strategy to obtain a superposed picture.
In the method of this embodiment, the target picture may be superimposed in the picture or the video, which is substantially the superposition of the picture and the picture, and for the superposition method of the picture and the picture, a person skilled in the art can use the existing superposition technology to implement, and details are not described here either.
Step S203: and displaying the superposed pictures.
The present invention also includes an embodiment of a picture overlaying display device, as shown in fig. 8, including the image-text matting device 100, the picture overlaying device 200 and the display device 300 of the above embodiment, wherein: the image-text matting device 100 is connected with the image superposition device 200; the image-text matting device 100 is used for generating a target image; the picture stacking device 200 is connected with the image-text matting device 100 and the display device 300; the picture superimposing device 200 is configured to superimpose the target picture in the selected picture according to a preset superimposing strategy to obtain a superimposed picture; a display device 300 connected with the picture superimposing apparatus 200; the display device 300 is used for displaying the overlay picture. The device of this embodiment implements the image superimposition by the above image superimposition display method, and the specific process is not described in detail, and the image-text matting device 100 in this embodiment can be implemented by referring to the foregoing embodiment, which is not described in detail herein.
As shown in fig. 9, for the effect displayed by the target picture superimposed in the selected picture, window 1 is the image size of the selected picture, and window 2 is the size of the target picture. The target picture generated by the method has transparency, so that the anti-aliasing capability is improved, the attractiveness of the content displayed by the picture is not affected when the target picture is superposed on the picture, and the display effect is very good.
The present invention has been further described with reference to specific embodiments, but it should be understood that the detailed description should not be construed as limiting the spirit and scope of the present invention, and various modifications made to the above-described embodiments by those of ordinary skill in the art after reading this specification are within the scope of the present invention.

Claims (10)

1. A method for picking pictures and texts in an image is characterized by comprising the following steps:
drawing a first picture of three channels according to a preset first picture drawing strategy;
drawing a third picture of the three channels according to a preset second picture drawing strategy;
drawing a third picture of the four channels according to a preset third picture drawing strategy;
the pixel points of the first picture, the second picture and the third picture are in one-to-one correspondence, and each pixel point of the third picture is reset to generate a target picture;
wherein resetting each pixel point of the third picture comprises:
for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point of the third picture are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point of the third picture are respectively RedB, GreenB and BlueB;
normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the R channel value and the G channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB';
updating the alphaC ' values of all pixel points of the third picture, wherein the alphaC ' = RedA ';
updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 728283DEST_PATH_IMAGE001
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with alpha ' 1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB ';
and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
2. The method of in-image matting according to claim 1, wherein the first picture drawing strategy is: generating a first black background according to a preset picture resolution, generating a first picture and text according to a preset first picture and text generation strategy, and combining the first black background and the first picture and text according to a preset combination strategy.
3. The method of in-image matting according to claim 2, wherein the second picture drawing strategy is: and generating a second black background according to the preset image resolution, generating a second image-text according to a preset second image-text generation strategy, and combining the second black background and the second image-text according to the preset combination strategy.
4. The method of in-image matting according to claim 3, wherein the first teletext generation strategy is: generating white pictures and texts by using preset characters and preset patterns; the second image-text generation strategy is as follows: and generating the color image-text by combining the preset characters and the preset patterns with the preselected colors.
5. The method of in-image matting according to claim 4, wherein the third picture drawing strategy is: and generating a fully transparent picture according to the preset picture resolution.
6. The method of in-image matting according to claim 5, wherein the combination strategy is: and superposing the image on the background according to a preset position relation.
7. The method for image-text matting according to claim 1, wherein the inverse normalization and integer extraction of the channel values of all the pixel points of the third picture comprises: and (4) rounding the denormalized channel value.
8. The utility model provides a device is scratched to picture and text in image, its characterized in that, the device is scratched to picture and text includes that first picture draws module, second picture and draws module, third picture and draws module and third picture and set for the module, wherein:
the first picture drawing module is connected with the third picture setting module; the first picture drawing module is used for drawing a three-channel first picture according to a preset first picture drawing strategy;
the second picture drawing module is connected with the third picture setting module; the second picture drawing module is used for drawing a third picture of three channels according to a preset second picture drawing strategy;
the third picture drawing module is connected with the third picture setting module; the third picture drawing module is used for drawing a third picture of the four channels according to a preset third picture drawing strategy;
the third picture setting module is connected with the first picture drawing module, the second picture drawing module and the third picture drawing module; the third picture setting module is used for corresponding pixel points of the first picture, the second picture and the third picture one by one, resetting each pixel point of the third picture and generating a target picture; wherein, the resetting of each pixel point of the third picture by the third picture setting module comprises:
for any pixel point of the third picture, determining that an Alpha channel value, an R channel value, a G channel value and a B channel value of the pixel point of the third picture are respectively Alpha C, RedC, GreenC and BlueC, determining that the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the pixel point of the third picture are respectively RedA, GreenA and BlueA, and determining that the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the pixel point of the third picture are respectively RedB, GreenB and BlueB;
normalizing the channel values of all pixel points of the first picture, the second picture and the third picture; for any pixel point of the normalized third picture, the Alpha channel value is expressed as Alpha C ', the R channel value, the G channel value and the B channel value are respectively RedC', GreenC 'and BlueC', the R channel value, the G channel value and the B channel value of the pixel point of the first picture corresponding to the Alpha channel value, the R channel value and the G channel value are respectively RedA ', GreenA' and BlueA ', and the R channel value, the G channel value and the B channel value of the pixel point of the second picture corresponding to the G channel value and the B channel value are respectively RedB', GreenB 'and BlueB';
updating the alphaC ' values of all pixel points of the third picture, wherein the alphaC ' = RedA ';
updating the RedC ', GreenC ' and BlueC ' values of all pixel points of the third picture, including: for a pixel point with alpha 'being =0, let red c' =0, GreenC '= 0, and BlueC' = 0; for alpha C'
Figure 645424DEST_PATH_IMAGE002
(0, 1) for the pixel point, the value of RedC ' is the quotient of RedB ' and RedA ', the value of GreenC ' is the quotient of GreenB ' and GreenA ', and the value of BlueC ' is the quotient of BlueB ' and BlueA '; for a pixel point with alpha ' 1, let red c ' = RedB ', GreenC ' = GreenB ', and BlueC ' = BlueB ';
and performing inverse normalization on the channel values of all the pixel points of the third picture and taking an integer.
9. A picture superposition display method is characterized by comprising the following steps:
generating the target picture by the in-image matting method according to any one of claims 1 to 7;
superposing the target picture in the selected picture according to a preset superposition strategy to obtain a superposed picture;
and displaying the superposed picture.
10. A picture overlay display device comprising the image matting apparatus of claim 8, and a picture overlay apparatus and a display apparatus, wherein:
the image-text digging device is connected with the image superposition device; the image-text matting device is used for generating the target image;
the picture stacking device is connected with the image-text digging device and the display device; the picture superposition device is used for superposing the target picture in the selected picture according to a preset superposition strategy to obtain a superposed picture;
the display device is connected with the picture superposition device; the display device is used for displaying the superposed pictures.
CN202011243812.0A 2020-11-10 2020-11-10 Method and device for picking image-text in image Active CN112102219B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011243812.0A CN112102219B (en) 2020-11-10 2020-11-10 Method and device for picking image-text in image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011243812.0A CN112102219B (en) 2020-11-10 2020-11-10 Method and device for picking image-text in image

Publications (2)

Publication Number Publication Date
CN112102219A CN112102219A (en) 2020-12-18
CN112102219B true CN112102219B (en) 2021-02-09

Family

ID=73785052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011243812.0A Active CN112102219B (en) 2020-11-10 2020-11-10 Method and device for picking image-text in image

Country Status (1)

Country Link
CN (1) CN112102219B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109478389A (en) * 2016-07-14 2019-03-15 三星电子株式会社 The multi-layer display enhanced with color and contrast

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7728845B2 (en) * 1996-02-26 2010-06-01 Rah Color Technologies Llc Color calibration of color image rendering devices
US8081821B1 (en) * 2008-09-16 2011-12-20 Adobe Systems Incorporated Chroma keying
CN101883218B (en) * 2010-03-12 2012-05-30 浙江大学 Image acquisition and artistic processing method based on camera
US10757346B1 (en) * 2017-04-28 2020-08-25 Flixbay Technologies, Inc. Systems and methods for video extraction and insertion
CN107230182B (en) * 2017-08-03 2021-11-09 腾讯科技(深圳)有限公司 Image processing method and device and storage medium
CN108805849B (en) * 2018-05-22 2020-07-31 京东数字科技控股有限公司 Image fusion method, device, medium and electronic equipment
CN110826360A (en) * 2018-08-10 2020-02-21 南京宁融信网络科技有限公司 OCR image preprocessing and character recognition
CN111340675B (en) * 2020-02-12 2023-04-25 中南林业科技大学 Sparse representation-based color pattern watermark embedding and extracting method

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109478389A (en) * 2016-07-14 2019-03-15 三星电子株式会社 The multi-layer display enhanced with color and contrast

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Photoshop通道在图像处理中的应用;石丽怡;唐普霞;《福建电脑》;20160825;第151-152页 *
数字影像制作中抠像技术的思考与实践;杨华勇;《电脑知识与技术》;20100225;第1469-1472页 *
色度键抠像中色边问题的探讨;王峥; 王建一;《现代电影技术》;20070611;第38-41页 *

Also Published As

Publication number Publication date
CN112102219A (en) 2020-12-18

Similar Documents

Publication Publication Date Title
US5793885A (en) Computationally efficient low-artifact system for spatially filtering digital color images
CN104038807B (en) A kind of figure layer mixed method and device based on OpenGL
CN105138317B (en) Window display processing method and device for terminal device
JPH04246690A (en) Method of displaying image having high quality by normal resolution
US6262778B1 (en) Image processing system
US7664338B2 (en) Perspective transformation of two-dimensional images
US7280117B2 (en) Graphical user interface for a keyer
CN101299804A (en) Character overlapping method and device
US20010014175A1 (en) Method for rapid color keying of color video images using individual color component look-up-tables
CN104392419B (en) A kind of method that dark angle effect is added for image
US7701470B2 (en) Stable mask combination in digital image editing
CN104077792A (en) Image processing method with cartoon effect
CN112102219B (en) Method and device for picking image-text in image
CN102903091B (en) Method for stitching image in digital image processing apparatus
US20050083355A1 (en) Apparatus and method for image-processing, and display apparatus
CN110992242A (en) Method and device for eliminating water ripples of transparent picture
JP2007324665A (en) Image correction apparatus and video display apparatus
KR20020084321A (en) real-time character composition method using template
CN103024294A (en) Chroma key implementation method and device
JPH0561970A (en) Device and method for image processing
CN116703794B (en) Multi-image fusion method in HSV color space
US20060055707A1 (en) Graphical user interface for a keyer
US20240273780A1 (en) Overlaying 2D images
US7590283B2 (en) Representing colors in stored images using color tinting
TW201508693A (en) Graphics tile compositing control

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 518000 101, integrated circuit Industrial Park, 1089 chaguang Road, Xili street, Shenzhen City, Guangdong Province

Patentee after: Carlette (Shenzhen) cloud Technology Co.,Ltd.

Address before: 518000 room 3801, block a, block 8, block C, Wanke Yuncheng phase III, Liuxin 4th Street, Xili community, Xili street, Nanshan District, Shenzhen City, Guangdong Province (37-39 floors)

Patentee before: COLORLIGHT (SHENZHEN) CLOUD TECHNOLOGY Co.,Ltd.

Address after: 518000 room 3801, block a, block 8, block C, Wanke Yuncheng phase III, Liuxin 4th Street, Xili community, Xili street, Nanshan District, Shenzhen City, Guangdong Province (37-39 floors)

Patentee after: Carlette cloud Technology Co.,Ltd.

Address before: 518000 101, integrated circuit Industrial Park, 1089 chaguang Road, Xili street, Shenzhen City, Guangdong Province

Patentee before: Carlette (Shenzhen) cloud Technology Co.,Ltd.