Image color block color classification method and device based on distance

Through the distance-based image color block color classification method, the problem of difficult to effectively classify image color block color characteristics in the prior art is solved, and the rapid and accurate color classification of image color blocks is achieved, which is suitable for circuit implementation.

CN119888342APending Publication Date: 2025-04-25XIAMEN SHENGSHENG MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411965862.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Existing image classification algorithms mainly focus on the categories of objects in the image, and it is difficult to effectively classify the color characteristics in image color blocks, especially in complex images.

Method used

The distance-based image color block color classification method is used to segment the original image, calculate the distance of pixel points in each color block, find the color categories and endpoints corresponding to the maximum distance, and split and classify the color categories according to the distance.

Benefits of technology

It realizes the fast and accurate color classification of image color blocks, is simple and fast compared to traditional methods, and is suitable for circuit implementation, improving the efficiency and effect of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888342A_ABST
    Figure CN119888342A_ABST
Patent Text Reader

Abstract

The invention discloses a distance-based image color block color classification method and device, and the method mainly comprises the steps: segmenting an original image to obtain M rows and N columns of image color blocks, calculating the distance between every two pixel points in the classified color of each color block, and obtaining a pixel point distance table, searching a category corresponding to the maximum distance in the existing pixel point distance table and a corresponding pixel point, if the maximum distance in the existing pixel point distance table is greater than a set threshold value, performing the following steps on the table, otherwise, exiting the classification process, comparing the distances between the other pixel points in the color category and the two pixel points with the maximum distance, and classifying; and splitting all the pixel points of the same color category into two color categories and two new pixel point distance tables according to the classification result, and circulating the steps until the color classification result of the color block is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for color classification of image color blocks, belongs to the field of image processing, and particularly to a method and device for color classification of image color blocks based on distance. Background Art

[0002] The main purpose of classification algorithms is to discover patterns in data and split the data into different categories. Common classification algorithms include decision trees, K-nearest neighbors, support vector machines, neural networks, etc. Different classification algorithms have their own advantages. For example, neural network methods have strong nonlinear fitting capabilities and can handle complex pattern recognition and prediction problems. However, the training process of neural networks is relatively complex and requires a lot of computing resources and time.

[0003] Image classification has a wide range of applications in many fields, such as image search, security monitoring, and autonomous driving. Image classification technology has become increasingly mature, and its accuracy can be very high, but image classification still mainly focuses on the single dimension of the category to which the object in the image belongs.

[0004] The classification algorithm of image color blocks can classify the pixels in the image color blocks according to different dimensions, including contrast characteristics, color (color and brightness) characteristics, etc., where the color characteristics mainly refer to the color types of pixels that can be visually distinguished in the color blocks. In view of the above problems, the present invention proposes a distance-based image color block color classification method and device. Summary of the invention

[0005] The present invention provides a distance-based image color block color classification method, comprising:

[0006] Step 1: Segment the original image to obtain image color blocks with M rows and N columns;

[0007] Step 2: Calculate the distance D between all pixels in the classified colors of each color block, and obtain the pixel distance table T. Suppose the number of classified colors is Q;

[0008] Step 3: Find the existing pixel distance table T1~T Q The color category q corresponding to the maximum distance m and the corresponding pixel i m With j m ;

[0009] Step 4: determine whether the maximum distance in the existing pixel distance table is greater than the set threshold. If so, proceed to step 5. If not, exit the classification process and obtain the color classification result of the color block.

[0010] Step 5: Compare the qth mThe remaining pixels in the color category are the two pixels i with the largest distance from each other. m With j m Distance and classification;

[0011] Step 6: Split all pixels of the same color category into two color categories and two new pixel distance tables according to the classification results;

[0012] Step 7: Repeat the above steps until exiting to obtain the color classification result of the color block.

[0013] In step 2, if the color category is q, 1≤q≤Q, assuming that the i-th and j-th pixels belong to the current color category q, the channel values ​​corresponding to the i-th and j-th pixels are

[0014] R i =R(i / N,i%N)

[0015] G i =G(i / N,i%N)

[0016] B i =B(i / N,i%N)

[0017] R j =R(j / N,j%N)

[0018] G j =G(j / N,j%N)

[0019] B j =B(j / N,j%N)

[0020] Then the distance between the i-th and j-th pixels in the q-th class is defined as D q (i,j), the distance calculation method uses but is not limited to the following three:

[0021] (1) Euclidean distance

[0022]

[0023] (2) Manhattan distance

[0024] D q (i,j)=|R i -R j |+|G i -G j |+|B i -B j |

[0025] (3) Chebyshev distance

[0026] D q (i,j)=max{|Ri -R j |,|G i -G j |,|B i -B j |}

[0027] In particular, when i=j, D q (i,j)=0

[0028] The distance D between all pixels of the current color category q in the color block q The pixel distance table composed of (i, j) is T q .

[0029] Step three includes: In For all pixel distance table T q The maximum value in , then the color category to be split is the qth m Class, and the i m The pixel and the jth m The pixel is the qth m The two corresponding pixels in the cluster are the farthest apart.

[0030] Step 4 includes:

[0031] Assume that the maximum allowable threshold is Threshold_D, if Then proceed to the next step for this table; if Then exit the classification process.

[0032] Step five includes, in the qth m In the color categories, select the kth pixel and compare the kth pixel with the i-th pixel. m pixels, the jth m The distance of pixels like Then the kth pixel and the jth pixel m Pixels are classified into the same color category;

[0033] like Then the kth pixel is connected to the i-th pixel m Pixels are classified into the same color category;

[0034] All pixels in the table are classified into the i-th m pixel or jth m The color category to which the pixels belong.

[0035] Step six includes:

[0036] Assume that all pixels to be classified in the color block belong to the same color category qm , when all pixels are classified, they can be split into the i-th m The pixel belongs to the color category q m and j m When the pixel belongs to the new color category Q+1, the above pixel distance table It can also be split into color categories q m The distance table composed of all pixels in The distance table T composed of all pixels in color category Q+1 Q+1 .

[0037] In step seven, the color classification result of the color block includes the number of separable categories of the color block and the pixel point sequence included in each category under the number of categories.

[0038] The present invention also provides a distance-based image color block color classification device, comprising:

[0039] Image segmentation unit: divides the original image into image color blocks of a certain size according to a certain number of rows and columns;

[0040] Pixel distance calculation unit: calculates the distance between each pixel in the image color block segmented by the image segmentation unit according to the pixel value, and generates a pixel distance table corresponding to the color category of the image color block;

[0041] Pixel distance comparison unit: compares the distances between pixels of each color category of the image color block and obtains the maximum value in the pixel distance table;

[0042] Category and endpoint selection unit: selects the color category corresponding to the maximum value of the distance comparison unit between pixels and the two endpoints with the longest distance, and transmits the corresponding color category and the two endpoints with the longest distance to the pixel nearest classification unit;

[0043] Pixel point proximity classification unit: The two endpoints with the longest distance received are directly divided into two color categories, and other pixels in the color category are divided into corresponding color categories according to their distance from the endpoints. The distance table of the pixels after being split into two color categories is updated for the next classification.

[0044] The classification method proposed in the present invention mainly classifies image color blocks according to the dimension of pixel color. Compared with traditional classification algorithms, the classification process is relatively simple and fast, the classification effect is better, and it is more conducive to circuit implementation. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 Shown is a flow chart of the present invention;

[0046] Figure 2The figure shows a schematic diagram of image color blocks of M rows and N columns after the original image is segmented according to the present invention;

[0047] Figure 3 The figure shows the pixel distance representation when the 0th to 5th pixel points are in category q in the present invention;

[0048] Figure 4 Shown is a schematic structural diagram of a color classification device for image color blocks of the present invention. DETAILED DESCRIPTION

[0049] 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.

[0050] See also Figure 1 , which is shown as a distance-based image color block classification method, including:

[0051] Step 1: Segment the original image to obtain image color blocks with M rows and N columns;

[0052] Assuming that each pixel of the original image contains three sub-pixels of RGB, the image color blocks of M rows and N columns after segmenting the original image can be expressed as follows: Figure 2 As shown, the number of rows M and the number of columns N are variable.

[0053] Step 2: Calculate the distance D between all pixels in the classified colors of each color block, and obtain the pixel distance table T. Suppose there are Q classified colors.

[0054] In the initial state, Q = 1, that is, all pixels in the color block belong to the same color; in the non-initial state, the distances between all pixels in each color block with classified colors are obtained by the pixel distance table T1~T Q .

[0055] Taking color category q as an example (1≤q≤Q), assuming that the i-th and j-th pixels belong to the current color category q, the channel values ​​corresponding to the i-th and j-th pixels are

[0056] R i =R(i / N,i%N)

[0057] G i =G(i / N,i%N)

[0058] B i =B(i / N,i%N)

[0059] Rj =R(j / N,j%N)

[0060] G j =G(j / N,j%N)

[0061] B j =B(j / N,j%N)

[0062] Then the distance between the i-th and j-th pixels in the q-th class is defined as D q (i,j), the distance calculation method can be used but is not limited to the following three:

[0063] (1) Euclidean distance

[0064]

[0065] (2) Manhattan distance

[0066] D q (i,j)=|R i -R j |+|G i -G j |+|B i -B j |

[0067] (3) Chebyshev distance

[0068] D q (i,j)=max{|R i -R j |,|G i -G j |,|B i -B j |}

[0069] In particular, when i=j, D q (i,j)=0,

[0070] The distance D between all pixels of the current color category q in the color block q The pixel distance table T composed of (i, j) q .like Figure 3 The pixel distance table shown is when the 0th to 5th pixel points are in category q. It can be clearly seen that the values ​​of the pixel distance table are symmetric about the diagonal line.

[0071] Step 3: Find the existing pixel distance table T1~T Q The color category q corresponding to the maximum distance m and the corresponding pixel i m With j m ;

[0072] If the table In is the maximum value in the distance table of all pixels, then the color category to be split is the qth m Class, and the i m The pixel and the jth m The pixel is the qth m The two corresponding pixels in the cluster are the farthest apart.

[0073] Step 4: Determine whether the maximum distance in the existing pixel distance table is greater than the set threshold. If so, proceed to step 5. If not, exit the classification process and obtain the color classification result of the color block.

[0074] Assume that the maximum allowable threshold is Threshold_D, if Then proceed to the next step for this table; if Then exit the classification process.

[0075] Step 5: Compare the qth m The remaining pixels in the color category are the two pixels i with the largest distance from each other. m With j m distance and classify.

[0076] In the q m In the color categories, select the kth pixel and compare the kth pixel with the i-th pixel. m pixels, the jth m The distance of pixels like Then the kth pixel and the jth pixel m Pixels are classified into the same color category;

[0077] like Then the kth pixel is connected to the i-th pixel m Pixels are classified into the same color category;

[0078] All pixels in the table are classified into the i-th m pixel or jth m The color category to which the pixels belong.

[0079] Step 6: Split all pixels of the same color category into two color categories and two new pixel distance tables based on the classification results.

[0080] Assume that all pixels to be classified in the color block belong to the same color category q m , when all pixels are classified, they can be split into the i-th m The pixel belongs to the color category q m and j mWhen the pixel belongs to the new color category Q+1, the above pixel distance table It can also be split into color categories q m The distance table composed of all pixels in The distance table T composed of all pixels in color category Q+1 Q+1 .

[0081] Step 7: Repeat the above steps until exiting to obtain the color classification result of the color block.

[0082] The color classification result of the color block includes the number of separable categories of the color block and the pixel point sequence contained in each category under the number of categories.

[0083] See also Figure 4 , shown as a distance-based image color block color classification device, comprising:

[0084] Image segmentation unit: divides the original image into image color blocks of a certain size according to a certain number of rows and columns;

[0085] Pixel distance calculation unit: calculates the distance between each pixel in the image color block segmented by the image segmentation unit according to the pixel value, and generates a pixel distance table corresponding to the color category of the image color block;

[0086] Pixel distance comparison unit: compares the distances between pixels of each color category of the image color block and obtains the maximum value in the pixel distance table;

[0087] Category and endpoint selection unit: selects the color category corresponding to the maximum value of the distance comparison unit between pixels and the two endpoints with the longest distance, and transmits the corresponding color category and the two endpoints with the longest distance to the pixel nearest classification unit;

[0088] Pixel point proximity classification unit: The two endpoints with the longest distance received are directly divided into two color categories, and other pixels in the color category are divided into corresponding color categories according to their distance from the endpoints. The distance table of the pixels after being split into two color categories is updated for the next classification.

[0089] The image color block color classification method proposed by the present invention is a preprocessing process that can be widely applied to various image processing algorithms.

[0090] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is limited by the appended claims and their equivalents.

Claims

1. A distance-based image color block classification method, characterized in that: include: Step 1: Segment the original image to obtain image color blocks with M rows and N columns; Step 2: Calculate the distance D between all pixels in the classified colors of each color block, and obtain the pixel distance table T. Suppose the number of classified colors is Q; Step 3: Find the existing pixel distance table T1~T Q The color category q corresponding to the maximum distance m and the corresponding pixel i m With j m ; Step 4: determine whether the maximum distance in the existing pixel distance table is greater than the set threshold. If so, proceed to step 5. If not, exit the classification process and obtain the color classification result of the color block. Step 5: Compare the qth m The remaining pixels in the color category are the two pixels i with the largest distance from each other. m With j m Distance and classification; Step 6: Split all pixels of the same color category into two color categories and two new pixel distance tables according to the classification results; Step 7: Repeat the above steps until exiting to obtain the color classification result of the color block.

2. The distance-based image color classification method according to claim 1, characterized in that: In step 2, if the color category is q, 1≤q≤Q, assuming that the i-th and j-th pixels both belong to the current color category q, the channel values ​​corresponding to the i-th and j-th pixels are R i =R(i / N,i%N) G i =G(i / N,i%N) B i =B(i / N,i%N) R j =R(j / N,j%N) G j =G(j / N,j%N) B j =B(j / N,j%N) Then the distance between the i-th and j-th pixels in the q-th class is defined as D q (i,j), the distance calculation method uses but is not limited to the following three: (1) Euclidean distance (2) Manhattan distance D q (i,j)=|R i -R j |+|G i -G j |+B i -B j | (3) Chebyshev distance D q (i,j)=max{|R i -R j |,|G i -G j |,|B i -B j |} In particular, when i=j, D q (i,j)=0 The distance D between all pixels of the current color category q in the color block q The pixel distance table composed of (i, j) is T q .

3. The distance-based image color block classification method according to claim 2, characterized in that: The step three includes: if the table In For all pixel distance table T q The maximum value in , then the color category to be split is the qth m Class, and the i m The pixel and the jth m The pixel is the qth m The two corresponding pixels in the cluster are the farthest apart.

4. The distance-based image color classification method according to claim 3, characterized in that: The fourth step comprises: Assume that the maximum allowable threshold is Threshold_D, if Then proceed to the next step for this table; if Then exit the classification process.

5. The distance-based image color block classification method according to claim 4, characterized in that: The step five comprises, in the q m In the color categories, select the kth pixel and compare the kth pixel with the i-th pixel. m pixels, the jth m The distance of pixels like Then the kth pixel and the jth pixel m Pixels are classified into the same color category; like Then the kth pixel and the i-th pixel m Pixels are classified into the same color category; All pixels in the table are classified into the i-th m pixel or jth m The color category to which the pixels belong.

6. The distance-based image color classification method according to claim 5, characterized in that: The step six comprises: Assume that all pixels to be classified in the color block belong to the same color category q m , when all pixels are classified, they can be split into the i-th m The pixel belongs to the color category q m and j m When the pixel belongs to the new color category Q+1, the above pixel distance table It can also be split into color categories q m The distance table composed of all pixels in The distance table T composed of all pixels in color category Q+1 Q+1 .

7. The distance-based image color classification method according to claim 6, characterized in that: In step seven, the color classification result of the color block includes the number of separable categories of the color block and the pixel point sequence included in each category under the number of categories.

8. A distance-based image color block classification device, using the distance-based image color block classification method according to any one of claims 1 to 7, characterized in that: include: Image segmentation unit: divides the original image into image color blocks of a certain size according to a certain number of rows and columns; Pixel distance calculation unit: calculates the distance between each pixel in the image color block segmented by the image segmentation unit according to the pixel value, and generates a pixel distance table corresponding to the color category of the image color block; Pixel distance comparison unit: compares the distances between pixels of each color category of the image color block and obtains the maximum value in the pixel distance table; Category and endpoint selection unit: selects the color category corresponding to the maximum value of the distance comparison unit between pixels and the two endpoints with the longest distance, and transmits the corresponding color category and the two endpoints with the longest distance to the pixel nearest classification unit; Pixel point proximity classification unit: The two endpoints with the longest distance received are directly divided into two color categories, and other pixels in the color category are divided into corresponding color categories according to their distance from the endpoints. The distance table of the pixels after being split into two color categories is updated for the next classification.