Image numbering method, device, computer equipment and medium

By dividing the pixel set in an image into sub-regions and determining the relationship between the central pixel and its neighboring pixels, the problem of cumbersome operation and low practicality of traditional image coloring methods is solved, achieving more accurate and efficient image numbering.

CN122223150APending Publication Date: 2026-06-16HUNAN SIJIU TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN SIJIU TECH CO LTD
Filing Date
2026-02-13
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Traditional image coloring methods are cumbersome and prone to errors, especially for non-professional users who find it difficult to accurately reproduce the original design intent. The numbering of existing technologies has low practicality.

Method used

The target image is divided into multiple pixel sets according to pixel value and position. The boundary pixel coordinates of each pixel set are determined, and the set is divided into multiple sub-regions based on density value. The coordinates and size of the number are determined by the judgment results of the center pixel and the judgment results of the neighboring pixels, and the number is added.

Benefits of technology

It improves the practicality of image numbering, especially in the case of long and thin patterns, enabling multiple numbering and enhancing the accuracy and efficiency of numbering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122223150A_ABST
    Figure CN122223150A_ABST
Patent Text Reader

Abstract

The application relates to a numbering method and device of an image, a computer device and a medium, which comprises the following steps: dividing each pixel in a target image into a plurality of pixel sets according to pixel values and positions; determining a first boundary pixel coordinate of each pixel set in a horizontal coordinate direction and a second boundary pixel coordinate in a vertical coordinate direction; dividing an image region corresponding to each pixel set into a plurality of sub-regions based on the first boundary pixel coordinate, the second boundary pixel coordinate and a density value of each pixel set, and determining a center pixel of each sub-region; determining the coordinate and numbering size of a to-be-added number in a to-be-numbered image according to a judgment result of whether the center pixel is a pixel in a target pixel set and a judgment result of whether a pixel in a first neighborhood of the center pixel is a pixel in the target pixel set, and adding the number, wherein the target pixel set is a pixel set to which a sub-region where the center pixel is located belongs, and the to-be-numbered image is composed of boundary pixel coordinates in each pixel set. The method can improve the practicability of numbering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image numbering technology, and in particular to an image numbering method, apparatus, computer device, and medium. Background Technology

[0002] With the development of digital image technology, color filling of images has become widespread in fields such as electronic painting software. Traditional color filling methods usually rely on the user's subjective judgment of colors or manually select colors through preset color palettes, which is cumbersome and prone to errors, especially for non-professional users, making it difficult to accurately reproduce the original design intent.

[0003] To improve the accuracy of the coloring process, existing technologies have attempted various methods for color filling in images, but all suffer from low practicality. For example, in patent application CN104765614A, each area to be filled is assigned a number, and areas with the same number are filled with the same color. This results in a situation where a large area to be filled or a narrow area has only one number, leading to low practicality of the numbering system. Summary of the Invention

[0004] Therefore, it is necessary to provide an image numbering method, apparatus, computer device, and medium that can improve practicality in response to the above-mentioned technical problems.

[0005] A method for numbering images, the method comprising:

[0006] S1. Divide each pixel in the target image into multiple pixel sets according to its pixel value and position;

[0007] S2. Determine the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set;

[0008] S3. Based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, the image region corresponding to each pixel set is divided into multiple sub-regions, and the center pixel of each sub-region is determined. The center pixel is the pixel at the center of the outer rectangle of the sub-region.

[0009] S4. Based on the judgment result of whether the center pixel is a pixel in the target pixel set and the judgment result of whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, determine the coordinates of the number to be added in the image to be numbered and the size of the number, and add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs. The image to be numbered is composed of the boundary pixel coordinates of each pixel set.

[0010] In one embodiment, step S4 includes:

[0011] Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, the first neighborhood is iteratively expanded with a preset step size until there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set or the size of the candidate neighborhood is the preset maximum size, then the expansion stops.

[0012] Based on the expansion result where the size of the expanded candidate neighborhood is a preset maximum size, the candidate neighborhood with the size of the preset maximum size is determined as the second neighborhood;

[0013] Based on the expansion result that there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set, the candidate neighborhood obtained in the previous expansion is determined as the second neighborhood;

[0014] The center coordinates of the second neighborhood are determined as the coordinates for adding the number, the size of the second neighborhood is determined as the size of the number, and the number is added to the image to be numbered corresponding to the target image.

[0015] In one embodiment, the method further includes:

[0016] Based on the judgment result that the center pixel is not in the target pixel set, and / or there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, traverse each pixel in the first neighborhood of the center pixel;

[0017] Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the first neighborhood of the center pixel is iteratively expanded with a preset step size until a first pixel that meets the filtering conditions is found, and the first pixel is taken as the new center pixel. The filtering conditions are that the currently judged pixel is a pixel in the target pixel set, and all pixels in the first neighborhood of the currently judged pixel are pixels in the target pixel set.

[0018] In one embodiment, the method further includes:

[0019] Based on the result that the size of the third neighborhood after the expansion of the first neighborhood of the center pixel is the preset maximum size and the first pixel is not found, the size of the first neighborhood is reduced and / or the density value is adjusted to obtain the first pixel that meets the filtering conditions.

[0020] In one embodiment, step S1 includes:

[0021] Determine the target image and the preset number of colors;

[0022] Based on the number of colors, a color quantization algorithm or clustering algorithm is used to simplify the colors of the determined target image to obtain a simplified image.

[0023] The RGB values ​​of each second pixel in the simplified image and the RGB values ​​of the neighboring pixels of the second pixel are determined, and target pixels that meet the target conditions are selected from the neighboring pixels; the target conditions include that the RGB value of the target pixel is the same as the RGB value of the second pixel and / or the difference between the RGB value of the target pixel and the RGB value of the second pixel is less than a preset pixel difference.

[0024] The second pixel and the target pixel are grouped into the same pixel set.

[0025] In one embodiment, step S2 includes:

[0026] The maximum and minimum horizontal coordinates and the maximum and minimum vertical coordinates of each pixel set are determined respectively in the horizontal coordinate direction; the maximum and minimum horizontal coordinates are the first boundary pixel coordinates, and the maximum and minimum vertical coordinates are the second boundary pixel coordinates.

[0027] In one embodiment, the formula for calculating the number of sub-regions into which each pixel set is divided in step S3 is as follows: ,in , , This represents the number of sub-regions along the horizontal axis. X represents the number of sub-regions along the vertical axis, where Density is the density value. max X is the maximum x-coordinate in the pixel set. min Y is the minimum x-coordinate in the pixel set. max Y is the maximum ordinate in the pixel set. min y is the minimum ordinate in the pixel set.

[0028] An image numbering device, the device comprising:

[0029] The pixel segmentation module is used to divide each pixel in the target image into multiple pixel sets according to its pixel value and position.

[0030] A boundary determination module is used to determine the first boundary pixel coordinates in the horizontal coordinate direction and the second boundary pixel coordinates in the vertical coordinate direction for each pixel set.

[0031] The region division module is used to divide the image region corresponding to each pixel set into multiple sub-regions based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, and to determine the center pixel of each sub-region, wherein the center pixel is the pixel at the center of the outer rectangle of the sub-region.

[0032] The numbering module is used to determine the coordinates of the number to be added in the image to be numbered and the size of the number based on the judgment result of whether the center pixel is a pixel in the target pixel set and the judgment result of whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, and to add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs, and the image to be numbered is composed of the boundary pixel coordinates of each pixel set.

[0033] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method described above.

[0034] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.

[0035] The aforementioned image numbering method, apparatus, computer equipment, and medium divide each pixel in the target image into multiple pixel sets according to pixel value and position. They determine the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set. Based on the first and second boundary pixel coordinates and a preset density value, they divide the image region corresponding to each pixel set into multiple sub-regions and determine the center pixel of each sub-region. Based on the judgment result of whether the center pixel is a pixel in the target pixel set and whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, they determine the coordinates and size of the number to be added in the image to be numbered, and then add the number. This allows for the division of extremely long and thin patterns in the target image into multiple pixel sets, enabling multiple numbering of the long and thin pattern and increasing the practicality of the numbering process. Attached Figure Description

[0036] Figure 1 This is a diagram illustrating the application environment of an image numbering method in one embodiment.

[0037] Figure 2 This is a flowchart illustrating an image numbering method in one embodiment;

[0038] Figure 3 This is a schematic diagram of the target image in one embodiment;

[0039] Figure 4 This is a simplified schematic diagram of clustered images in one embodiment;

[0040] Figure 5 This is a schematic diagram of the outline in one embodiment;

[0041] Figure 6 This is a schematic diagram of the numbering in one embodiment;

[0042] Figure 7 This is a structural block diagram of an image numbering device in one embodiment;

[0043] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0045] The image numbering method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 interacts with server 104 via a wired / wireless channel. A data storage system can store the data that server 104 needs to process. The server divides each pixel in the target image into multiple pixel sets according to its pixel value and position; the server determines the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set; based on the first and second boundary pixel coordinates and a preset density value, the server divides the image region corresponding to each pixel set into multiple sub-regions and determines the center pixel of each sub-region, where the center pixel is the pixel at the center of the bounding rectangle of the sub-region; based on the judgment result of whether the center pixel is a pixel in the target pixel set and whether the pixels in the first neighboring region of the center pixel are pixels in the target pixel set, the server determines the coordinates and size of the number to be added in the image to be numbered, and adds the number. The target pixel set is the pixel set to which the sub-region containing the center pixel belongs, and the image to be numbered is composed of the boundary pixel coordinates of each pixel set. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, etc. Server 104 can be a single server, a server cluster consisting of multiple servers, or a cloud computing center consisting of multiple servers.

[0046] In one embodiment, such as Figure 2 As shown, an image numbering method is provided, which can be applied to... Figure 1Taking server 104 as an example, the following steps are included:

[0047] S1. Divide each pixel in the target image into multiple pixel sets according to its pixel value and position;

[0048] In this context, all pixels within the same pixel set are pixels with matching pixel values ​​and adjacent positions. Matching pixel values ​​means that the pixel values ​​are identical or the difference between the pixel values ​​is less than a preset difference.

[0049] The target image can be of various styles, such as realistic, cartoon, abstract, or minimalist. For example, a target image like... Figure 3 As shown.

[0050] S2. Determine the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set;

[0051] The first boundary pixel coordinates refer to the maximum and / or minimum x-coordinates in the pixel set, and the second boundary pixel coordinates refer to the maximum and / or minimum y-coordinates in the pixel set.

[0052] S3. Based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, the image region corresponding to each pixel set is divided into multiple sub-regions, and the center pixel of each sub-region is determined. The center pixel is the pixel at the center of the bounding rectangle of the sub-region.

[0053] Here, the image region corresponding to the pixel set is the region composed of each pixel in the pixel set.

[0054] Based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value, the number of sub-regions after dividing the image region of each pixel set in the horizontal and vertical coordinate directions can be determined. Thus, the image region corresponding to each pixel set can be divided according to the number of sub-regions in the horizontal and vertical coordinate directions.

[0055] Each pixel set is divided into at least one sub-region.

[0056] S4. Based on the judgment result of whether the center pixel is a pixel in the target pixel set and whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, determine the coordinates and size of the number to be added in the image to be numbered, and add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs. The image to be numbered is composed of the boundary pixel coordinates of each pixel set.

[0057] Here, boundary pixel coordinates refer to the pixel coordinates located at the boundaries of a pixel set. The boundary pixel coordinates of each pixel set can be connected to form a closed region, and the closed regions formed by connecting the boundary pixel coordinates of all pixel sets together constitute the image to be numbered. The image to be numbered is not filled with any color. Further, based on the numbers added to the closed regions enclosed by the boundary pixel coordinates of each pixel set in the image to be numbered, and the colors associated with those numbers, the color to be filled in each closed region is determined.

[0058] The image numbering method described above divides each pixel in the target image into multiple pixel sets according to its pixel value and position. It then determines the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set. Based on the first and second boundary pixel coordinates and a preset density value, the image region corresponding to each pixel set is divided into multiple sub-regions. The center pixel of each sub-region is determined. Based on the judgment result of whether the center pixel is a pixel in the target pixel set and whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, the coordinates and size of the number to be added in the image are determined, and the number is added. This method can be used when the target image contains extremely long and thin patterns, dividing the pattern into multiple pixel sets and thus numbering the pattern multiple times, increasing the practicality of the numbering system.

[0059] In one embodiment, step S4 includes:

[0060] Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, the first neighborhood is iteratively expanded with a preset step size until there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set or the size of the candidate neighborhood is the preset maximum size, and then the expansion stops.

[0061] Based on the expansion result where the size of the expanded candidate neighborhood is the preset maximum size, the candidate neighborhood with the size of the preset maximum size is determined as the second neighborhood;

[0062] Based on the expansion result that there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set, the candidate neighborhood obtained in the previous expansion is determined as the second neighborhood.

[0063] The center coordinates of the second neighborhood are determined as the coordinates for adding the number, the size of the second neighborhood is determined as the size of the number, and the number is added to the image to be numbered corresponding to the target image.

[0064] The first neighborhood is rectangular in shape. The unexpanded first neighborhood has a preset minimum size. For example, the first neighborhood can be a 4-neighborhood, an 8-neighborhood, or other sizes, such as a 24-neighborhood. Size expansion extends the side length of the first neighborhood. For example, expanding the first neighborhood from a 4-neighborhood to an 8-neighborhood.

[0065] The first neighborhood is centered on the center pixel. Since the first neighborhood can be expanded by extending the top and left sides, the top and right sides, the bottom and left sides, or the bottom and right sides, the second neighborhood may or may not be centered on the center pixel.

[0066] The specific value of the number is determined based on the pixel set to which the center pixel belongs and the color number mapping library. Specifically, the color number mapping library is obtained, which includes various colors and associated numbers; the target color corresponding to the pixel set to which the center pixel belongs is determined; the number associated with the target color is found in the color number mapping library, and this associated number is identified as the number to be added. The pixel set to which the center pixel belongs is the pixel set corresponding to the sub-region where the center pixel is located. For example, if pixel set 1 is divided into sub-regions, and sub-region A is included, the pixel set to which the center pixel of sub-region A belongs is pixel set 1.

[0067] Furthermore, the minimum preset step size is The maximum preset step size is , To preset the maximum size, This sets the minimum preset size. The minimum preset step size is set to [value]. This ensures that a second neighborhood with a preset maximum size can be found, by setting the maximum value of the preset step size. This ensures that the coordinates of the added number are close to the center of the sub-region.

[0068] In this embodiment, by determining the center coordinates of the second neighborhood as the coordinates for adding the number, and determining the size of the second neighborhood as the size of the number, it can be ensured that the added number will not be added to the closed area enclosed by the boundary pixel coordinates of another pixel set.

[0069] In one embodiment, the method further includes:

[0070] Based on the judgment result that the center pixel is not in the target pixel set, and / or there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, traverse each pixel in the first neighborhood of the center pixel;

[0071] Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the first neighborhood of the center pixel is iteratively expanded with a preset step size until the first pixel that meets the filtering conditions is found. The filtering conditions are that the currently judged pixel is a pixel in the target pixel set, and all pixels in the first neighborhood of the currently judged pixel are pixels in the target pixel set.

[0072] Here, the first pixel is the pixel found in the first neighborhood of the center pixel. The expanded first neighborhood can also be understood as the first neighborhood. The first neighborhood of the first pixel is square. The first neighborhood of the first pixel can be a 4-neighborhood, an 8-neighborhood, or a neighborhood of other sizes, such as a 24-neighborhood.

[0073] Specifically, based on the judgment that the center pixel is not in the target pixel set, each pixel in the first neighborhood of the center pixel is traversed. Based on the judgment that there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, each pixel in the first neighborhood of the center pixel is traversed. Based on the judgments that the center pixel is not in the target pixel set and that there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, each pixel in the first neighborhood of the center pixel is traversed.

[0074] In this embodiment, based on the judgment result that the center pixel is not in the target pixel set and / or there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, each pixel in the first neighborhood of the center pixel is traversed. Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the first neighborhood of the center pixel is iteratively expanded with a preset step size until the first pixel that meets the filtering conditions is found. This can ensure that the subsequent numbering operation is performed within the corresponding sub-region and avoid out-of-bounds numbering.

[0075] In one embodiment, step S1 includes:

[0076] Determine the target image and the preset number of colors;

[0077] Based on the number of colors, color quantization algorithms or clustering algorithms are used to simplify the colors of a given target image to obtain a simplified image.

[0078] Determine the RGB values ​​of each second pixel in the simplified image, and the RGB values ​​of the adjacent pixels of the second pixel, and filter the target pixels that meet the target conditions from the adjacent pixels; the target conditions include that the RGB value of the target pixel is the same as the RGB value of the second pixel and / or the difference between the RGB value of the target pixel and the RGB value of the second pixel is less than a preset pixel difference;

[0079] The second pixel and the target pixel are grouped into the same pixel set.

[0080] The simplified image uses a preset number of colors. Color quantization algorithms include, but are not limited to, uniform quantization, octree, and median slicing. Clustering algorithms include, but are not limited to, K-Means clustering, Mean Shift clustering, and Mini-Batch K-Means clustering.

[0081] Each pixel in a simplified image is called a second pixel. A simplified image is as follows: Figure 4 As shown. Figure 5 The contour map is composed of the boundary pixel coordinates of each pixel set, i.e., the image to be numbered.

[0082] In this embodiment, by determining the target image and the preset number of colors, a color quantization algorithm or clustering algorithm is used to simplify the target image based on the number of colors, resulting in a simplified image. This reduces image complexity, thereby reducing the amount of data and computational complexity in subsequent processing. By determining the RGB values ​​of each second pixel in the simplified image and the RGB values ​​of the adjacent pixels of the second pixel, target pixels that meet the target conditions are selected from the adjacent pixels. The second pixels and target pixels are then grouped into the same pixel set, realizing a leap from raw pixels to structured regions. This improves the efficiency and accuracy of subsequent processing and lays the foundation for automated numbering.

[0083] In one embodiment, step S2 includes:

[0084] Determine the maximum and minimum x-coordinates of each pixel set in the x-coordinate direction and the maximum and minimum y-coordinates in the y-coordinate direction; the maximum and minimum x-coordinates are the coordinates of the first boundary pixels, and the maximum and minimum y-coordinates are the coordinates of the second boundary pixels.

[0085] In this embodiment, by determining the maximum and minimum horizontal coordinates and the maximum and minimum vertical coordinates of each pixel set in the horizontal direction, the number of sub-regions in the horizontal direction and the number of sub-regions in the vertical direction of each pixel set can be calculated based on the maximum and minimum horizontal coordinates.

[0086] In one embodiment, the formula for calculating the number of sub-regions in step S3 is as follows: ,in , , This represents the number of sub-regions along the horizontal axis. X represents the number of sub-regions along the vertical axis, where Density is the density value. max X is the maximum x-coordinate in the pixel set. minY is the minimum x-coordinate in the pixel set. max Y is the maximum ordinate in the pixel set. min y is the minimum ordinate in the pixel set.

[0087] Wherein, the x-coordinate of the first sub-region in the x-axis direction is X. min and X min +round((X max -X min ) / Div x The ordinate of the first sub-region along the vertical axis is Y. min and Y min +round((Y) max -Y min ) / Div y ).

[0088] Furthermore, if and If the value is less than 1, the image region corresponding to the pixel set will not be divided.

[0089] In this embodiment, by using , Calculate the number of sub-regions so that the number of sub-regions is not a fixed value, but a dynamic value that can be dynamically adjusted according to the density value, thereby improving the rationality and adaptability of the division.

[0090] In one embodiment, the method further includes:

[0091] If the size of the third neighborhood expanded from the first neighborhood of the center pixel is the preset maximum size, and no first pixel is found, the size of the first neighborhood is reduced and / or the density value is adjusted to obtain the first pixel that meets the filtering conditions.

[0092] Furthermore, the process of reducing the size of the first neighborhood of the center pixel to obtain the first pixel that meets the filtering criteria, based on the result that the size of the third neighborhood after expanding the first neighborhood of the center pixel is the preset maximum size and no first pixel is found, includes:

[0093] The first neighborhood after size reduction is taken as the fourth neighborhood. Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the fourth neighborhood of the center pixel are pixels in the target pixel set, the center pixel is determined to be the first pixel.

[0094] Based on the judgment result that the center pixel is not in the target pixel set, and / or there is at least one pixel in the fourth neighborhood that does not belong to the target pixel set, traverse each pixel in the fourth neighborhood of the center pixel; based on the judgment result that none of the pixels in the fourth neighborhood of the center pixel meet the filtering conditions, iterate and expand the fourth neighborhood with a preset step size until the first pixel that meets the filtering conditions is found.

[0095] Furthermore, the process of adjusting the density value to obtain the first pixel that meets the filtering criteria, based on the result that the size of the third neighborhood after the expansion of the first neighborhood is the preset maximum size and no first pixel is found, includes:

[0096] Using the adjusted density value as the already adjusted density value, based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the already adjusted density value of each pixel set, the image region corresponding to each pixel set is divided into multiple sub-regions, and the center pixel of each sub-region is determined.

[0097] Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, the center pixel is determined as the first pixel;

[0098] Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the first neighborhood is iteratively expanded with a preset step size until the first pixel that meets the filtering conditions is found.

[0099] Furthermore, the process of reducing the size of the first neighborhood of the center pixel and adjusting the density value based on the result that the size of the third neighborhood after the expansion of the first neighborhood is the preset maximum size and no first pixel is found, in order to obtain the first pixel that meets the screening conditions, includes:

[0100] Using the first neighborhood after size reduction as the fourth neighborhood, and the adjusted density value as the adjusted density value, the image region corresponding to each pixel set is divided into multiple sub-regions based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the adjusted density value of each pixel set, and the center pixel of each sub-region is determined.

[0101] Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the fourth neighborhood of the center pixel are pixels in the target pixel set, the center pixel is determined as the first pixel.

[0102] Based on the judgment result that none of the pixels in the fourth neighborhood of the center pixel meet the filtering conditions, the fourth neighborhood of the center pixel is iteratively expanded with a preset step size until the first pixel that meets the filtering conditions is found.

[0103] In this embodiment, by reducing the size of the first neighborhood and / or adjusting the density value based on the result that the size of the third neighborhood after the expansion of the first neighborhood is the preset maximum size and no first pixel is found, the first pixel can be obtained, thus avoiding exceeding the boundary when adding numbers later.

[0104] In one embodiment, if the first pixel is not found even after reducing the size of the first neighborhood and / or adjusting the density value, the sub-region where the center pixel is located is not numbered.

[0105] This application also provides an application scenario in which the above-described image numbering method is applied. Specifically, the image numbering method is applied in this scenario as follows:

[0106] The server determines the target image and the preset number of colors, and uses the colorReduce method from the OpenCV library to reduce the number of colors in the target image, resulting in a simplified image. The server starts traversing from the top-left pixel (0,0) of the simplified image, recording the RGB values ​​of pixel (0,0) and the RGB values ​​of its neighboring pixels. It then selects target pixels from the neighboring pixels whose RGB values ​​are identical or approximately identical to those of pixel (0,0). Pixel (0,0) and the target pixels are grouped into the same pixel set, until the server reaches the bottom-right pixel of the simplified image, resulting in multiple pixel sets.

[0107] The server filters for the largest x-coordinate X in each pixel set. max Minimum x-coordinate min Maximum ordinate Y max Minimum ordinate Y min The server uses a pre-set density value (Density) and a maximum x-coordinate (X). max Minimum x-coordinate min Maximum ordinate Y max Minimum ordinate Y min The number of sub-regions along the horizontal and vertical axes of the image region for each pixel set is calculated. Based on the calculated number of sub-regions for each pixel set, each pixel set is divided into multiple sub-regions. Specifically, the X-axis region of the image region corresponding to each pixel set is divided into multiple sub-regions. max and X min The regions between are divided into average segments. Each sub-region will have Y max and Y min The regions between are divided into average segments. Each sub-region is further divided into sub-regions. The server determines the center pixel of each sub-region and, based on the judgment that the center pixel is a pixel in the target pixel set and that the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, it iteratively expands the first neighborhood with a preset step size until there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set or the size of the candidate neighborhood is the preset maximum size, at which point the expansion stops. Based on the expansion result that the size of the expanded candidate neighborhood is the preset maximum size, the candidate neighborhood with the size of the preset maximum size is determined as the second neighborhood. Based on the expansion result that there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set, the candidate neighborhood obtained in the previous expansion is determined as the second neighborhood. The center coordinates of the second neighborhood are determined as the coordinates for adding a number, the size of the second neighborhood is determined as the size of the number, and the number is added to the image to be numbered corresponding to the target image.

[0108] The server iterates through all pixels in the first neighborhood of the center pixel based on the judgment result that the center pixel is not in the target pixel set and / or there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set. Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the server iterates and expands the first neighborhood of the center pixel with a preset step size until a first pixel that meets the filtering conditions is found, and the first pixel is taken as the new center pixel. The filtering conditions are that the currently judged pixel is a pixel in the target pixel set and all pixels in the first neighborhood of the currently judged pixel are pixels in the target pixel set.

[0109] For each pixel set The above operation is performed on the center pixels of each sub-region to obtain the number of the entire image to be numbered, such as... Figure 6 As shown.

[0110] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0111] Based on the same inventive concept, this application also provides an image numbering device for implementing the image numbering method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in the one or more image numbering device embodiments provided below can be found in the limitations of the image numbering method described above, and will not be repeated here.

[0112] In one embodiment, such as Figure 7 As shown, an image numbering device is provided, comprising:

[0113] The pixel segmentation module is used to divide each pixel in the target image into multiple pixel sets according to its pixel value and position.

[0114] A boundary determination module is used to determine the first boundary pixel coordinates in the horizontal coordinate direction and the second boundary pixel coordinates in the vertical coordinate direction for each pixel set.

[0115] The region division module is used to divide the image region corresponding to each pixel set into multiple sub-regions based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, and to determine the center pixel of each sub-region, wherein the center pixel is the pixel at the center of the outer rectangle of the sub-region.

[0116] The numbering module is used to determine the coordinates of the number to be added in the image to be numbered and the size of the number based on the judgment result of whether the center pixel is a pixel in the target pixel set and the judgment result of whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, and to add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs, and the image to be numbered is composed of the boundary pixel coordinates of each pixel set.

[0117] Each module in the aforementioned image numbering device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0118] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores various types of data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements an image numbering method.

[0119] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0120] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0121] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0122] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0123] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0124] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0125] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for numbering images, characterized in that, The method includes: S1. Divide each pixel in the target image into multiple pixel sets according to its pixel value and position; S2. Determine the first boundary pixel coordinates in the horizontal direction and the second boundary pixel coordinates in the vertical direction for each pixel set; S3. Based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, the image region corresponding to each pixel set is divided into multiple sub-regions, and the center pixel of each sub-region is determined. The center pixel is the pixel at the center of the outer rectangle of the sub-region. S4. Based on the judgment result of whether the center pixel is a pixel in the target pixel set and the judgment result of whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, determine the coordinates of the number to be added in the image to be numbered and the size of the number, and add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs. The image to be numbered is composed of the boundary pixel coordinates of each pixel set.

2. The method according to claim 1, characterized in that, Step S4 includes: Based on the judgment result that the center pixel is a pixel in the target pixel set and the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, the first neighborhood is iteratively expanded with a preset step size until there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set or the size of the candidate neighborhood is the preset maximum size, then the expansion stops. Based on the expansion result where the size of the expanded candidate neighborhood is a preset maximum size, the candidate neighborhood with the size of the preset maximum size is determined as the second neighborhood; Based on the expansion result that there are pixels in the expanded candidate neighborhood that do not belong to the target pixel set, the candidate neighborhood obtained in the previous expansion is determined as the second neighborhood; The center coordinates of the second neighborhood are determined as the coordinates for adding the number, the size of the second neighborhood is determined as the size of the number, and the number is added to the image to be numbered corresponding to the target image.

3. The method according to claim 2, characterized in that, The method further includes: Based on the judgment result that the center pixel is not in the target pixel set, and / or there is at least one pixel in the first neighborhood of the center pixel that does not belong to the target pixel set, traverse each pixel in the first neighborhood of the center pixel; Based on the judgment result that none of the pixels in the first neighborhood of the center pixel meet the filtering conditions, the first neighborhood of the center pixel is iteratively expanded with a preset step size until a first pixel that meets the filtering conditions is found, and the first pixel is taken as the new center pixel. The filtering conditions are that the currently judged pixel is a pixel in the target pixel set, and all pixels in the first neighborhood of the currently judged pixel are pixels in the target pixel set.

4. The method according to claim 3, characterized in that, The method further includes: Based on the result that the size of the third neighborhood after the expansion of the first neighborhood of the center pixel is the preset maximum size and the first pixel is not found, the size of the first neighborhood is reduced and / or the density value is adjusted to obtain the first pixel that meets the filtering conditions.

5. The method according to claim 1, characterized in that, Step S1 includes: Determine the target image and the preset number of colors; Based on the number of colors, a color quantization algorithm or clustering algorithm is used to simplify the colors of the determined target image to obtain a simplified image. The RGB values ​​of each second pixel in the simplified image and the RGB values ​​of the neighboring pixels of the second pixel are determined, and target pixels that meet the target conditions are selected from the neighboring pixels; the target conditions include that the RGB value of the target pixel is the same as the RGB value of the second pixel and / or the difference between the RGB value of the target pixel and the RGB value of the second pixel is less than a preset pixel difference. The second pixel and the target pixel are grouped into the same pixel set.

6. The method according to claim 1, characterized in that, Step S2 includes: The maximum and minimum horizontal coordinates and the maximum and minimum vertical coordinates of each pixel set are determined respectively in the horizontal coordinate direction; the maximum and minimum horizontal coordinates are the first boundary pixel coordinates, and the maximum and minimum vertical coordinates are the second boundary pixel coordinates.

7. The method according to claim 6, characterized in that, The formula for calculating the number of sub-regions into which each pixel set is divided in step S3 is as follows: ,in , , This represents the number of sub-regions along the horizontal axis. X represents the number of sub-regions along the vertical axis, where Density is the density value. max X is the maximum x-coordinate in the pixel set. min Y is the minimum x-coordinate in the pixel set. max Y is the maximum ordinate in the pixel set. min y is the minimum ordinate in the pixel set.

8. An image numbering device, characterized in that, The device includes: The pixel segmentation module is used to divide each pixel in the target image into multiple pixel sets according to its pixel value and position. A boundary determination module is used to determine the first boundary pixel coordinates in the horizontal coordinate direction and the second boundary pixel coordinates in the vertical coordinate direction for each pixel set. The region division module is used to divide the image region corresponding to each pixel set into multiple sub-regions based on the first boundary pixel coordinates, the second boundary pixel coordinates, and the preset density value of each pixel set, and to determine the center pixel of each sub-region, wherein the center pixel is the pixel at the center of the outer rectangle of the sub-region. The numbering module is used to determine the coordinates of the number to be added in the image to be numbered and the size of the number based on the judgment result of whether the center pixel is a pixel in the target pixel set and the judgment result of whether the pixels in the first neighborhood of the center pixel are pixels in the target pixel set, and to add the number. The target pixel set is the pixel set to which the sub-region where the center pixel is located belongs, and the image to be numbered is composed of the boundary pixel coordinates of each pixel set.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Color filling processing method and device

    CN104765614A