HSV-based color automatic delimitation identification method, pipe cap classification method and system
Through the HSV-based color automatic delimiting recognition method, a color boundary division table is generated, which solves the problems of difficulty in determining color boundaries and large demand for color templates in the prior art, and achieves efficient and low-cost color recognition.
Patent Information
- Application Number
- CN202311662788.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-06
- Publication Date
- 2025-06-06
AI Technical Summary
The existing color recognition algorithm is difficult to determine color boundaries, cumbersome operations, and requires a large number of color templates, resulting in large amounts of calculations and disk usage.
The automatic delimited color recognition method based on HSV is used to set the basic color color boundary, obtain the basic color color template, calculate the tone center, calculate the tone boundary average, and generate a color boundary division table to judge the image color by pixel.
It realizes color recognition with strong scene adaptability, small calculation amount and low disk usage, reducing the cumbersomeness of manually adjusting color boundaries and the collection of a large number of color templates.
Smart Images

Figure CN120107374A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition, and in particular to an automatic color delimitation recognition method based on HSV, and a pipe cap classification method and system. Background Art
[0002] Color images are usually represented in RGB or HSV color space. RGB uses the three primary colors of red (Red, R), green (Green, G), and blue (Blue, B) to form various colors; while HSV uses hue (Hue, H), saturation (Saturation, S), and value (Value, V) to represent. The two can be converted into each other and are different ways of expressing the same object. After the color boundary range is determined in the color space, you only need to determine the interval of the pixel value to know what color it represents.
[0003] Existing color recognition algorithms can be roughly divided into two types. One is based on human experience. Its approach is to divide the color space into several color intervals through human visual perception, and then determine which interval the pixels on the test image fall into more, so as to obtain the main color of the test image. The principle of this method is relatively simple, but it is difficult to determine the color boundary, the actual operation is relatively cumbersome, and it is difficult to support scenes with diverse color categories. The other is based on color templates, such as CN115578714A "A vehicle color recognition method and system based on shallow feature information enhancement", which requires some template images to be prepared in advance and classified by color, and then the classification model is trained based on these templates. This method represents the color template as a feature vector through a series of calculations of the convolutional neural network, and then uses the vector as the input of the classification layer SVM, decision tree, neural network and other models to obtain color classification. This method requires more template images, large image acquisition workload, large calculation amount, and the template image will take up a lot of disk space. It requires more template images and large image acquisition workload. Summary of the invention
[0004] The purpose of the present invention is to provide a color automatic delimitation recognition method based on HSV, a pipe cap classification method and system, which combines the above two methods, takes advantage of their strengths and overcomes their weaknesses, and has the advantages of strong scene adaptability, small calculation amount, and small disk occupancy.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] The HSV-based color automatic delimitation and recognition method includes the following steps:
[0007] S1: Set the basic color boundary;
[0008] S2: Get a basic color template;
[0009] S3: Determine whether the color template is one of black, white, and gray. If it is one of the colors, return to step S2; if it is not one of the colors, proceed to the next step;
[0010] S4: Calculate all hue centers of the color template;
[0011] S5: averaging all the hue centers obtained in step S4 to obtain the hue boundary of the current basic color;
[0012] S6: According to the hue boundary obtained in step S5, the color boundary of the current basic color is internally divided.
[0013] S7: Determine whether all the basic color templates have been called, otherwise return to step S2, if yes, save the color boundaries of all the basic colors as a color boundary division table.
[0014] In step S1 and step S2, the basic colors are divided into 10 colors, namely black, white, gray, red, orange, yellow, green, cyan, blue, and purple, which correspond to 10 basic color templates respectively.
[0015] In step S2: when the basic color template is obtained, it is recorded as obtained, and the template is not obtained in the next round of steps.
[0016] In step S5, the average value of every two adjacent hue centers is calculated to obtain the current hue boundary.
[0017] The pipe cap classification method is characterized by comprising the following steps:
[0018] A1: Input the pipe cap image to be inspected;
[0019] A2: scaling the image to be detected;
[0020] A3: Substituting the displayed image into the color boundary division table obtained by the above-mentioned color automatic delimitation recognition method;
[0021] A4: Determine the color of the image pixel by pixel according to the color boundary division table;
[0022] A5: Count the number of times different colors appear, and take the color with the largest number of appearances as the tube cap color in the image to be detected.
[0023] In step A5, the tube cap color information includes the base color and the hue center.
[0024] A pipe cap classification system includes an image acquisition device, a processor and a memory, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0025] Compared with the prior art, the beneficial effect of the present invention is that fewer color templates are required, only basic colors are needed, and after the boundary division table of the HSV color space is generated, the color template can be deleted, and only the table needs to be stored subsequently. There is no need to manually adjust the color boundaries according to the application scenarios, and there is no need to collect a large number of color templates, which saves labor costs and disk space. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A flowchart of automatic color delimitation recognition according to an embodiment of the present invention;
[0027] Figure 2 A flow chart of a pipe cap classification method according to an embodiment of the present invention;
[0028] Figure 3 This is a tube cap color classification result according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] Example 1
[0031] like Figure 1 As shown, the HSV-based color automatic delimitation and recognition method includes the following steps:
[0032] S1: Set the basic color boundary;
[0033] S2: Get a basic color template;
[0034] S3: Determine whether the color template is one of black, white, and gray. If it is one of the colors, return to step S2; if it is not one of the colors, proceed to the next step;
[0035] S4: Calculate all hue centers of the color template;
[0036] S5: averaging all the hue centers obtained in step S4 to obtain the hue boundary of the current basic color;
[0037] S6: According to the hue boundary obtained in step S5, the color boundary of the current basic color is internally divided.
[0038] S7: Determine whether all the basic color templates have been called, otherwise return to step S2, if yes, save the color boundaries of all the basic colors as a color boundary division table.
[0039] In step S1 and step S2, the basic colors are divided into 10 colors, namely black, white, gray, red, orange, yellow, green, cyan, blue, and purple, which correspond to 10 basic color templates respectively.
[0040] In step S2: when the basic color template is obtained, it is recorded as obtained, and the template is not obtained in the next round of steps.
[0041] In step S5, the average value of every two adjacent hue centers is calculated to obtain the current hue boundary.
[0042] Example 2
[0043] The pipe cap classification method is characterized by comprising the following steps:
[0044] A1: Input the pipe cap image to be inspected;
[0045] A2: scaling the image to be detected;
[0046] A3: Substituting the displayed image into the color boundary division table obtained by the color automatic delimitation and recognition method in Example 1;
[0047] A4: Determine the color of the image pixel by pixel according to the color boundary division table;
[0048] A5: Count the number of times different colors appear, and take the color with the largest number of appearances as the tube cap color in the image to be detected.
[0049] In step A5, the tube cap color information includes the base color and the hue center.
[0050] Example 3
[0051] A pipe cap classification system includes an image acquisition device, a processor and a memory, wherein the memory stores a computer program, and the processor performs the following steps when executing the computer program:
[0052] A1: Input the pipe cap image to be inspected;
[0053] A2: scaling the image to be detected;
[0054] A3: Substituting the displayed image into the color boundary division table obtained by the color automatic delimitation and recognition method in Example 1;
[0055] A4: Determine the color of the image pixel by pixel according to the color boundary division table;
[0056] A5: Count the number of times different colors appear, and take the color with the largest number of appearances as the tube cap color in the image to be detected.
[0057] In step A5, the tube cap color information includes the base color and the hue center.
[0058] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention in the form of a ring-shaped light source. Therefore, the embodiments should be considered exemplary and non-restrictive in every sense, and the scope of the invention is defined by the appended claims rather than the above description, and it is intended that all changes within the meaning and range of equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0059] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. Automatic color delimitation and recognition method based on HSV, It is characterized in that The following steps are involved: S1: Set the basic color boundary; S2: Get a basic color template; S3: Determine whether the color template is one of black, white, and gray. If it is one of the colors, return to step S2; if it is not one of the colors, proceed to the next step; S4: Calculate all hue centers of the color template; S5: averaging all the hue centers obtained in step S4 to obtain the hue boundary of the current basic color; S6: According to the hue boundary obtained in step S5, the color boundary of the current basic color is internally divided. S7: Determine whether all the basic color templates have been called, otherwise return to step S2, if yes, save the color boundaries of all the basic colors as a color boundary division table.
2. The HSV-based color automatic delimitation and recognition method according to claim 1, It is characterized in that In step S1 and step S2, the basic colors are divided into 10 colors, namely black, white, gray, red, orange, yellow, green, cyan, blue, and purple, which correspond to 10 basic color templates respectively.
3. The HSV-based color automatic delimitation and recognition method according to claim 1, It is characterized in that In step S2: when the basic color template is obtained, it is recorded as obtained, and the template is not obtained in the next round of steps.
4. The HSV-based color automatic delimitation and recognition method according to claim 1, It is characterized in that In step S5, the average value of every two adjacent hue centers is calculated to obtain the current hue boundary.
5. Pipe cap classification method, It is characterized in that The following steps are involved: A1: Input the pipe cap image to be inspected; A2: scaling the image to be detected; A3: Substituting the displayed image into the color boundary division table obtained in the color automatic delimitation and recognition method of claims 1 to 4; A4: Determine the color of the image pixel by pixel according to the color boundary division table; A5: Count the number of times different colors appear, and take the color with the largest number of appearances as the tube cap color in the image to be detected.
6. The pipe cap classification method according to claim 6, It is characterized in that In step A5, the tube cap color information includes the base color and the hue center.
7. A tube cap classification system, including an image acquisition device, a processor and a memory, It is characterized in that The memory stores a computer program, and when the processor executes the computer program, the steps of the method according to any one of claims 5 to 6 are implemented.
Citation Information
Patent Citations
Vehicle color identification method and system based on shallow feature information enhancement
CN115578714A