CN111950654B - Magic cube color block color reduction method based on SVM classification - Google Patents

Magic cube color block color reduction method based on SVM classification Download PDF

Info

Publication number
CN111950654B
CN111950654B CN202010860737.6A CN202010860737A CN111950654B CN 111950654 B CN111950654 B CN 111950654B CN 202010860737 A CN202010860737 A CN 202010860737A CN 111950654 B CN111950654 B CN 111950654B
Authority
CN
China
Prior art keywords
color
magic cube
edge
block
white
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
CN202010860737.6A
Other languages
Chinese (zh)
Other versions
CN111950654A (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.)
Guilin University of Electronic Technology
Original Assignee
Guilin University of Electronic Technology
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 Guilin University of Electronic Technology filed Critical Guilin University of Electronic Technology
Priority to CN202010860737.6A priority Critical patent/CN111950654B/en
Publication of CN111950654A publication Critical patent/CN111950654A/en
Application granted granted Critical
Publication of CN111950654B publication Critical patent/CN111950654B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2411Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration using local operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • 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
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour
    • 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/20081Training; Learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Multimedia (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)
  • Color Image Communication Systems (AREA)

Abstract

The invention discloses a magic cube color block color reduction method based on SVM classification, which is characterized by comprising the following steps of: 1) collecting magic cube color block information; 2) preprocessing an image; 3) image color gamut space conversion; 4) identifying magic cube color blocks by a one-to-many classification method; 5) and (5) finishing the accurate identification of each color block of the magic cube by color repairing of the magic cube. The method can improve the accuracy and speed of color identification.

Description

Magic cube color block color reduction method based on SVM classification
Technical Field
The invention relates to an image processing technology, in particular to a magic cube color lump color reduction method based on SVM classification.
Background
The existing magic cube is low in color recognition efficiency, inaccurate in recognition and prone to errors, color difference exists in color processing of a camera, color changes of different degrees can occur in the process from collection to display under different color temperatures, images can be interfered by surrounding noise, light environment and the like in the process of collection and digital conversion, subsequent calculation can be sensitive and wrong, and the success rate of color recognition can be reduced due to changes of illumination environment and color difference.
Many errors of magic cube color block color identification are unavoidable due to the influence of ambient light, and errors of the type are hidden and are not easy to perceive, but in actual life, the errors in magic cube color block color reading caused by the environmental influence are very fatal, and at this time, if the errors are not regulated by a program or processed through data operation, errors can be caused in each magic cube color block reading under different environments. At present, the color of the magic cube color block is mainly identified as follows: 1. threshold definition identifies: the relatively common method is to adopt a fixed RGB or HSV threshold value, namely, the color of each color block is limited to the color value of one area, the algorithm is simple, but the influence on the illumination and the equipment environment can not be eliminated basically, and the algorithm is easy to appear in the situation that the normal identification can be carried out in a place with sufficient illumination, and the identification cannot be carried out in a dark place at all; 2. machine learning identification: by collecting the colors of magic cube color blocks in different environments and then using a large number of samples to 'predict' the currently recognized color, the scheme well eliminates the influence of the environment, but has the defect that the algorithm is difficult to remove shadows, colors and orange, so that only black magic cube blocks are adopted to replace orange magic cube blocks, and the color misrecognition is avoided.
Disclosure of Invention
The invention aims to provide a magic cube color lump color reduction method based on SVM classification aiming at the defects of the prior art. The method can improve the accuracy and speed of color identification.
The technical scheme for realizing the purpose of the invention is as follows:
a magic cube color block color reduction method based on SVM classification comprises the following steps:
1) collecting magic cube color block information: acquiring images of six surfaces of the magic cube color block by using acquisition equipment;
2) image preprocessing: eliminating noise and illumination interference on the magic cube color block image in the digitization process by adopting Gaussian filtering processing and white balance processing;
3) image gamut space conversion: each pixel point in the digital image of the magic cube color block acquired by the acquisition equipment is a value of an RGB color space, RGB is a color model commonly used in a hardware direction, from the viewpoint of color generation, the RGB space can apply three basic colors to describe all colors, a three-dimensional model can be used for geometrically representing an image in the color space, the color of the same magic cube color block has different R, G and B values under different brightness, and a correct reference threshold value is difficult to set according to the color of the tone of the image, the color gamut conversion removal acquisition equipment acquires the relationship between a brightness component and color information in the magic cube color block image, HSV color is described by changing the color space of the RGB image, because the HSV color space model is more suitable for identifying the color block color of the magic cube than the RGB color space model under the influence of different illumination, and can better reflect the saturation and brightness of the image, preparing for the next further processing, wherein different color spaces have different color information under different illumination environments, converting HSV color spaces through RGB to ensure that the captured color information is not defective, wherein the HSV color space model is more suitable for identifying the color block color of the magic cube, the saturation and the brightness of an image can be better reflected, converting the color blocks of the magic cube into RGB-HSV color gamut space, dividing each surface of each color block of the magic cube into nine areas with the size of 50 pixels by 50 pixels, acquiring the RGBW six values of each area, and obtaining the data of the color gamut space of the whole magic cube: 6, 9, 50 and 135000 data, firstly setting six colors of a magic cube color block as labels, then adopting SVM classification training, storing the acquired data of the RGBWV color gamut space corresponding to the set labels, and generating an XML training file;
4) identifying magic cube color blocks by a one-to-many classification method: carrying out magic cube color block recognition on the image preprocessed in the step 2) by adopting a one-to-many classification method according to the XML training file generated in the step 3), predicting the color of each magic cube color block by SVM classification, wherein the one-to-many classification method, namely one against all, is to reclassify samples in the training process, construct six vector machines of six classes, if an unknown sample is encountered in the classification process, the unknown sample is classified into the class with the maximum classification value in the training function, when there are six magic cube color categories, training the training sets separately to obtain six different training result files, testing each component after each training file, each test having a result, and finally comparing the maximum value of the six results to obtain which magic cube color the tested component belongs to;
5) magic cube color repairing: the magic cube is usually a six-sided cube structure, each face of the magic cube has nine color blocks, there are fifty-four color blocks in total, the central one is a middle block, the adjacent four are called edge blocks, the corner blocks occupy the corners, there is an axis up, down, left, right, forward and backward in the middle of the magic cube, from the perspective of the magic cube structure, the whole magic cube is composed of twenty-six blocks, only one color six central blocks is in the middle of each face, eight corner blocks with three colors are in the edge angle of the magic cube and two color twelve edge blocks are between the corner blocks and the central block, the magic cube is composed of fifty-four color block colors through mathematical arrangement and combination, the color block color predicted in step 4), the cube structure of the magic cube and the current international standard coloring principle are combined to make central block judgment, And (4) judging corner blocks and edge blocks, checking and repairing color blocks which cannot be identified and color blocks with wrong identification, and finishing accurate identification of each color block of the magic cube.
The Gaussian filtering treatment in the step 2) comprises the following steps: scanning each pixel in the magic cube color lump image by using a template, and replacing the value of the central pixel point of the template by using the weighted average gray value of the pixels in the neighborhood determined by the template, wherein the weight distribution is that each coefficient of a Gaussian kernel is multiplied by the sum of all coefficients, and the Gaussian filter kernel is shown in the following table 1:
TABLE 1 Gaussian Filter Kernel
Figure GDA0003648808250000021
Figure GDA0003648808250000031
The parameter formula of the gaussian filtered kernel is:
Figure GDA0003648808250000032
g (x, y) is a Gaussian template calculated by a Gaussian function, sampling is carried out by taking the central position of the template as a coordinate origin, X, y is a coordinate axis of each position, sigma is called the width of a Gaussian filter for determining the smoothing degree, the larger sigma is, the wider the frequency band of the Gaussian filter is, the better the smoothing degree is, when the image is smoothed, the influence degree of surrounding pixels on the current pixel is actually adjusted by adjusting sigma, the influence degree of remote pixels on the central pixel is improved by increasing sigma, the smoother the filtering result is, the larger the standard deviation sigma is, the closer to the average value filtering is, the more obvious the filtering effect on the magic cube color block image is, but some edge information of the magic cube color block image is lost, the weight of the center is set to be the highest by the Gaussian filter, the weight of the environment is relatively lower, not only the damage condition of the edge points of the magic cube image is considered, but the strength of the center is not lost in the filtering process of the magic cube color block image, the filter is suitable for edge processing of the whole magic cube color block image, after the magic cube color block image is acquired by acquisition equipment, because the magic cube color block image can be interfered by surrounding noise and light environment during the acquisition process and the digital conversion, the subsequent calculation can be sensitive and error, the filtering needs to be carried out firstly, the pixel intensity of the magic cube color block image boundary can be lost while the noise is removed in the program digitization process, and therefore, the Gaussian filtering is adopted to carry out weighted average processing on the value of each pixel point between the noise reduction and the edge intensity reservation.
The white balance treatment in the step 2) is as follows: the color correction of the magic cube color block, the white balance processing process processes the darker and lighter colors of the magic cube color block, and a specific pixel value is designated, the color affected by the ambient light is corrected into the primary color, the white balance processing ensures that the color of the magic cube color block image is consistent with the actual color of the object under different illumination conditions, the problems of color recovery and hue processing are solved, the white balance is an index for describing the white precision after the three primary colors of red, green and blue are mixed, the color processing of the USB camera of the acquisition equipment has color difference, under different color temperatures, the magic cube color block images have different degrees of color changes in the process from collection to display, thus having great influence on the capture of the magic cube color blocks, therefore, the color of the magic cube color block needs to be corrected, the effect of eliminating illumination is very good under the condition of different color temperatures, and correct color conversion can be obtained finally.
The SVM classification in the step 3) is as follows: the SVM algorithm is a classifier formally defined as super-other classes, which can separate different classes among samples, namely, for training and testing a plurality of classes, the SVM algorithm can generate the optimal separation level, the two-dimensional point type can be linearly divided and the optimal separation line can be found, in the two classes of image cutting graphs, there are two classes of square and circle, there are countless lines which can cut samples, but the line which is too close to the sample is not suitable because the line is very sensitive to noise and has low generalization, so the aim is to find a correct division line which is farthest from all the two-dimensional points, find a super-horizontal plane which can divide various points and maximize the value, in the vector support technology, the line which finds the best effect is called as the division super-plane, the maximum distance level is defined as an interval, that is, the distance from the nearest sample point to the hyperplane is the maximum, so that the training data range is maximized, and the hyperplane expression is f (x) beta0Tx, beta are called weight vectors, beta0Called bias, the optimal hyperplane can be expressed in an infinite number of ways, namely by arbitrarily scaling beta and beta0The optimal hyperplane is expressed in the following way: beta | (B)0Tx | ═ 1, where x denotes those points closest to the hyperplane, which are called support vectors, and which are also called hyperplanes, from which the points x to the hyperplane (β, β) are known from the knowledge of geometry0) The distance of (a) is:
Figure GDA0003648808250000041
for the hyperplane, the numerator in the expression is 1, so the distance of the support vector to the hyperplane is:
Figure GDA0003648808250000042
the interval margin is denoted M, which takes a value 2 times the closest distance:
Figure GDA0003648808250000043
maximizing M translates to minimizing the function L (β) under additional constraints that imply the hyperplane to fit all training samples xiConditions for correct classification:
Figure GDA0003648808250000044
in the formula yiRepresenting the class mark of the sample, and obtaining the weight vector beta and the bias beta of the optimal hyperplane by the Lagrange multiplier method0The optimal 'interval' cutting graph determines a dotted line by two kinds of points closest to a central solid line, an area formed by the two dotted lines is an 'interval', the 'interval' needs to be as large as possible, when a hyperplane is obtained through an algorithm, as long as the distance from the closest point of one kind to the hyperplane is equal to the distance from the closest point of the other kind to the hyperplane, and when the hyperplanes of two sides are parallel, the hyperplane reaches the maximum value, the obtained maximum interval is also the maximum interval, the SVM is a common algorithm in machine learning, in a color recognition scheme, compared with the method of dividing colors by using a threshold value limit of a certain color gamut space, the prediction is more accurate and efficient after the colors are classified by using an SVM scheme, the algorithm is an algorithm for classifying sample data and regressing and analyzing training data, and using the color space categories of six colors of a magic cube color block as training data, firstly, a complete classifier is built, then a classification model is built, the training data are distributed to different labels, the classification model becomes a non-probabilistic Meta linear regression, the maximum interval is divided into two classes, all the data points are mapped into the corresponding classes, the classes are predicted according to the side of the interval of the data in a hyperplane, and on the premise of identifying the color block color of the magic cube by using an SVM algorithm, some color blocks which cannot be identified or have errors are still existed due to the change of factors such as environment, light, shadow and the like,in order to solve the problem, color is supplemented according to the structural distribution, the spatial position and the color characteristic distribution rule of the magic cube, the magic cube is supplemented under the condition that at most one surface is lost, the accuracy of color identification is improved, the identification result is easily influenced by the change of the illumination environment by adopting a traditional RGB or HSV threshold limiting method, the robustness is poor, and the reason that red and orange can not be distinguished by using the traditional color identification is also used in a team for reducing the magic cube in MIT 0.38s, so that a black magic cube block is used for replacing an orange magic cube block, the mistaken identification of the color is avoided, the color block color of the magic cube is classified and identified by adopting an SVM classification training method, the influence of illumination intensity on the color identification is eliminated, the color identification of the magic cube is basically free of errors, and the working stability of the whole system is improved.
The central block judgment in the step 5) is as follows: the state of each magic cube can obtain a unique development figure corresponding to six surfaces of the magic cube, the planar development figures of the original state or the restored state of the magic cube, namely, the numbering from the U surface is represented by numbers 1, 2 and 3 …, the numbers from the last 1 to 48 represent a complete magic cube, the central block is relatively fixed according to the current international standard coloring principle, the relative positions of 6 central block blocks can never be changed, the central block judges that the colors of all color blocks of the magic cube are stored by an array, and the colors of the central block are forcibly changed, namely [4] ═ white, [13] ═ red, [22] ═ green, [31] ═ yellow, [40] ═ orange and [49] ═ blue.
The corner block judgment in the step 5) is as follows: because the corner block of each magic cube is a first-order magic cube body in fact, the color of each corner block is completely the same as the original color matching of the magic cube, which is the basis for deducing the corner block, the color of the third surface of the corner block can be deduced by knowing the colors of two sides of the corner block, however, the missing color can not be deduced when the corner block lacks more than two colors, and the rule of the magic cube corner block is as follows: (1) relative red and orange; (2) blue and green are opposite; (3) relative yellow and white; (4) yellow at the top and white at the bottom; (5) the colors are ordered counterclockwise, namely red, green, orange and blue, and the eight corner blocks are respectively: white orange blue (0,36,47), white red blue (2,11,45), white green orange (6,18,38), white red green (8,9,20), green yellow orange (24,27,44), green red yellow (15,26,29), yellow orange blue (33,42,53), red yellow blue (17,35,51), the color of the magic cube corner block will not change due to rotation, so long as two colors of the corner block are captured, the rule of "upper yellow lower white, red green orange blue" can infer missing color, the process is:
5-1) six URFDLB surfaces of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively;
5-2) the array positions corresponding to the eight corner blocks are respectively as follows:
(0,36,47)-WGR、(2,11,45)-WGO、(6,18,38)-WBR、(8,9,20)-WBO、
(24,27,44)-YGR、(15,26,29)-YGO、(33,42,53)-YBR、(17,35,51)-YBO;
5-3) setting four arrays, wherein three arrays store 24 positions of the corner block, and a corner array judges which corner block position has an error:
corner[8]={0};
A[8]={0,2,6,8,24,15,33,17};
B[8]={36,11,18,9,27,26,42,35};
C[8]={47,45,38,20,44,29,53,51};
5-4) according to the regulation of a corner block algorithm, only two large classes of W white and Y yellow are provided, each large class is provided with two middle classes of G green and blue, each middle class is provided with two small classes of R red and O orange, and then 8 times of array position polling is adopted to detect whether three groups of colors of the corner block in the position are correct or not;
5-5) the large class of W white appears randomly at twelve positions 0, 2, 6, 8,9, 11, 18, 20, 36, 38, 45, 47, so the polling first determines whether there is a large class of W white in the positions, if the large class is white, there are two cases of G green and B blue in the medium class, then determines whether the medium class is G green, if the medium class is G green, there are two cases of WGR and WGO, if the small class is R red, it is determined (0,36,47) that the three colors WGR identification of the corner block at this position is successful, the flag bit array corr [0] is set to 1, if the small class is O orange, it is determined (2,11,45) that the three colors WGO identification of the corner block at this position is successful, the flag bit array corr [1] is set to 1, if the medium class is not G green but B blue, there are two cases WBR and WBO, and if the small class is R red, it is determined (6,18,38) the identification of the three colors WBR of the corner block at the position is successful, the flag bit array corner [2] is set to be 1, if the subclass is O orange, the identification of the three colors WBO of the corner block at the position is judged (8,9,20) to be successful, and the flag bit array corner [3] is set to be 1;
5-6) judging next that the major class Y yellow appears randomly at twelve positions of 15, 17, 24, 26, 27, 29, 33, 35, 42, 44, 51, 53, two cases of middle class G green and B blue exist in the major class Y yellow, judging next whether the middle class is G green, two cases of YGR and YGO exist if the middle class is G green, judging that the identification of the three colors YGR of the corner block at the position (24,27,44) is successful if the minor class is R red, setting 1 to a flag bit array corner [4], judging that the identification of the three colors YGO of the corner block at the position (15,26,29) is successful if the minor class is O orange, setting 1 to a flag bit array corner [5], judging that the identification of the three colors WBR of the corner block at the position (33,42,53) is successful if the minor class is R red, setting 1 to a flag bit array corner block WBR and YBO, setting a flag bit array corner [6] to be 1, judging (17,35,51) that the identification of the angle block with three colors YBO at the position is successful if the subclass is O orange, and setting a flag bit array corner [7] to be 1;
5-7) the corner block algorithm determines which corner block position is identified incorrectly according to the flag bit in the array corner, and then repairs the missing color at the position, for example, corner [0] is equal to 0, the algorithm checks three colors in the (0,36,47) positions, only three colors of W red, G green, and R red may exist in the (0,36,47), if only W red and G green appear, it can be known that the identified colour is R red, and then the other color is forcibly changed to red.
The process for judging the edge block in the step 5) comprises the following steps: the magic cube is provided with 12 prism blocks which are respectively white blue (1,46), white orange (3,37), white red (5,10), white green (7,19), yellow green (28,25), yellow orange (30,43), yellow red (32,16), yellow blue (34,52), red green (12,23), red blue (14,48), blue orange (50,39) and green orange (21,41), the judgment of the prism blocks is similar to that of the corner blocks, but the prism blocks cannot directly deduce the color of the other side from one color, because four prism blocks of the same color can appear on different sides, the deduction of the prism blocks needs to know the prism blocks of the other three sides to check whether color block information is accurate:
a: six faces of URFDLB of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively;
and b, the array positions corresponding to the twelve corner blocks are respectively as follows:
(1,46)-WG、(3,37)-WR、(5,10)-WB、(7,19)-WO
(28,25)-YG、(30,43)-YR、(32,16)-YB、(34,52)-YO
(12,23)-GR、(14,48)-GO、(50,39)-BR、(21,41)-BO;
c: set for three array, wherein 24 positions of two array storage arriss piece, it is wrong that an edge array judges which arris piece position:
A[12]={1,3,5,7,28,30,32,34,12,14,50,21};
B[12]={46,37,10,19,25,43,16,52,23,48,39,41};
edge[12]={0};
d: defining four broad classes of W white, Y yellow, G green and B blue, wherein the other three colors exist in the broad classes of W white and Y yellow, and the R red and O orange exist in the broad classes of G green and B blue, and detecting the prism blocks in the positions by adopting the positions of 12 polling arrays;
e: firstly, judging a large class of W white, wherein the W white can randomly appear at eight positions of 1, 3, 5, 7, 10, 19, 37 and 46, then identifying G green, successfully identifying the position of (1,46), identifying R red, successfully identifying the position of (3,37), identifying edge 1, identifying B blue, successfully identifying the position of (5,10), identifying edge 2, successfully identifying (7,19) and identifying orange, and finally, identifying edge 3;
f: then, judging that the major color is Y white, Y yellow appears at eight positions of 16, 25, 28, 30, 32, 34, 43 and 52 randomly, if G green is recognized, the position recognition of (28,25) is successful, the flag bit edge [4] is set to be 1, if R red is recognized, the position recognition of (30,43) is successful, the flag bit edge [5] is set to be 1, if B blue is recognized, the position recognition of (32,16) is successful, the flag bit edge [6] is set to be 1, if O orange is recognized, the position recognition of (34,52) is successful, and the flag bit edge [7] is set to be 1;
g: then continuing to judge the major G green, wherein the G green randomly appears at four positions of 12, 14, 23 and 48, and then recognizing R red, successfully recognizing the positions of (12 and 23), setting the flag edge [8] to 1, recognizing O orange, successfully recognizing the positions of (14 and 48), and setting the flag edge [9] to 1;
h: finally, judging that B blue of the major class randomly appears at four positions 21, 39, 41 and 50, and then if R red is identified, (50,39) position identification is successful, and if an edge [10] is set to be 1, if O orange is identified, (21,41) position identification is successful, and if an edge [11] is set to be 1;
i: according to the flag bit in the array edge, which prism position is wrong to identify is judged, and one color is wrong to identify in the white major category, and the color can be reduced only by checking the flag bits of edge [0], edge [1], edge [2] and edge [3 ]:
i-1) when edge [0] is 0, edge [1] is 1, edge [2] is 1, edge [3] is 1, then G green is known to be missing;
i-2) when edge [0] is 1, edge [1] is 0, edge [2] is 1, edge [3] is 1, then R red is known to be missing;
i-3) when edge [0] is 1, edge [1] is 1, edge [2] is 0, edge [3] is 1, then B blue is known to be missing;
i-4) when edge [0] is 1, edge [1] is 1, edge [2] is 1, and edge [3] is 0, then O-orange is known to be missing.
According to the technical scheme, firstly, OpenCV is adopted to carry out Gaussian filtering to process the edge of an image, the image is processed through RGVHSV color gamut conversion, an SVM classifier algorithm is adopted, a class model of six colors of the magic cube is established to improve the capturing accuracy of the colors of the magic cube, meanwhile, corner, edge and center block repairing is proposed according to the overall structure of the magic cube, the SVM class model and the color repairing algorithm are combined, and color values and magic cube color block repairing verification are judged according to the classifier, so that the color of each color block of the magic cube is obtained.
The method can improve the accuracy and speed of color identification.
Drawings
FIG. 1a is a color block image after Gaussian filtering processing in the embodiment;
FIG. 1b is a block image before Gaussian filtering processing in the embodiment;
FIG. 2a is a block image before white balance processing in the embodiment;
FIG. 2b is a block image after white balance processing in the embodiment;
FIG. 3 is a schematic diagram of the magic cube of the embodiment;
FIG. 4 is a schematic diagram illustrating an exemplary magic cube coloring classification;
FIG. 5 is a schematic flow chart of a corner block determination method in an embodiment;
FIG. 6 is a schematic diagram of magic cube color lump color reduction of SVM classification in an embodiment;
FIG. 7 is a diagram illustrating an SVM training process in accordance with an embodiment;
FIG. 8 is a schematic diagram illustrating two types of image cutting diagrams in the embodiment;
FIG. 9 is a schematic diagram of an optimal "interval" cutting pattern in the example;
FIG. 10 is a schematic flow chart of the method in the example;
FIG. 11 is a diagram of sample data generation for the non-equilibrium of parties 9986:14 in the example embodiment;
FIG. 12 is a sample random extraction graph in accordance with an embodiment;
FIG. 13 is a diagram illustrating data specifications of an optimization result of a grid search optimization penalty coefficient c in an embodiment;
FIG. 14 is a diagram of data specification (3D) of the optimization result of the parameter coefficient g of the SVM kernel in the embodiment of grid search optimization;
FIG. 15 is a test chart of the color reduction algorithm in the example.
Detailed Description
The present invention will be further described with reference to the following drawings and examples, but the present invention is not limited thereto.
Example (b):
referring to fig. 10, a magic cube color lump color reduction method based on SVM classification includes the following steps:
1) collecting magic cube color block information: acquiring images of six surfaces of the magic cube color block by using an acquisition device, namely a USB camera;
2) image preprocessing: eliminating noise and illumination interference on the magic cube color block image in the digitization process by adopting Gaussian filtering processing and white balance processing;
3) image gamut space conversion: each pixel point in the magic cube color block digital image shot by the USB camera is a value of an RGB color space, the RGB is a color model commonly used in a hardware direction, from the viewpoint of color generation, the RGB space can use three basic colors to describe all colors, a three-dimensional model can be used for geometrically representing an image in the color space, the color of the same magic cube color block has different R, G and B values under different brightness, and a correct reference threshold value is difficult to set according to the color of the tone of the image, so the color gamut conversion removal acquisition device of the embodiment reads the relationship between the brightness component and the color information in the magic cube color block image by the USB camera, and describes HSV color by changing the color space of the RGB image, because the HSV color space model is more suitable for identifying the color block color of the magic cube than the color space model under the influence of different illumination, the saturation and brightness of the image can be better reflected, preparation is made for the next further processing, the magic cube is in the environment with different illumination, different color spaces have different color information, HSV color spaces are converted through RGB, the captured color information cannot be damaged, HSV color space models are more suitable for identifying the color block color of the magic cube, the saturation and brightness of the image can be better reflected, the magic cube color blocks are subjected to RGB-HSV color gamut space conversion, each surface of each magic cube color block is divided into nine areas with the size of 50 pixels, six RGBWV values of each area are obtained, and the data of the color gamut space of the whole magic cube color block is as follows: 6, 9, 50 and 135000 data, firstly setting six colors of a magic cube color block as tags, then adopting SVM classification training to store the acquired data of the RGBWV color gamut space corresponding to the set tags to generate an XML training file, collecting 200 groups of tags in the example, training a model through an SVM algorithm to obtain an XML file, storing the XML file in a project directory, and then calling the model to recognize the colors;
4) identifying magic cube color blocks by a one-to-many classification method: carrying out magic cube color block recognition on the image preprocessed in the step 2) by adopting a one-to-many classification method according to the XML training file generated in the step 3), predicting the color of each magic cube color block by SVM classification, wherein the one-to-many classification method, namely one against all, is to reclassify samples in the training process, construct six vector machines of six classes, if an unknown sample is encountered in the classification process, the unknown sample is classified into the class with the maximum classification value in the training function, when there are six magic cube color categories, training the training sets separately to obtain six different training result files, testing each component after each training file, each test having a result, and finally comparing the maximum value of the six results to obtain which magic cube color the tested component belongs to;
5) magic cube color repairing: the magic cube is usually a six-sided cube structure, each face of the magic cube has nine color blocks, there are fifty-four color blocks in total, the central one is a middle block, the adjacent four are called edge blocks, the corner blocks occupy the corners, there is an axis up, down, left, right, forward and backward in the middle of the magic cube, from the perspective of the magic cube structure, the whole magic cube is composed of twenty-six blocks, only one color six central blocks is in the middle of each face, eight corner blocks with three colors are in the edge angle of the magic cube, and two color twelve edge blocks are between the corner blocks and the central block, the magic cube is composed of fifty-four color block colors through mathematical arrangement combination, the magic cube structure is shown in figure 3, and the central block judgment, the three-order magic cube color block judgment, and the current international standard coloring principle are combined with the magic cube color block color predicted in step 4), And (4) judging corner blocks and edge blocks, checking and repairing color blocks which cannot be identified and color blocks with wrong identification, and finishing accurate identification of each color block of the magic cube.
The Gaussian filtering treatment in the step 2) comprises the following steps: scanning each pixel in the magic cube color lump image by using a template, and replacing the value of the central pixel point of the template by using the weighted average gray value of the pixels in the neighborhood determined by the template, wherein the weight distribution is that each coefficient of a Gaussian kernel is multiplied by the sum of all coefficients, and the Gaussian filter kernel is shown in the following table 1:
TABLE 1 Gaussian Filter Kernel
1 4 7 4 1
4 16 26 16 4
7 26 41 26 7
4 16 26 16 4
1 4 7 4 1
The parameter formula of the gaussian filtered kernel is:
Figure GDA0003648808250000101
g (x, y) is a Gaussian template calculated by a Gaussian function, sampling is carried out by taking the central position of the template as a coordinate origin, X, y is a coordinate axis of each position, sigma is called the width of a Gaussian filter for determining the smoothing degree, the larger sigma is, the wider the frequency band of the Gaussian filter is, the better the smoothing degree is, when the image is smoothed, the influence degree of surrounding pixels on the current pixel is actually adjusted by adjusting sigma, the influence degree of remote pixels on the central pixel is improved by increasing sigma, the smoother the filtering result is, the larger the standard deviation sigma is, the closer to the average value filtering is, the more obvious the filtering effect on the magic cube color block image is, but some edge information of the magic cube color block image is lost, the weight of the center is set to be the highest by the Gaussian filter, the weight of the environment is relatively lower, not only the damage condition of the edge points of the magic cube image is considered, but the strength of the center is not lost in the filtering process of the magic cube color block image, the method is suitable for preprocessing the edge of the whole magic cube color block image, after the magic cube color block image is acquired by an acquisition device USB camera, because the magic cube color block image can be interfered by surrounding noise and light environment during the acquisition process and the digital conversion, the subsequent calculation can be sensitive and error, the filtering needs to be performed firstly, the pixel intensity of the magic cube color block image boundary can be lost while the noise is removed in the program digitization process, therefore, the value of each pixel point is subjected to weighted average postprocessing between noise reduction and edge intensity reservation by adopting Gaussian filtering, and comparison graphs before and after the Gaussian filtering processing are shown in figures 1a and 1 b.
The white balance treatment in the step 2) is as follows: the color correction is carried out on the magic cube color block, the white balance processing process processes the darker and brighter colors of the magic cube color block, a specific pixel value is designated, the color influenced by ambient light is corrected into the primary color, the white balance processing ensures that the color of the magic cube color block image is consistent with the actual color of an object under different lighting conditions, the problems of color recovery and color tone processing are solved, the white balance is an index for describing the white precision after the red, green and blue primary colors are mixed, the color processing of the USB camera of the acquisition equipment has chromatic aberration, the magic cube color block image has color changes of different degrees in the process from acquisition to display under different color temperatures, so the acquisition of the magic cube color block is greatly influenced, the color correction of the magic cube color block is needed, the light removal effect is very good under different color temperature conditions, and finally the correct color conversion can be obtained, fig. 2a and 2b show comparative diagrams before and after the white balance processing.
The SVM classification in the step 3) is as follows: the support vector machine algorithm is a classifier formally defined as a super-other class, which can separate different classes among samples, i.e. for training tests on a plurality of different class grades, the SVM algorithm will generate the best separation level, assuming that two-dimensional point types can be linearly divided and the best separation line can be found, as shown in FIG. 8, in two classes of image cutting graphs, there are two classes of square and circle, there are countless possible lines that can divide the samples, but a line too close to the sample is not suitable because it is very sensitive to noise and has low generalization, so the goal is to find a correct division line, which is farthest from all two-dimensional points, find a super-horizontal plane that can divide various classes of points and maximize the value, in the vector support technology, the line that finds the best effect is called "dividing super-plane", the maximum distance level is defined as an "interval", i.e. the closest sample point to the hyperplane is the largest distance to maximize the training data range,
the expression of hyperplane is f (x) beta0Tx, beta are called weight vectors, beta0Called bias, the optimal hyperplane can be expressed in an infinite number of ways, namely by arbitrarily scaling beta and beta0The optimal hyperplane is expressed in the following way:|β0Tx | ═ 1, where x denotes those points closest to the hyperplane, which are referred to as support vectors, and which are also referred to as hyperplanes, knowledge of the geometry of points x to hyperplane (β, β)0) The distance of (a) is:
Figure GDA0003648808250000111
for the hyperplane, the numerator in the expression is 1, so the distance of the support vector to the hyperplane is:
Figure GDA0003648808250000112
the interval margin is denoted M, which takes a value 2 times the closest distance:
Figure GDA0003648808250000113
maximizing M translates to minimizing the function L (β) under additional constraints that imply the hyperplane to fit all training samples xiConditions for correct classification:
Figure GDA0003648808250000114
in the formula yiRepresenting the class mark of the sample, and obtaining the weight vector beta and the bias beta of the optimal hyperplane by the Lagrange multiplier method0The optimal "interval" cut-off graph is as shown in fig. 9, a dotted line is determined by the points of two kinds closest to the central solid line, the area formed by the two dotted lines is the "interval", the "interval" is made as large as possible, because the probability of error making of the large "interval" is small, when the hyperplane is obtained through the algorithm, as long as the distance from the closest point of one kind to the hyperplane is equal to the distance from the closest point of the other kind to the hyperplane, and when the hyperplane of the two kinds on the two sides is parallel, the hyperplane is maximized, the obtained maximum interval is also the maximum interval, the SVM is a common algorithm in machine learning, in the color recognition scheme, compared with the method of dividing colors by using a threshold value limit of a certain color gamut space, the prediction is more accurate and efficient after the color classification is performed by using the SVM scheme, the SVM algorithm is an algorithm for classifying sample data and performing regression and analysis on training dataThe color space categories of six colors of a magic cube color block are taken as training data, firstly, a complete classifier is built, then a classification model is built, the training data are distributed to different labels, the classification model becomes a non-probabilistic Meta linear regression, the maximum interval is divided into two categories, all the data points are mapped to the corresponding categories, the categories are predicted according to the side of the interval of the data in a hyperplane, on the premise that the color block of the magic cube is identified by using an SVM algorithm, due to the change of factors such as environment, light rays, shadow and the like, some color blocks which cannot be identified or can not be identified are still existed, in order to solve the problem, the color is supplemented according to the structural distribution, the spatial position and the color characteristic distribution rule of the magic cube, the magic cube is supplemented under the condition that at most one surface is lacked, and the accuracy of color identification is improved, as shown in fig. 6, the recognition result is easily affected by the change of the lighting environment by adopting the traditional RGB or HSV threshold value limiting method, the robustness is poor, and the reason that the red and orange can not be distinguished by the team of MIT 0.38s reduction magic cube is also because the traditional color recognition is used, so the black magic cube block is used to replace the orange magic cube block, thereby the false recognition of the color is avoided, the SVM classification training method is adopted to classify and recognize the color block color of the magic cube, the influence of the lighting intensity on the color recognition is eliminated, the color recognition of the magic cube basically has no error, and the working stability of the whole system is improved, as shown in fig. 7.
The central block judgment in the step 5) is as follows: the state of each magic cube can obtain a unique development corresponding to six faces of the magic cube, the plane development of the original state or the restored state of the magic cube, namely, the number from the U face is represented by numbers 1, 2 and 3 …, the last numbers 1 to 48 represent a complete magic cube, as shown in fig. 4, the present example does not discuss special coloring of the magic cube, namely, the central block is relatively fixed, the relative positions of 6 central blocks can never be changed, the central block judges that the colors of the color blocks of the magic cube are stored by an array, and the color of the central block is forced to be changed, namely, the [4] is white, the [13] is red, the [22] is green, the [31] is yellow, the [40] is orange, and the [49] is blue.
The corner block judgment in the step 5) is as follows: because the corner block of each magic cube is a first-order magic cube body in fact, the color of each corner block is completely the same as the original color matching of the magic cube, which is the basis for deducing the corner block, the color of the third surface of the corner block can be deduced by knowing the colors of two sides of the corner block, however, the missing color can not be deduced when the corner block lacks more than two colors, and the rule of the magic cube corner block is as follows: (1) relative red oranges; (2) blue and green are opposite; (3) relative yellow and white; (4) yellow at the top and white at the bottom; (5) and when the color is viewed anticlockwise, the colors are sorted, wherein the eight corner blocks are respectively as follows: white orange blue (0,36,47), white red blue (2,11,45), white green orange (6,18,38), white red green (8,9,20), green yellow orange (24,27,44), green red yellow (15,26,29), yellow orange blue (33,42,53), red yellow blue (17,35,51), the color of the magic cube corner block does not change due to rotation, the missing color can be inferred by the rule of "upper yellow lower white, red green orange blue" as long as two colors of the corner block are captured, the corner block decision is as shown in fig. 5, the process is:
5-1) six URFDLB surfaces of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively;
5-2) the array positions corresponding to the eight corner blocks are respectively as follows:
(0,36,47)-WGR、(2,11,45)-WGO、(6,18,38)-WBR、(8,9,20)-WBO、
(24,27,44)-YGR、(15,26,29)-YGO、(33,42,53)-YBR、(17,35,51)-YBO;
5-3) setting four arrays, wherein three arrays store 24 positions of the corner block, and a corner array judges which corner block position has an error:
corner[8]={0};
A[8]={0,2,6,8,24,15,33,17};
B[8]={36,11,18,9,27,26,42,35};
C[8]={47,45,38,20,44,29,53,51};
5-4) according to the regulation of a corner block algorithm, only two large classes W white and Y yellow are provided, each large class comprises two middle classes G green and blue, each middle class comprises two small classes R red and O orange, and then 8 times of polling array positions are adopted to detect whether three groups of colors of the corner block in the positions are correct or not;
5-5) the large class of W white appears randomly at twelve positions 0, 2, 6, 8,9, 11, 18, 20, 36, 38, 45, 47, so the polling first determines whether there is a large class of W white in the positions, if the large class is white, there are two cases of G green and B blue in the medium class, then determines whether the medium class is G green, if the medium class is G green, there are two cases of WGR and WGO, if the small class is R red, it is determined (0,36,47) that the three colors WGR identification of the corner block at this position is successful, the flag bit array corr [0] is set to 1, if the small class is O orange, it is determined (2,11,45) that the three colors WGO identification of the corner block at this position is successful, the flag bit array corr [1] is set to 1, if the medium class is not G green but B blue, there are two cases WBR and WBO, and if the small class is R red, it is determined (6,18,38) the identification of the three colors WBR of the corner block at the position is successful, the flag bit array corner [2] is set to be 1, if the subclass is O orange, the identification of the three colors WBO of the corner block at the position is judged (8,9,20) to be successful, and the flag bit array corner [3] is set to be 1;
5-6) judging whether the major Y yellow appears randomly at twelve positions of 15, 17, 24, 26, 27, 29, 33, 35, 42, 44, 51 and 53, judging whether the major Y yellow has two middle classes of G green and B blue, judging whether the middle class is G green or not, judging (24,27 and 44) that the three-color YGR identification of the corner block at the position succeeds if the middle class is G green, setting the flag bit array corner [4] to 1 if the middle class is O green, judging (15,26 and 29) that the three-color YGO identification of the corner block at the position succeeds if the minor class is R red, setting the flag bit array corner [5] to 1, judging that the minor class is not G green but B blue, setting the three-color WBR identification of the position succeeds, setting a flag bit array corner [6] to be 1, judging (17,35,51) that the identification of the angle block with three colors YBO at the position is successful if the subclass is O orange, and setting a flag bit array corner [7] to be 1;
5-7) the corner block algorithm determines which corner block position is identified incorrectly according to the flag bit in the array corner, and then repairs the missing color at the position, for example, corner [0] is equal to 0, the algorithm checks three colors in the (0,36,47) positions, only three colors of W red, G green, and R red may exist in the (0,36,47), if only W red and G green appear, it can be known that the identified colour is R red, and then the other color is forcibly changed to red.
The process for judging the edge block in the step 5) comprises the following steps: as shown in the colored diagram of fig. 4, the magic cube has 12 prism blocks, namely, white blue (1,46), white orange (3,37), white red (5,10), white green (7,19), yellow green (28,25), yellow orange (30,43), yellow red (32,16), yellow blue (34,52), red green (12,23), red blue (14,48), blue orange (50,39), green orange (21,41), the judgment of the prism blocks is similar to that of the corner blocks, but the prism blocks cannot directly deduce the color of the other side from one color, because four prism blocks of the same color can appear on different sides, the deduction of the prism blocks must know the prism blocks of the other three sides to check whether the color blocks are accurate:
a: six faces of URFDLB of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively;
and b, the array positions corresponding to the twelve corner blocks are respectively as follows:
(1,46)-WG、(3,37)-WR、(5,10)-WB、(7,19)-WO
(28,25)-YG、(30,43)-YR、(32,16)-YB、(34,52)-YO
(12,23)-GR、(14,48)-GO、(50,39)-BR、(21,41)-BO;
c: set for three array, wherein 24 positions of two array storage arriss piece, it is wrong that an edge array judges which arris piece position:
A[12]={1,3,5,7,28,30,32,34,12,14,50,21};
B[12]={46,37,10,19,25,43,16,52,23,48,39,41};
edge[12]={0};
d: defining four broad classes of W white, Y yellow, G green and B blue, wherein the other three colors exist in the broad classes of W white and Y yellow, and the R red and O orange exist in the broad classes of G green and B blue, and detecting the prism blocks in the positions by adopting the positions of 12 times of polling arrays;
e: firstly, judging a large class of W white, wherein the W white can randomly appear at eight positions of 1, 3, 5, 7, 10, 19, 37 and 46, then identifying G green, successfully identifying the position of (1,46), identifying R red, successfully identifying the position of (3,37), identifying edge 1, identifying B blue, successfully identifying the position of (5,10), identifying edge 2, successfully identifying (7,19) and identifying orange, and finally, identifying edge 3;
f: then judging that the major Y white appears randomly at eight positions of 16, 25, 28, 30, 32, 34, 43 and 52, then recognizing G green, then (28,25) successfully recognizing the position, setting the flag edge [4] to 1, recognizing R red, then (30,43) successfully recognizing the position, setting the flag edge [5] to 1, recognizing B blue, then (32,16) successfully recognizing the position, setting the flag edge [6] to 1, recognizing O orange, then (34,52) successfully recognizing the position, and setting the flag edge [7] to 1;
g: then continuing to judge the major G green, wherein the G green randomly appears at four positions of 12, 14, 23 and 48, and then recognizing R red, successfully recognizing the positions of (12 and 23), setting the flag edge [8] to 1, recognizing O orange, successfully recognizing the positions of (14 and 48), and setting the flag edge [9] to 1;
h: finally, judging that the B blue of the large class randomly appears at four positions 21, 39, 41 and 50, identifying R red, successfully identifying the position (50 and 39), setting a flag edge [10] to 1, identifying O orange, successfully identifying the position (21 and 41), and setting a flag edge [11] to 1;
i: according to the flag bit in the array edge, which prism position is wrong to identify is judged, and one color is wrong to identify in the white major category, and the color can be reduced only by checking the flag bits of edge [0], edge [1], edge [2] and edge [3 ]:
i-1) when edge [0] is 0, edge [1] is 1, edge [2] is 1, edge [3] is 1, then G green is known to be missing;
i-2) when edge [0] is 1, edge [1] is 0, edge [2] is 1, edge [3] is 1, then R red is known to be missing;
i-3) when edge [0] is 1, edge [1] is 1, edge [2] is 0, edge [3] is 1, then B blue is known to be missing;
i-4) when edge [0] is 1, edge [1] is 1, edge [2] is 1, and edge [3] is 0, then O-orange is known to be missing.
The method comprises the steps of firstly carrying out Gaussian filtering on the edge of an image by adopting OpenCV, then carrying out RGVHSV color gamut conversion processing on the image, establishing a class model of six colors of the magic cube by adopting an SVM classifier algorithm to improve the capturing accuracy of the colors of the magic cube, simultaneously proposing angle, edge and center block repairing according to the overall structure of the magic cube, combining the SVM class model with the color repairing algorithm, and carrying out repairing and checking according to color values pre-judged by the classifier and color blocks of the magic cube so as to obtain the color of each color block of the magic cube.
Experimental simulation proves that the method effectively improves the speed and the precision of the system for identifying the color of the magic cube and accurately identifies the color of the color block of the magic cube.
Experiment simulation: the method of the present example was tested using MATLAB2016a simulation software, where red and orange are similar colors in the color patches of the magic cube, so the two colors were taken as test data to generate unbalanced samples with red: orange: 9986:14, 200 red samples and 10 orange samples were randomly extracted from the 10000 data, the method of the present example was compared with a conventional SVM classifier algorithm, and the parameter settings of the experiment are shown in table 2:
table 2 experimental parameter settings
Figure GDA0003648808250000151
And (3) generating data: 9986:14, wherein the training samples are obtained by randomly extracting 200 positive (red) samples and 10 (orange) samples from 10000 data as shown in fig. 11, and as shown in fig. 12, preprocessing the data to normalize the data to [ -1,1], then using a grid search optimization penalty coefficient c to find the optimal result data specification as shown in fig. 13, a parameter coefficient g of a grid search optimization SVM kernel function as the optimal result data specification (3D) is shown in fig. 14, the penalty coefficient c is understood as adjusting the weight of the two indexes (interval size and classification accuracy) in the optimization direction, that is, the higher c is the tolerance of the error, the more the error cannot be tolerated, the overfitting is easy, the smaller c is the underrun, the too large c is the too small c, the generalization capability is poor, the parameter coefficient g of the SVM kernel function implicitly determines the distribution of the data after mapping to a new feature space, the larger the g value is, the fewer the support vectors are, the smaller the g value is, the more the support vectors are, the number of the support vectors influences the training and predicting speed, then the SVM classifier algorithm is adopted to train the data, and the results obtained through the one-to-many algorithm are shown in the table 3:
TABLE 3 Algorithm test data
Figure GDA0003648808250000161
Experimental results and analysis: as the generated data is non-equilibrium and non-linear data, the detection cannot be performed according to the fitting curve algorithm, and the color can only be predicted through the training data, as can be seen from table 3, the accuracy of the identified red sample is higher under the training of the large data sample by the SVM classifier algorithm, but the estimation of a small number of orange samples is not accurate, for the two extreme non-equilibrium data, the performance test is a larger problem after the training of the SVM algorithm is completed, especially for the test of the classification accuracy of a small number of samples, a more reliable classification prediction accuracy can be obtained only through a large number of samples, while the method of the embodiment still has high accuracy under the two extreme data, and the error is lower than that of the SVM algorithm. Because the method judges and corrects the color of all the center blocks, the corner blocks and the edge blocks according to the structure of the magic cube, the problem that the SVM algorithm is inaccurate in identifying a few types of samples can be solved.
This example color patch algorithm tests: input an array of 54 colors in error: (GOYWWGWWOWRYGRGOOBBGBGOWBWRGBOYOGRYORRORBBGWYYBYRY), and can be restored into correct magic cube color block color after the color patch algorithm, as shown in FIG. 15: (GBYWWWOWRGGRGOOBBGBGOWWWRGBOYOGRRORRORBBGOYYBYYRY).

Claims (4)

1. A magic cube color block color reduction method based on SVM classification is characterized by comprising the following steps:
1) collecting magic cube color block information: acquiring images of six surfaces of the magic cube color block by using acquisition equipment;
2) image preprocessing: eliminating noise and illumination interference on the magic cube color block image in the digitization process by adopting Gaussian filtering processing and white balance processing;
3) image gamut space conversion: the method comprises the following steps of performing RGB-HSV color gamut space conversion on magic cube color blocks, dividing each surface of a magic cube into nine regions with the size of 50 x 50 pixels, namely nine magic cube color blocks of each surface, obtaining six RGBWV values of each region, wherein the data of the color gamut space of the whole magic cube color blocks are as follows: 6, 9, 50 and 135000 data, firstly setting six colors of a magic cube color block as labels, then adopting SVM classification training, storing the acquired data of the RGBWV color gamut space corresponding to the set labels, and generating an XML training file;
4) identifying magic cube color blocks by a one-to-many classification method: carrying out magic cube color block recognition on the image preprocessed in the step 2) by adopting a one-to-many classification method according to the XML training file generated in the step 3), predicting the color of each magic cube color block by SVM classification, wherein the one-to-many classification method, namely one against all, is to reclassify samples in the training process, construct six vector machines of six classes, if an unknown sample is encountered in the classification process, the unknown sample is classified into the class with the maximum classification value in the training function, when there are six magic cube color categories, training the training sets separately to obtain six different training result files, testing each component after each training file, each test having a result, and finally comparing the maximum value of the six results to obtain which magic cube color the tested component belongs to;
5) magic cube color repairing: the magic cube color block cube is formed by fifty-four color blocks through a mathematical arrangement and combination mode, the center block judgment, the corner block judgment and the edge block judgment are carried out by combining the color block color of the magic cube predicted in the step 4), the cube structure of the three-order magic cube and the current international standard coloring principle, the color blocks which cannot be identified and the color blocks which are identified wrongly are checked and repaired, and the accurate identification of each color block of the magic cube is completed;
the central block judgment in the step 5) is as follows: the state of each magic cube is to obtain a unique development diagram corresponding to six surfaces of the magic cube, the planar development diagram of the original state or the restored state of the magic cube is that the numbering is expressed by numbers 1, 2 and 3 … from the U surface, the numbers 1 to 48 finally express a complete magic cube, the central block is relatively fixed according to the current international standard coloring principle, the relative positions of 6 central block blocks can not be changed, the central block judges that the colors of all color blocks of the magic cube are stored by an array, and the colors of the central block are forcibly changed, namely [4] ═ white, [13] ═ red, [22] ═ green, [31] ═ yellow, [40] ═ orange and [49] -;
the corner block judgment in the step 5) is as follows: the corner block of every magic cube all is a first-order magic cube body, and the colour of every corner block is exactly the foundation that the angle block was inferred with the magic cube original color matching, knows the colour on corner block both sides, just can deduce the colour of corner block third face, can't deduce the colour of disappearance when the corner block lacks the colour more than two, and the law of magic cube corner block is: (1) relative red and orange; (2) blue and green are opposite; (3) relative yellow and white; (4) yellow at the top and white at the bottom; (5) and when the color is viewed anticlockwise, the colors are sorted, wherein the eight corner blocks are respectively as follows: white orange blue (0,36,47), white red blue (2,11,45), white green orange (6,18,38), white red green (8,9,20), green yellow orange (24,27,44), green red yellow (15,26,29), yellow orange blue (33,42,53), red yellow blue (17,35,51), the color of the cube corner block does not change due to rotation, as long as two colors of the corner block are captured, the missing color is deduced according to the rule of "upper yellow lower white, red green orange blue", the process is as follows:
5-1) six URFDLB surfaces of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively;
5-2) the array positions corresponding to the eight corner blocks are respectively as follows:
(0,36,47)-WGR、(2,11,45)-WGO、(6,18,38)-WBR、(8,9,20)-WBO、
(24,27,44)-YGR、(15,26,29)-YGO、(33,42,53)-YBR、(17,35,51)-YBO;
5-3) four arrays are set, wherein three arrays store 24 positions of the corner block, and a corner array is also used for judging which corner block position is wrong:
corner[8]={0};
A[8]={0,2,6,8,24,15,33,17};
B[8]={36,11,18,9,27,26,42,35};
C[8]={47,45,38,20,44,29,53,51};
5-4) only two major classes of W white and Y yellow are specified, each major class has two major classes of G green and blue, each major class has two minor classes of R red and O orange, and then the positions of the array are polled 8 times to detect whether the three groups of colors of the corner block in the positions are correct;
5-5) the large W white appears randomly at twelve positions 0, 2, 6, 8,9, 11, 18, 20, 36, 38, 45, 47, polling first judges whether the large W white exists in the positions, if the large W white exists, the middle W white has two cases of G green and B blue, then judges whether the middle W white is G green, if the middle W white is G green, the middle W white has two cases of WGR and WGO, if the small W white is R red, the corner block three colors WGR identification of the position is judged to be successful, the flag bit array corr [0] is set to be 1, if the small W white is O orange, the corner block three colors WGO identification of the position is judged to be successful, the flag bit array corr [1] is set to be 1, if the middle W white is not G green but B blue, the small W white is judged to be R red, the flag bit array is judged to be 6,18,38) the identification of the three colors WBR of the corner block at the position is successful, the flag bit array corner [2] is set to be 1, if the subclass is O orange, the identification of the three colors WBO of the corner block at the position is judged (8,9,20) to be successful, and the flag bit array corner [3] is set to be 1;
5-6) judging whether the major Y yellow appears randomly at twelve positions of 15, 17, 24, 26, 27, 29, 33, 35, 42, 44, 51 and 53, judging whether the major Y yellow has two middle classes of G green and B blue, judging whether the middle class is G green or not, judging (24,27 and 44) that the three-color YGR identification of the corner block at the position succeeds if the middle class is G green, setting the flag bit array corner [4] to 1 if the middle class is O green, judging (15,26 and 29) that the three-color YGO identification of the corner block at the position succeeds if the minor class is R red, setting the flag bit array corner [5] to 1, judging that the minor class is not G green but B blue, setting the three-color WBR identification of the position succeeds, setting a flag bit array corner [6] to be 1, judging (17,35,51) that the identification of the angle block with three colors YBO at the position is successful if the subclass is O orange, and setting a flag bit array corner [7] to be 1;
5-7) judging which corner block position is identified wrongly according to the flag bit in the array corner, and then repairing the missing color of the position;
the process for judging the edge block in the step 5) comprises the following steps: the magic cube color blocks have 12 prism blocks which are respectively white blue (1,46), white orange (3,37), white red (5,10), white green (7,19), yellow green (28,25), yellow orange (30,43), yellow red (32,16), yellow blue (34,52), red green (12,23), red blue (14,48), blue orange (50,39) and green orange (21,41),
a: six faces of URFDLB of the fixed magic cube correspond to white, red, green, yellow, orange and blue WRGYOB respectively:
and b, the array positions corresponding to the twelve corner blocks are respectively as follows:
(1,46)-WG、(3,37)-WR、(5,10)-WB、(7,19)-WO
(28,25)-YG、(30,43)-YR、(32,16)-YB、(34,52)-YO
(12,23)-GR、(14,48)-GO、(50,39)-BR、(21,41)-BO;
c: set for three array, wherein 24 positions of two array storage arriss piece, it is wrong that an edge array judges which arris piece position:
A[12]={1,3,5,7,28,30,32,34,12,14,50,21};
B[12]={46,37,10,19,25,43,16,52,23,48,39,41};
edge[12]={0};
d: defining four broad classes of W white, Y yellow, G green and B blue, wherein the other three colors exist in the broad classes of W white and Y yellow, and the R red and O orange exist in the broad classes of G green and B blue, and detecting the prism blocks in the positions by adopting the positions of 12 times of polling arrays;
e: firstly, judging a large class of W white, wherein the W white can randomly appear at eight positions of 1, 3, 5, 7, 10, 19, 37 and 46, then identifying G green, successfully identifying the position of (1,46), identifying R red, successfully identifying the position of (3,37), identifying edge 1, identifying B blue, successfully identifying the position of (5,10), identifying edge 2, successfully identifying (7,19) and identifying orange, and finally, identifying edge 3;
f: then judging that the major Y white appears randomly at eight positions of 16, 25, 28, 30, 32, 34, 43 and 52, then recognizing G green, then (28,25) successfully recognizing the position, setting the flag edge [4] to 1, recognizing R red, then (30,43) successfully recognizing the position, setting the flag edge [5] to 1, recognizing B blue, then (32,16) successfully recognizing the position, setting the flag edge [6] to 1, recognizing O orange, then (34,52) successfully recognizing the position, and setting the flag edge [7] to 1;
g: then continuously judging the major G green, wherein the G green randomly appears at four positions of 12, 14, 23 and 48, and then if R red is identified, the position identification of (12,23) is successful, and the flag bit edge [8] is set to be 1, if O orange is identified, the position identification of (14,48) is successful, and the flag bit edge [9] is set to be 1;
h: finally, judging that the B blue of the large class randomly appears at four positions 21, 39, 41 and 50, identifying R red, successfully identifying the position (50 and 39), setting a flag edge [10] to 1, identifying O orange, successfully identifying the position (21 and 41), and setting a flag edge [11] to 1;
i: according to the flag bit in the array edge, which prism position is wrong to identify is judged, and one color is wrong to identify in the white major category, and the color can be reduced only by checking the flag bits of edge [0], edge [1], edge [2] and edge [3 ]:
i-1) when edge [0] is 0, edge [1] is 1, edge [2] is 1, edge [3] is 1, then G green is known to be missing;
i-2) when edge [0] is 1, edge [1] is 0, edge [2] is 1, edge [3] is 1, then R red is known to be missing;
i-3) when edge [0] is 1, edge [1] is 1, edge [2] is 0, edge [3] is 1, then B blue is known to be missing;
i-4) when edge [0] is 1, edge [1] is 1, edge [2] is 1, edge [3] is 0, then it is known that O-orange is missing.
2. The magic cube color block color reduction method based on SVM classification according to claim 1, wherein the Gaussian filtering process in step 2) is: scanning each pixel in the magic cube color lump image by using a template, and replacing the value of the central pixel point of the template by using the weighted average gray value of the pixels in the neighborhood determined by the template, wherein the weight distribution is that each coefficient of a Gaussian kernel is multiplied by the sum of all coefficients, and the Gaussian filter kernel is shown in the following table 1:
TABLE 1 Gaussian Filter Kernel
1 4 7 4 1 4 16 26 16 4 7 26 41 26 7 4 16 26 16 4 1 4 7 4 1
The parameter formula of the gaussian filtered kernel is:
Figure FDA0003648808240000041
g (x, y): the sampling is performed using the central position of the template as the origin of coordinates, X, Y is the coordinate axis of each position, and σ is the width of the gaussian filter that determines the degree of smoothing.
3. A magic cube color patch color reduction method according to claim 1, wherein the white balance processing in step 2) is: for color correction of the magic cube color block, the white balance processing process processes the darker and lighter colors of the magic cube color block and specifies a specific pixel value to correct the colors affected by the ambient light into the primary colors.
4. The magic cube color lump color reduction method based on SVM classification of claim 1, wherein the SVM classification in step 3) is: assuming that two-dimensional point types can be linearly divided and the best separation line can be found, in the two types of image cutting maps, there are two types of square and circularIn vector support technology, the line with the best effect is found to be a ' dividing hyperplane ', the maximum distance level is defined as an interval ', namely the distance between the nearest sample point and the hyperplane is the maximum, so that the training data range is maximized, and the hyperplane has the expression of f (x) and beta0Tx, beta are called weight vectors, beta0Called offset, the optimal hyperplane has an infinite number of expressions, namely by arbitrarily scaling β and β0The optimal hyperplane is expressed in the following way: beta | (B)0Tx | ═ 1, where x denotes those points closest to the hyperplane, also called support vectors, from point x to the hyperplane (β, β), also called hyperplane0) The distance of (c) is:
Figure FDA0003648808240000051
for the hyperplane, the numerator in the expression is 1, and the distance of the support vector to the hyperplane is:
Figure FDA0003648808240000052
the interval margin is denoted M, which takes a value 2 times the closest distance:
Figure FDA0003648808240000053
maximizing M translates to minimizing the function L (β) under additional constraints that imply the hyperplane to fit all training samples xiConditions for correct classification:
Figure FDA0003648808240000054
in the formula yiRepresenting the class mark of the sample, and obtaining the weight vector beta and the bias beta of the optimal hyperplane by a Lagrange multiplier method0The optimal 'interval' cutting graph is formed by determining dotted lines by two kinds of points which are closest to the central solid line, and the area formed by the two dotted lines is the 'interval', only one dotted line is requiredWhen the hyperplanes of the two side classes are parallel, the hyperplane reaches the maximum and the obtained maximum interval is also the maximum, the color space classes of the six colors of the magic cube color block are used as training data, firstly, a complete classifier is built, then a classification model is built, the training data are distributed to different labels, the classification model becomes a non-probability Meta linear regression, the maximum interval is divided into two classes, then all data points are mapped to the corresponding classes, and the classes are predicted according to the side of the interval of the data in the hyperplane.
CN202010860737.6A 2020-08-25 2020-08-25 Magic cube color block color reduction method based on SVM classification Active CN111950654B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010860737.6A CN111950654B (en) 2020-08-25 2020-08-25 Magic cube color block color reduction method based on SVM classification

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010860737.6A CN111950654B (en) 2020-08-25 2020-08-25 Magic cube color block color reduction method based on SVM classification

Publications (2)

Publication Number Publication Date
CN111950654A CN111950654A (en) 2020-11-17
CN111950654B true CN111950654B (en) 2022-07-05

Family

ID=73360111

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010860737.6A Active CN111950654B (en) 2020-08-25 2020-08-25 Magic cube color block color reduction method based on SVM classification

Country Status (1)

Country Link
CN (1) CN111950654B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113408573B (en) * 2021-05-11 2023-02-21 广东工业大学 Method and device for automatically classifying and classifying tile color numbers based on machine learning
CN116010996B (en) * 2023-03-01 2023-06-13 上海伯镭智能科技有限公司 Unmanned system development data safety management method
CN117095103B (en) * 2023-08-11 2024-03-19 广州淦源智能科技有限公司 Data processing method based on intelligent magic cube and magic cube thereof

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982350A (en) * 2012-11-13 2013-03-20 上海交通大学 Station caption detection method based on color and gradient histograms
CN107154058A (en) * 2017-05-08 2017-09-12 上海葡萄纬度科技有限公司 A kind of method for guiding user to reduce magic square
CN108830908A (en) * 2018-06-15 2018-11-16 天津大学 A kind of magic square color identification method based on artificial neural network
CN109284759A (en) * 2018-07-24 2019-01-29 五邑大学 One kind being based on the magic square color identification method of support vector machines (svm)
CN110838150A (en) * 2019-11-18 2020-02-25 重庆邮电大学 Color recognition method for supervised learning
CN111383352A (en) * 2020-03-20 2020-07-07 北京工业大学 Automatic color filling and abstracting method for three-order magic cube

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8358320B2 (en) * 2007-11-02 2013-01-22 National University Of Singapore Interactive transcription system and method
CN105413156B (en) * 2015-12-29 2017-11-14 江淦源 A kind of magic square

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982350A (en) * 2012-11-13 2013-03-20 上海交通大学 Station caption detection method based on color and gradient histograms
CN107154058A (en) * 2017-05-08 2017-09-12 上海葡萄纬度科技有限公司 A kind of method for guiding user to reduce magic square
CN108830908A (en) * 2018-06-15 2018-11-16 天津大学 A kind of magic square color identification method based on artificial neural network
CN109284759A (en) * 2018-07-24 2019-01-29 五邑大学 One kind being based on the magic square color identification method of support vector machines (svm)
CN110838150A (en) * 2019-11-18 2020-02-25 重庆邮电大学 Color recognition method for supervised learning
CN111383352A (en) * 2020-03-20 2020-07-07 北京工业大学 Automatic color filling and abstracting method for three-order magic cube

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Color Recognition for Rubik"s Cube Robot;Lin Feng 等;《2019 IEEE International Conference on Smart Internet of Things(SmartIoT)》;20191114;269-274 *
Color restoration algorithm of Rubik"s cube color block based on SVM classification;QIN QIN 等;《RICAI 2020:Proceedings of the 2020 2nd International Conference on Robotics,Intelligent Control and Artificial Intelligence》;20201019;29-33 *
魔方中的颜色识别及其STM32实现;赵晓军 等;《电视技术》;20181205;第42卷(第12期);71-74 *

Also Published As

Publication number Publication date
CN111950654A (en) 2020-11-17

Similar Documents

Publication Publication Date Title
CN111950654B (en) Magic cube color block color reduction method based on SVM classification
CN109255344B (en) Machine vision-based digital display type instrument positioning and reading identification method
CN109829914B (en) Method and device for detecting product defects
CN105046252B (en) A kind of RMB prefix code recognition methods
CN104866862B (en) A kind of method of belt steel surface area-type defect recognition classification
CN108596197B (en) Seal matching method and device
CN102426649B (en) Simple steel seal digital automatic identification method with high accuracy rate
CN103034838B (en) A kind of special vehicle instrument type identification based on characteristics of image and scaling method
CN109271991B (en) License plate detection method based on deep learning
CN110443128B (en) Finger vein identification method based on SURF feature point accurate matching
CN102103698B (en) Image processing apparatus and image processing method
CN112465809A (en) Mold defect detection method based on image recognition, computer-readable storage medium and device
CN112164055A (en) Photovoltaic cell color difference classification method based on color segmentation
CN114926661A (en) Textile surface color data processing and identifying method and system
Lin et al. License plate location method based on edge detection and mathematical morphology
CN113052234A (en) Jade classification method based on image features and deep learning technology
CN118037091A (en) Intelligent report working quality detection method and system based on computer vision technology
CN113361547A (en) Signature identification method, device, equipment and readable storage medium
CN116152234B (en) Template end face defect identification method based on image processing
CN115880683B (en) Urban waterlogging ponding intelligent water level detection method based on deep learning
CN117036314A (en) Method for detecting oxidation area of high-density flexible IC substrate
CN111652200A (en) Processing method, device and equipment for distinguishing multiple vehicles from pictures in vehicle insurance case
CN113989823B (en) Image table restoration method and system based on OCR coordinates
CN116612461A (en) Target detection-based pointer instrument whole-process automatic reading method
CN114581407B (en) Self-adaptive defect detection method for photovoltaic module

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