A method for sorting RGB color block ratios in images

The RGB color component ratio is determined through user text, combined with the feature thesaurus and emotional thesaurus, the RGB color component ratio of the picture is calculated, which solves the problem of complex color correction in large-scale images generated by large-scale models, and achieves efficient and accurate color correction effects.

CN118484552BActive Publication Date: 2024-11-01北京科杰科技有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410653578.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-11-01
Estimated Expiration
2044-05-24

AI Technical Summary

Technical Problem

In the prior art, the color correction of pictures generated by large models is complex and inaccurate, and there is a problem of long training cycles.

Method used

Provide a method for sorting the proportion of RGB color blocks for image RGB. By collecting the text input by the user, extracting keywords, and comparing them based on the feature lexicon and emotional lexicon, determining the color lexicon and its weight, using the mean method and statistical strategy Calculate the RGB color component ratio, evaluate the color deviation, determine whether the picture meets the preset standards, and optimize keyword collection and thesaurus if it does not meet.

Benefits of technology

It realizes the close connection between user text and images, efficiently counts pixel color, simplifies the color correction process, and improves the accuracy and efficiency of correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118484552B_ABST
    Figure CN118484552B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence, and in particular to a method for sorting the proportion of RGB color blocks of an image, comprising: collecting text input by a user; extracting keywords after dividing the text; obtaining feature keywords and emotional keywords after comparing the extracted keywords in a feature word library and an emotional word library respectively; determining color words corresponding to each feature keyword and emotional keyword based on a color word list; determining the proportion of RGB color components of the text by adopting a mean value method; screening corresponding images from a picture library based on the feature keywords; completing the calculation of the proportion of RGB color components of the image after determining a statistical strategy for the proportion of RGB color components of the image based on the number of megabytes of the image; determining a color deviation evaluation value, and judging whether the screening of the image meets a preset standard according to the color deviation evaluation value, thereby optimizing the generation and color rendering of large model images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a method for sorting RGB color block ratios of images. Background Art

[0002] "Big model drawing" refers to the use of large machine learning models (such as GPT-4, DALL-E, etc.) to generate images. These models are usually trained based on a large amount of image and text data, and can generate corresponding images based on the text description entered by the user.

[0003] However, the images generated by the large model may not fully meet the needs of customers, especially there may be color deviation, which may be caused by model training data, algorithm limitations or randomness in the generation process. In the prior art, support vector regression (SVR) is used for color correction, and multivariate linear regression is used to establish a color correction model. The above models all have the problems of complex correction and long training cycle. Summary of the invention

[0004] To this end, the present invention provides a method for sorting the proportion of RGB color blocks of an image, so as to overcome the problem that the color correction of images generated by large models in the prior art is complex and inaccurate.

[0005] To achieve the above object, the present invention provides a method for sorting the proportion of RGB color blocks in an image, comprising:

[0006] Step S1, collecting text input by the user;

[0007] Step S2, dividing the collected text based on semantics and extracting keywords;

[0008] Step S3, comparing the extracted keywords in a feature word library and a sentiment word library respectively to obtain feature keywords and sentiment keywords;

[0009] Step S4, determining the color vocabulary corresponding to each feature keyword and the emotional keyword based on the color vocabulary table, wherein each color vocabulary is set with a corresponding weight coefficient;

[0010] Step S5, using the mean value method to determine the proportion of RGB color components of the text;

[0011] Step S6, filtering corresponding pictures from the picture library based on the characteristic keywords;

[0012] Step S7, after determining the statistical strategy of the RGB color component ratio of the picture based on the number of megabytes of the picture, the calculation of the RGB color component ratio of the picture is completed;

[0013] Step S8, determining a color deviation evaluation value based on the image RGB color component ratio and the text RGB color component ratio, and judging whether the image screening meets the preset standard according to the color deviation evaluation value.

[0014] Further, the process of determining the statistical strategy of the proportion of RGB color components of the picture based on the number of megabytes of the picture includes:

[0015] Compare the image megabyte count with a preset megabyte count threshold;

[0016] If the image size is less than the preset megabyte threshold, the traversal strategy is used to count the proportions of the RGB color components of the image;

[0017] If the image megabytes is greater than or equal to the preset megabytes threshold, the histogram strategy is used to perform image RGB color component ratio statistics.

[0018] Furthermore, the traversal strategy includes the following steps:

[0019] Step S6101, read the picture and obtain the picture width information and height information;

[0020] Step S6102, traverse the pixels of the image and obtain the RGB value of each pixel;

[0021] Step S6103, adding the number of pixels of the three color channels of the image to obtain the total number of pixels;

[0022] Step S6104, respectively calculate the ratio of the number of pixels in each channel to the total number of pixels to complete the RGB color component ratio statistics of the image.

[0023] Furthermore, the sampling method or the scaling method is used to complete the traversal of the image pixels, where:

[0024] The sampling method is to obtain the RGB value of the corresponding pixel point every 1 pixel.

[0025] The scaling method is to obtain the RGB value of each pixel after reducing the image of the image.

[0026] Further, the histogram strategy comprises the following steps:

[0027] Step S6201, read the image and perform grayscale processing and edge enhancement processing in sequence;

[0028] Step S6202, dividing the sub-areas after performing contour area detection;

[0029] Step S6203, for a single sub-region, respectively calculate the histograms of the three color channels and then normalize the histograms;

[0030] Step S6204, merging the histograms of each sub-region to obtain a picture histogram;

[0031] Step S6205, completing RGB color component ratio statistics based on the image histogram.

[0032] Furthermore, the image is read using the Pillow library or the OpenCV library in Python.

[0033] Furthermore, the color deviation evaluation value is calculated by the following formula:

[0034]

[0035] In the formula, K is the color deviation value, R is the image RGB red ratio value, G is the image RGB green ratio value, B is the image RGB blue ratio value, R0 is the text RGB red ratio value, G0 is the text RGB green ratio value, and B0 is the text RGB blue ratio value.

[0036] Furthermore, when it is determined that the screening of images does not meet the preset standards based on the color deviation evaluation value, the screened images are re-rendered after using the text RGB color component ratio instead of the image RGB color component ratio, or the reason for not meeting the preset standards is determined based on the proportion of historical image screening that does not meet the preset standards.

[0037] Further, based on the proportion of historical images that do not meet the preset standards, the reasons for not meeting the preset standards include: image screening does not meet the standards, or keyword extraction does not meet the standards;

[0038] When the image screening fails to meet the criteria, re-screen the images in the gallery and then make a screening judgment;

[0039] When the extracted keywords do not meet the standards, the proportion of keyword collection will be increased and the feature word library and sentiment word library will be optimized;

[0040] The proportion of keyword collection is the ratio of the number of keywords extracted to the total number of words after text division.

[0041] Furthermore, the increase in the proportion of the keyword collection quantity is positively correlated with the proportion difference, and the proportion difference is the difference between the proportion and the preset proportion threshold.

[0042] Compared with the prior art, the invention has the following beneficial effects: the invention determines the text RGB color component ratio through user text, and calculates the image RGB color component ratio through the screened image. Through these two benchmarks, the user text and image screening are closely connected, and the screened image is checked by comparison to see whether it meets the preset standard, and the optimization path when it does not meet the preset standard.

[0043] Furthermore, the present invention sets a statistical strategy for the proportion of RGB color components of pictures for pictures of different sizes, thereby achieving efficient statistics of the colors of picture pixels. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 This is a flow chart of a method for sorting RGB color blocks in a picture according to an embodiment of the present invention;

[0045] Figure 2 A flowchart of a statistical strategy for determining the proportion of RGB color components of an image according to an embodiment of the present invention;

[0046] Figure 3 This is a flow chart of an embodiment of the present invention for determining whether the screening of pictures meets the preset standard according to the color deviation evaluation value;

[0047] Figure 4 This is a flowchart of an embodiment of the present invention for determining reasons for not meeting the preset standards based on the percentage of historical pictures that do not meet the preset standards. DETAILED DESCRIPTION

[0048] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0049] Those skilled in the art will appreciate that the method of the present invention for determining a single parameter mentioned above may be to select the value with the highest proportion as the preset standard parameter based on data distribution, use weighted summation to use the obtained value as the preset standard parameter, substitute each historical data into a specific formula and use the value obtained by using the formula as the preset standard parameter or other selection methods, as long as the system of the present invention can clearly define different specific situations in the single determination process through the obtained values.

[0050] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0051] See also Figures 1 to 4 , which is a flowchart of a method for sorting the proportion of RGB color blocks of an image according to an embodiment of the present invention; a flowchart of a statistical strategy for determining the proportion of RGB color components of an image according to an embodiment of the present invention; a flowchart of an embodiment of the present invention for determining whether the screening of an image meets the preset standard according to the color deviation evaluation value; a flowchart of an embodiment of the present invention for determining the reason for not meeting the preset standard based on the proportion of historical image screening that does not meet the preset standard.

[0052] The embodiment of the present invention is used for a method for sorting RGB color blocks in a picture in a proportional manner, including:

[0053] Step S1, collecting text input by the user;

[0054] Step S2, dividing the collected text based on semantics and extracting keywords;

[0055] Step S3, comparing the extracted keywords in a feature word library and a sentiment word library respectively to obtain feature keywords and sentiment keywords;

[0056] Step S4, determining the color vocabulary corresponding to each feature keyword and the emotional keyword based on the color vocabulary table, wherein each color vocabulary is set with a corresponding weight coefficient;

[0057] Step S5, using the mean value method to determine the proportion of RGB color components of the text;

[0058] Step S6, filtering corresponding pictures from the picture library based on the characteristic keywords;

[0059] Step S7, after determining the statistical strategy of the RGB color component ratio of the picture based on the number of megabytes of the picture, the calculation of the RGB color component ratio of the picture is completed;

[0060] Step S8, determining a color deviation evaluation value based on the image RGB color component ratio and the text RGB color component ratio, and judging whether the image screening meets the preset standard according to the color deviation evaluation value.

[0061] Specifically, the process of determining the statistical strategy of the proportion of RGB color components of an image based on the number of megabytes of the image includes:

[0062] Compare the image megabyte count with a preset megabyte count threshold;

[0063] If the image size is less than the preset megabyte threshold, the traversal strategy is used to count the proportions of the RGB color components of the image;

[0064] If the image megabytes is greater than or equal to the preset megabytes threshold, the histogram strategy is used to calculate the proportion of the RGB color components of the image;

[0065] Set the default megabyte threshold to 100MB.

[0066] Specifically, the traversal strategy includes the following steps:

[0067] Step S6101, read the picture and obtain the picture width information and height information;

[0068] Step S6102, traverse the pixels of the image and obtain the RGB value of each pixel;

[0069] Step S6103, adding the number of pixels of the three color channels of the image to obtain the total number of pixels;

[0070] Step S6104, respectively calculate the ratio of the number of pixels in each channel to the total number of pixels to complete the RGB color component ratio statistics of the image.

[0071] Specifically, the sampling method or the scaling method is used to complete the traversal of the image pixels, where:

[0072] The sampling method is to obtain the RGB value of the corresponding pixel point every 1 pixel.

[0073] The scaling method is to obtain the RGB value of each pixel after reducing the image of the image. Specifically, the scaling method is such that the size of the original image is W (width) × H (height), and it needs to be scaled to a new size of W' (new width) × H' (new height). The image formula is as follows:

[0074] X=W / W'

[0075] Y=H / H'

[0076] I(i,j)=I(X*i,Y*j)

[0077] Where I(i,j) is the value of pixel (i,j) in the new image, I(X*i,Y*j)) is the pixel value at the position corresponding to the new image pixel (i,j) in the original image; X is the ratio of W / W', and Y is the ratio of H / H'. X and Y are used to calculate the position of the new image pixel in the original image when scaling.

[0078] Specifically, the histogram strategy includes the following steps:

[0079] Step S6201, read the image and perform grayscale processing and edge enhancement processing in sequence;

[0080] Step S6202, dividing the sub-areas after performing contour area detection;

[0081] Step S6203, for a single sub-region, respectively calculate the histograms of the three color channels and then normalize the histograms;

[0082] Step S6204, merging the histograms of each sub-region to obtain a picture histogram;

[0083] Step S6205, completing RGB color component ratio statistics based on the image histogram.

[0084] Specifically, the image is read using the Pillow library or the OpenCV library in Python.

[0085] Specifically, the color deviation evaluation value is calculated by the following formula:

[0086]

[0087] In the formula, K is the color deviation value, R is the image RGB red ratio value, G is the image RGB green ratio value, B is the image RGB blue ratio value, R0 is the text RGB red ratio value, G0 is the text RGB green ratio value, and B0 is the text RGB blue ratio value.

[0088] Specifically, it is determined whether the image screening meets the preset standard according to the color deviation evaluation value, wherein:

[0089] If the color deviation evaluation value is less than the first preset color deviation evaluation value, it is determined that the image screening meets the preset standard, and the image is output;

[0090] If the color deviation evaluation value is greater than or equal to the first preset color deviation evaluation value and less than the second preset color deviation evaluation value, it is determined that the image screening does not meet the preset standard, and the RGB color component ratio of the text is used to replace the RGB color component ratio of the image and then the screened image is re-rendered;

[0091] If the color deviation evaluation value is greater than or equal to the second preset color deviation evaluation value, it is determined that the image screening does not meet the preset standard, and the reason for not meeting the preset standard is determined based on the proportion of historical image screening that does not meet the preset standard;

[0092] The first preset color deviation evaluation value is set to 2.25, and the second preset color deviation evaluation value is set to 8.67.

[0093] Specifically, the reasons for not meeting the preset standards are determined based on the percentage of historical images that do not meet the preset standards, among which:

[0094] When the proportion is less than the preset proportion threshold of 35%, it is determined that the reason for not meeting the preset standard is that the image screening does not meet the standard, and the image screening determination is performed after rescreening the images in the gallery;

[0095] When the proportion is greater than or equal to the preset proportion threshold, it is determined that the reason for not meeting the preset standard is that the extracted keywords do not meet the standard, and the proportion of the number of collected keywords is increased, and the feature word library and the sentiment word library are optimized;

[0096] The proportion of keyword collection is the ratio of the number of keywords extracted to the total number of words after text division.

[0097] Specifically, the increase in the proportion of the number of keyword collections is positively correlated with the proportion difference, and the proportion difference is the difference between the proportion and the preset proportion threshold. It can be understood that the larger the proportion difference, the greater the increase in the proportion of the number of keyword collections.

[0098] Example 1

[0099] Receive the text input by the user: "The New Year atmosphere is busy. Lanterns are hung all over the front and back yards, including palace lanterns and gauze lanterns. As early as the beginning of the twelfth lunar month, everyone couldn't wait to get busy, kneading dough, washing glutinous rice, and putting it in the steamer. It's time to steam the rice cakes. The streets are bustling with people, and the old man smoking a pipe can't help but sigh: "The New Year is coming. "I especially like to hear them say "Year is here". "Year" seems to have become a tangible object, and I sigh like them: "New Year". I don't know when, the huge red lantern jumped onto the tall building, shaking its fat body mischievously in the wind. As long as a store hangs a big red lantern, every family will immediately hang a red lantern, like a flame, reflecting half the sky red. There are also better-looking ones like palace lanterns and glass lanterns, lit with candles, translucent, and small children holding rabbit lanterns in their hands. The body is white, with a few cartoon characters painted on it, with eyes blinking, and four wheels under the feet, turning "gurgling" on the ground. There is also a small horse lantern, with a small horse head on the top and a horse's butt at the bottom. Light the candle, and the red lantern will emit a festive red light. The golden couplet that runs for thousands of miles has also been put on the door, "Half a Tusu is not yet raised, and the grass in front of the lamp writes peach charms" to compete with each other to see who is more talented."

[0100] After dividing the collected text based on semantics, the keywords "year", "lantern", "twelfth lunar month", "New Year", "red", "flame", "festive", "golden", "couplet", and "candle" are extracted.

[0101] The extracted keywords are compared in the feature word library {"night", "New Year", ..........} and the emotional word library {"sad", "festive" .............} to obtain the feature keyword "New Year" and the emotional keyword "festive";

[0102] Determine the color vocabulary corresponding to each feature keyword and the emotional keyword based on the color vocabulary table, wherein each color vocabulary is set with a corresponding weight coefficient;

[0103] Among them, the color vocabulary and the corresponding weight coefficients are as follows:

[0104] 'New Year': (1, 0.5, 0.2), example of New Year's color distribution, mainly red,

[0105] 'Spring Festival': (1, 0.5, 0.2), color distribution example of Spring Festival, mainly red,

[0106] 'Winter': (0.2, 0.3, 1), color distribution example for winter, mainly blue,

[0107] 'Festive': (1, 0.5, 0.2), festive color distribution example, mainly red,

[0108] 'Happy': (1, 0.5, 0.2), an example of the color distribution of happiness, mainly red,

[0109] The mean method is used to determine the proportion of the RGB color components of the text. Specifically, the mean method is the mean of the weight coefficients of each RGB color, and the proportion of the RGB color components of the text is (4.2, 2.3, 1.8);

[0110] Filter corresponding pictures from the picture library based on the characteristic keyword "Chinese New Year";

[0111] The calculation of the RGB color component ratio of the image is completed after the image RGB color component ratio statistics strategy is determined based on the number of megabytes of the image. For example, if the screened image is less than 100MB, the traversal strategy is used to perform image RGB color component ratio statistics.

[0112] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

[0113] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for sorting the proportion of RGB color blocks in an image, characterized in that: include: Step S1, collecting text input by the user; Step S2, dividing the collected text based on semantics and extracting keywords; Step S3, comparing the extracted keywords in a feature word library and a sentiment word library respectively to obtain feature keywords and sentiment keywords; Step S4, determining the color vocabulary corresponding to each feature keyword and the emotional keyword based on the color vocabulary table, wherein each color vocabulary is set with a corresponding weight coefficient; Step S5, using the mean value method to determine the proportion of RGB color components of the text; Step S6, filtering corresponding pictures from the picture library based on the characteristic keywords; Step S7, after determining the statistical strategy of the RGB color component ratio of the picture based on the number of megabytes of the picture, the calculation of the RGB color component ratio of the picture is completed; Step S8, determining a color deviation evaluation value based on the RGB color component ratio of the image and the RGB color component ratio of the text, and judging whether the screening of the image meets the preset standard according to the color deviation evaluation value; The process of determining the statistical strategy for the proportion of RGB color components of an image based on the number of megabytes of the image includes: Compare the image megabyte count with a preset megabyte count threshold; If the image size is less than the preset megabyte threshold, the traversal strategy is used to count the proportions of the RGB color components of the image; If the image megabytes is greater than or equal to the preset megabytes threshold, the histogram strategy is used to calculate the proportion of the RGB color components of the image; The traversal strategy includes the following steps: Step S6101, read the picture and obtain the picture width information and height information; Step S6102, traverse the pixels of the image and obtain the RGB value of each pixel; Step S6103, adding the number of pixels of the three color channels of the image to obtain the total number of pixels; Step S6104, respectively calculating the ratio of the number of pixels in each channel to the total number of pixels to complete the RGB color component ratio statistics of the image; The histogram strategy includes the following steps, Step S6201, read the image and perform grayscale processing and edge enhancement processing in sequence; Step S6202, dividing the sub-areas after performing contour area detection; Step S6203, for a single sub-region, respectively calculate the histograms of the three color channels and then normalize the histograms; Step S6204, merging the histograms of each sub-region to obtain a picture histogram; Step S6205, completing RGB color component ratio statistics based on the picture histogram; In step S5, the weight coefficients of the color words corresponding to the characteristic keywords and the emotional keywords are subjected to the mean method to determine the proportion of the RGB color components of the text.

2. The method for sorting RGB color blocks in a picture according to claim 1, characterized in that: Use sampling or scaling to complete the image pixel traversal, where: The sampling method is to obtain the RGB value of the corresponding pixel point every 1 pixel. The scaling method is to obtain the RGB value of each pixel after reducing the image of the image.

3. The method for sorting RGB color blocks in a picture according to claim 1, characterized in that: Use the Pillow library or OpenCV library in Python to read the image.

4. The method for sorting RGB color blocks in a picture according to claim 1, characterized in that: The color deviation evaluation value is calculated by the following formula: , In the formula, K is the color deviation value, R is the image RGB red ratio value, G is the image RGB green ratio value, B is the image RGB blue ratio value, R0 is the text RGB red ratio value, G0 is the text RGB green ratio value, and B0 is the text RGB blue ratio value.

5. The method for sorting the proportion of RGB color blocks in an image according to claim 4, characterized in that: When it is determined that the screening of images does not meet the preset standards according to the color deviation evaluation value, the screened images are re-rendered after using the text RGB color component ratio instead of the image RGB color component ratio, or the reason for not meeting the preset standards is determined based on the proportion of historical image screening that does not meet the preset standards.

6. The method for sorting RGB color blocks in a picture according to claim 5, characterized in that: Based on the percentage of historical images that do not meet the preset standards, the reasons for not meeting the preset standards include: image screening does not meet the standards, or keyword extraction does not meet the standards; When the image screening fails to meet the criteria, re-screen the images in the gallery and then make a screening judgment; When the extracted keywords do not meet the standards, the proportion of keyword collection will be increased and the feature word library and sentiment word library will be optimized; The proportion of keyword collection is the ratio of the number of keywords extracted to the total number of words after text division.

7. The method for sorting RGB color blocks in a picture according to claim 6, characterized in that: The increase in the proportion of the keyword collection quantity is positively correlated with the proportion difference, and the proportion difference is the difference between the proportion and a preset proportion threshold.

Citation Information

Patent Citations

  • Image color matching method, device and equipment

    CN114332301A

  • Text and graph generation method and device, equipment and storage medium

    CN117745882A

  • Apparatus and Method of Automatic Text Design based on Emotion

    KR101611895B1

  • Image processing method, image processing apparatus, image forming apparatus, image reading apparatus, and recording medium

    US20090034005A1

  • Image colour identification method and device, terminal and storage medium

    WO2016123977A1