Image texture extraction method, device and computer readable storage medium
By decomposing an image into multiple layers and using a window frame mask to extract texture information, the method overcomes the shortcomings of traditional edge detection algorithms in texture information extraction, achieving higher completeness and fineness in texture information extraction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 张国流
- Filing Date
- 2022-03-24
- Publication Date
- 2026-07-24
Smart Images

Figure CN115965671B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image texture extraction method, apparatus, and computer-readable storage medium. Background Technology
[0002] Edge and texture extraction plays a crucial role in both human and computer vision. Texture extraction (edge detection) refers to the process of extracting target textures from images containing both the target and the background, ignoring background and noise interference, using specific techniques and methods. Currently, traditional texture extraction methods utilize conventional edge detection operators to detect edge information with significant grayscale changes in images. Since traditional edge detection techniques primarily use grayscale as the detection index and often require converting complex images to grayscale before edge detection processing, the output results are often monotonous, with highly homogenized edge information, making further subdivision difficult. Furthermore, because traditional edge detection algorithms only respond well to peak grayscale changes, they often only perform well on strong textures, while performing poorly on medium or weak textures, losing a significant amount of subtle but equally important detail information in the image. All of these factors contribute to the poor performance of traditional edge detection algorithms in terms of both the completeness and precision of texture information extraction. Summary of the Invention To address the aforementioned problems, the present invention aims to provide an image texture extraction method, apparatus, and computer-readable storage medium, which can effectively improve the completeness and precision of image texture extraction.
[0003] In a first aspect, embodiments of the present invention provide an image texture extraction method, comprising: The color value of each pixel in the target image is converted to a base, resulting in a digital array for each pixel; the base of the color value of the converted pixel is lower than the base of the color value of the pixel before conversion. Based on the digital array, the target image is decomposed into several layers; Texture information is extracted for each layer using a window frame mask to obtain a sub-texture map for each layer; All the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image.
[0004] As an improvement to the above scheme, the step of converting the color value of each pixel in the target image into a number array includes: The color values of each pixel in the target image are converted to N-ary to obtain a digital array for each pixel; The color level values of the R, G, and B color channels of each pixel are represented in N-ary form. Therefore, the RGB value of each pixel is represented as a 3×M-bit number array. Here, N-ary is less than the current base of the color value, and M represents the number of bits corresponding to the maximum color level value of the color channel in N-ary.
[0005] As an improvement to the above scheme, the step of converting the color values of each pixel in the target image into an N-ary representation to obtain a digital array for each pixel includes: The color values of each pixel in the target image are converted into a number system to obtain a 3×M-bit digital array for each pixel; Then, based on the digital array, the target image is decomposed into several layers, including: Based on the digital array of each pixel, the bits of each color channel in all pixels are clustered and merged into a single layer.
[0006] As an improvement to the above solution, the step of extracting texture information for each layer using a window frame mask to obtain a sub-texture map for each layer includes: Each layer is covered using the window frame mask; wherein, the window frame mask is composed of a plurality of window frames; For each layer, at least two contrast groups are used to extract the texture of the layer area where each window frame is located, so as to obtain the texture information of the layer area where each window frame is located; wherein, each contrast group consists of two detection points on opposite sides of the window frame; The texture information of all window frames in the window frame mask is stitched together to obtain the sub-texture map of the corresponding layer.
[0007] As an improvement to the above scheme, a first comparison group and a second comparison group are set on the boundary of each window frame, wherein the angle between the line connecting the two detection points in the first comparison group and the line connecting the two detection points in the second comparison group is 360° / 2n, where n represents the number of comparison groups; Then, for each window frame, at least two pairs of contrast groups are used to extract the texture of its layer area to obtain the texture information of the layer area where each window frame is located, including: Extract the layer pixel values of the detection points in the first comparison group and the second comparison group respectively, and perform numerical comparison; When the two detection points of the first comparison group have the same value and the two detection points of the second comparison group have the same value, it is determined that there is no texture between the first comparison group and the second comparison group, and no color filling process is performed. When the two detection points in the first comparison group have different values and the two detection points in the second comparison group have the same value, it is determined that there is a texture in the first comparison group and no texture in the second comparison group; the window frame is divided into two according to the vertical line of the first comparison group, and the half of the window frame where the detection point with a value of 1 in the first comparison group is located is filled with color, while the other half is not filled with color. When the two detection points of the first comparison group are different and the two detection points of the second comparison group are different, it is determined that there is a common texture between the first comparison group and the second comparison group. The window frame is divided into two parts by the vertical line of any two detection points of the four detection points of the first comparison group and the second comparison group that are different from each other. The half of the window frame containing the two detection points with a value of 1 is filled with color, and the half containing the two detection points with a value of 0 is not filled with color. The fill color of the window frame is the texture information of the corresponding window frame.
[0008] As an improvement to the above solution, the step of stitching together the texture information of all window frames in the window frame mask to obtain the sub-texture map of the corresponding layer includes: After each window frame completes the color filling process for its area, the texture information of all window frames is merged according to their positions in the window frame mask to form a sub-texture map of the layer.
[0009] As an improvement to the above scheme, the step of weighting all the sub-texture maps to synthesize the total texture of the target image includes: All the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image.
[0010] As an improvement to the above solution, the method further includes: By setting the RGB value range, the overall texture map is filtered for texture color blocks to obtain the final texture map output result.
[0011] In a second aspect, embodiments of the present invention provide an image texture extraction device, comprising: The number system conversion module is used to convert the color value of each pixel in the target image into a number system, resulting in a digital array for each pixel; wherein the number system of the color value of the pixel after conversion is lower than the number system of the color value of the pixel before conversion. Layer decomposition module: used to decompose the target image into several layers according to the digital array; The sub-texture map extraction module is used to extract texture information from each of the layers using a window frame mask to obtain a sub-texture map for each layer. The total texture extraction module is used to superimpose the weights of all the sub-texture maps to synthesize the total texture map of the target image.
[0012] Thirdly, embodiments of the present invention provide an image texture extraction device, comprising: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the image texture extraction method as described in any one of the first aspects.
[0013] Fourthly, embodiments of the present invention provide a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the image texture extraction method as described in any one of the first aspects.
[0014] Compared with the prior art, the beneficial effects of the embodiments of the present invention are as follows: by converting the color value of each pixel in the target image into a base, a digital array of each pixel is obtained, and the target image is decomposed into several layers according to the digital array; texture information is extracted for each layer using a window frame mask to obtain a sub-texture map of each layer; all the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image; the present invention increases the number of layers of the target image decomposition by reducing the base of the color value of the pixels in the target image, thereby effectively improving the completeness and accuracy of image texture extraction. Attached Figure Description
[0015] To more clearly illustrate the technical solution of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart of an image texture extraction method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the exploded image provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the window frame mask provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the window frame relative to this detection point provided in an embodiment of the present invention; Figure 5 This is another schematic diagram of the window frame for this detection point provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of texture filling provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of layer merging provided in an embodiment of the present invention; Figure 8This is a schematic diagram of image texture information provided in an embodiment of the present invention; Figure 9 This is a schematic diagram of layer weight overlay provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of an image texture extraction device provided in an embodiment of the present invention; Figure 11 This is a schematic diagram of the structure of an image texture extraction device provided in an embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Please see Figure 1 This invention provides an image texture extraction method, which can be called the Multi-layer Grids Contralateral Opponent extraction method (MGCO), specifically including: S1: Convert the color value of each pixel in the target image to a base, resulting in a digital array for each pixel; wherein the base of the color value of the converted pixel is lower than the base of the color value of the pixel before conversion. Texture is essentially the difference in optical properties between two illuminated surfaces. Texture exists if and only if there is a color difference between the two surfaces. Therefore, texture can be detected by measuring the color difference between the two surfaces. Specifically, images can be represented using various color spaces, such as HSV, HSB, CMY, and L. a b In this invention, the RGB color space is used as an example to illustrate the process steps. However, in principle, the method implemented in this invention can be applied to extract texture information from an image using any other color space.
[0019] Furthermore, the step of converting the color value of each pixel in the target image into a number array includes: The color values of each pixel in the target image are converted to N-ary to obtain a digital array for each pixel; The color level values of the R, G, and B color channels of each pixel are represented in N-ary form. Therefore, the RGB value of each pixel is represented as a 3×M-bit number array. Here, N-ary is less than the current base of the color value, and M represents the number of bits corresponding to the maximum color level value of the color channel in N-ary.
[0020] In this embodiment of the invention, the color values of each pixel in the target image can be converted from decimal to N-ary (N < 10) to improve the layer separation of the image. For example, it can be converted to binary, ternary, quaternary, etc. The smaller the selected base, the more layers the target image can be decomposed into, thus resulting in higher texture extraction accuracy.
[0021] Further, the step of converting the color values of each pixel in the target image into an N-ary representation to obtain a digital array for each pixel includes: The color values of each pixel in the target image are converted into binary to obtain a 3×M-bit digital array for each pixel; In this embodiment of the invention, it is preferable to convert the decimal pixel color value into binary. Since the RGB color space consists of three color channels—red, green, and blue—each channel has an integer value in the range [0, 255], resulting in 256 color levels. That is, each color channel can be represented by 8 bits of binary. If all three color channels are represented in binary, then the RGB value of each pixel can be represented as a digital array consisting of 24 0 / 1 signals (3×8). Therefore, comparing the color values between two glossy surfaces can be understood in computer terms as comparing the values between two sets of 3×8 digital arrays. The difference between the two digital arrays is the texture value between the two glossy surfaces.
[0022] The embodiments of the present invention utilize the simplicity and clear contrast of binary signals to transform the task of recognizing complete texture information into a task adapted to computer language, enabling the computer to extract all texture information in the target image more easily and accurately.
[0023] For example, for a pixel with a color value of RGB (50, 120, 200), the binary number array corresponding to its color value is presented in the table below.
[0024]
[0025] in: R50=128×0+64×0+32×1+16×1+4×0+2×1+1×0; G120=128×0+64×1+32×1+16×1+4×1+2×0+1×0; B200=128×1+64×1+32×0+16×0+4×1+2×0+1×0; S2: Based on the digital array, the target image is decomposed into several layers; Furthermore, based on the binary conversion, according to the digital array of each pixel, the bits of each color channel in all pixels are clustered and merged into a layer, resulting in a total of 24 layers.
[0026] Each color channel's bit can generate one layer. The color value of each pixel is composed of three color channels: R, G, and B, each with 8 bits (0 / 1). Each bit is named according to its "channel + binary digit". For example, the 6th bit of the R channel is named R6, the 4th bit of the G channel is named G4, and so on. Each pixel contains 24 0 / 1 bits: R1~R8, G1~G8, and B1~B8. The bits of each color channel in all pixels are clustered and merged. For example, the R1 bits of all pixels are clustered and merged into one layer, the R2 bits of all pixels are clustered and merged into a second layer, and so on, resulting in 24 layers. Each layer has the same number of pixels as the original image, but the pixel values only have two values: 0 and 1.
[0027] Each layer is named using the digits that make up the layer; for example, a layer formed by clustering and merging the G5 digits of each pixel is called the G5 layer, and so on. Therefore, the 24 layers are layers R1~R8, G1~G8, B1~B8, etc. Figure 2 As shown.
[0028] S3: Extract texture information for each layer using a window frame mask to obtain a sub-texture map for each layer; Furthermore, all the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image.
[0029] Assigning weights to sub-textures: Sub-textures are assigned weights based on the binary digits in their names. The weight y is related to its binary digit n by the formula y = 2^(n-1). For example, the weight y(G5) of sub-texture G5 is 2^4 = 16. That is, the weight of sub-texture G5 is the green value 16.
[0030] All the sub-texture maps are superimposed according to their weights to form the overall texture map of the target image.
[0031] For example, the total texture map is obtained by weighting and superimposing the sub-texture maps corresponding to the 24 layers, such as... Figures 7-9 As shown. The resulting total texture map will depict the texture of the target image and visually represent the color difference value of each texture point using RGB values.
[0032] by Figure 4The principle of texture weight superposition within a window frame will be explained using an example. Figure 9 The RGB values on the left side of the window frame are 200, 90, and 20, while the RGB values on the right side are 210, 220, and 240. After weighting and superimposing the sub-texture maps corresponding to the 24 layers according to their weights, the total texture color difference between the left and right sides of the window frame is: R = layer R5 + layer R4 + layer R2 = -16 + 8 - 2 = -10; G = Layer G8 + Layer G3 + Layer G2 = -128 - 4 + 2 = -130; B = Layer B8 + Layer B7 + Layer B6 + Layer B3 = -128 - 64 - 32 + 4 = -220.
[0033] In this invention, the target image is divided into 24 layers based on the three channels R, G, and B of the binary digital array, each with 8 digits. Then, texture extraction is performed on each layer separately. After that, the sub-texture maps of each layer are weighted and superimposed to obtain the total texture map. This can effectively improve the accuracy of image texture extraction and ensure that the extracted texture has completeness and fineness.
[0034] In an optional embodiment, S3: Extracting texture information for each layer using a window frame mask to obtain a sub-texture map for each layer, including: Each layer is covered using the window frame mask; wherein, the window frame mask is composed of a plurality of window frames; For each layer, at least two contrast groups are used to extract the texture of the layer area where each window frame is located, so as to obtain the texture information of the layer area where each window frame is located; wherein, each contrast group consists of two detection points on opposite sides of the window frame; Specifically, points located on the window frame boundary are selected as detection points to detect the layer pixel values at those points, and two detection points on opposite sides of the window frame are used as a pair of comparison groups.
[0035] The texture information of all window frames in the window frame mask is stitched together to obtain the sub-texture map of the corresponding layer.
[0036] Furthermore, a first comparison group and a second comparison group are set at the boundary of each window frame, wherein the angle between the line connecting the two detection points in the first comparison group and the line connecting the two detection points in the second comparison group is 360° / 2n, where n represents the number of comparison groups; Then, for each window frame, at least two pairs of contrast groups are used to extract the texture of its layer area to obtain the texture information of the layer area where each window frame is located, including: Extract the layer pixel values of the detection points in the first comparison group and the second comparison group respectively, and perform numerical comparison; When the two detection points of the first comparison group have the same value and the two detection points of the second comparison group have the same value, it is determined that there is no texture between the first comparison group and the second comparison group, and no color filling process is performed. When the two detection points in the first comparison group have different values and the two detection points in the second comparison group have the same value, it is determined that there is a texture in the first comparison group and no texture in the second comparison group; the window frame is divided into two according to the vertical line of the first comparison group, and the half of the window frame where the detection point with a value of 1 in the first comparison group is located is filled with color, while the other half is not filled with color. When the two detection points of the first comparison group are different and the two detection points of the second comparison group are different, it is determined that there is a common texture between the first comparison group and the second comparison group. The window frame is divided into two parts by the vertical line of any two detection points of the four detection points of the first comparison group and the second comparison group that are different from each other. The half of the window frame containing the two detection points with a value of 1 is filled with color, and the half containing the two detection points with a value of 0 is not filled with color. The fill color of the window frame is the texture information of the corresponding window frame.
[0037] In this embodiment of the invention, the window frame mask (opposite-side antagonistic window frame mask) is composed of several window frames of a custom size. For example, in this embodiment, the window frame is set to a size of 3×3 pixels. Therefore, for an original target image of 11x11 pixels, each layer is covered by a mask composed of 5x5 window frames. Thus, each window frame covers a 3x3 area of the image, a total of 9 pixels. Figure 3 As shown.
[0038] Window frame structure: such as Figure 4 and Figure 5 As shown, each window frame has at least two contrast groups. The feature points of each contrast group are: 1) A contrast group consists of two detection points located on the window frame boundary, symmetrical about the midpoint and located on opposite sides of the window frame; 2) The angle between the orientations of the two contrast groups is 360° / 2n, where n represents the number of contrast groups. Taking the setting of the first contrast group A and the second contrast group B as an example, the extraction of texture information of the window frame is explained: Texture recognition: Extract the values of the pixels where the detection points are located in comparison groups A and B respectively, and compare the values; if the two detection points in comparison groups A and B have the same value (both are 0 or both are 1), it is determined that there is no texture between comparison groups A and B; if the two detection points in comparison groups A or B have different values (one is 0 and the other is 1), it is determined that there is texture between comparison groups A and B. Texture extraction: The window frame is simultaneously monitored by four detection points (comparison groups A and B), which extract texture from the covered pixel area. Based on the different detection results of comparison groups A and B, the following texture results are output: 1) If the two detection points in comparison group A have the same value, and the detection points in comparison group B also have the same value: the window frame has no texture and is not filled with color. 2) If the detection points in comparison group A have different values and the detection points in comparison group B have the same value: Divide the window frame in half along the vertical line of comparison group A, fill the half of the window frame containing the detection point with a value of 1 in comparison group A with color, and leave the other half uncolored. 3) If the detection points in comparison group A have the same value, and the detection points in comparison group B have different values: Divide the window frame in half along the vertical line of comparison group B, fill the half of the window frame containing the detection point with a value of 1 in comparison group B with color, and leave the other half uncolored. 4) If the detection points of comparison group A and comparison group B have different values: the window frame is divided in half by the perpendicular line of any two detection points with different values among the four detection points. The half of the window frame containing the two detection points with a value of 1 is filled with color, and the other half is not filled with color. For example, suppose comparison group A is horizontally oriented and comparison group B is vertically oriented.
[0039] When the detection points in comparison group A and comparison group B have the same value, it is determined that there is no texture inside the window frame. When the detection points in comparison group A have different values and the detection points in comparison group B have the same value, the window frame is divided in two along the vertical line of comparison group A. At this time, if the left detection point of comparison group A is 1 and the right detection point is 0, the left half of the window frame is filled with color, while the right half remains colorless; if the value is 1 at the right detection point, the right side of the window frame is filled with color while the left side remains colorless. When the detection points in comparison group A have the same value, and the detection points in comparison group B have different values, the window frame is divided in two by the vertical line of comparison group B. At this time, if the upper detection point of group B is 1 and the lower detection point is 0, the upper half of the window frame is filled with color, while the lower half remains colorless; otherwise, the lower half is filled with color, while the upper half remains colorless. When both the A and B comparison groups have outlier detection points, the window frame is divided in two by the perpendicular bisector of the two outlier detection points. The half containing the two 1-value detection points is then filled with color. Specifically, if the left and top detection points are both 1-values, the upper left side of the window frame is filled with color, while the lower right side remains colorless; if the right and bottom detection points are both 1-values, the lower right side of the window frame is filled with color, while the lower left side remains colorless. Using the midpoints of the four sides of the window frame as four detection points, and grouping opposing pairs of detection points into a comparison group, the four detection points of the window frame can be divided into a vertical pair and a horizontal pair. The pixel values of each pair of detection points are compared. If any pair of detection points shows a difference in value, it indicates the presence of texture within the window frame; if neither pair shows a difference, then no texture exists within the window frame. For example, if the vertical pair of detection points on layer B1 has pixel values of 1 and 0, and the horizontal pair has pixel values of 0 and 0, then texture exists within that window frame. Conversely, if the vertical pair of detection points on layer B1 has pixel values of 0 and 0, and the horizontal pair has pixel values of 0 and 0, then no texture exists within that window frame. Specifically, the window frame can be divided in two by the vertical line between a pair of detection points with different pixel values. The half of the window frame containing pixel value 1 is filled with color, while the half containing pixel value 0 is left unfilled. The window frame is filled with color according to the color weight of the corresponding layer. The color weight depends on the color channel of the layer and the weight of its corresponding digit. The relationship between the weight y and its corresponding digit n is y = 2^(n-1). For example, the window frame of layer R1 is filled with color R=1, the window frame of layer G5 is filled with color G=16, and the window frame of layer B8 is filled with color B=128.
[0040] Considering that the texture within the window frame has not only color difference attributes but also orientation attributes, this invention also sets the included angle between two pairs to 360° / 2n, where n represents the number of detection points in the comparison group, to help determine the orientation of the texture. At this time, the color filling process for the window frame specifically includes: Taking layer R1 as an example, for each window frame in layer R1, a horizontal and a vertical contrast group are set. When only one pair of detection points has different values (one is 1 and the other is 0), the vertical line between the two pairs of detection points is used as the texture orientation. When both pairs of detection points have different values, the texture orientation is the diagonal of the window frame. There are 16 possible combinations for the two pairs of detection points. When both contrast groups have the same value (both are 0 or both are 1), it means there is no texture inside the window frame. The texture orientation inside the window frame is as follows: Figure 6 As shown, by setting multiple pairs of detection points to compare pixel values, the accuracy of texture orientation within the window frame can be improved.
[0041] In one optional embodiment, the step of stitching together the texture information of all window frames in the window frame mask to obtain a sub-texture map of the corresponding layer includes: After each window frame completes the color filling process for its area, the texture information of all window frames is merged according to their positions in the window frame mask to form a sub-texture map of the layer.
[0042] Sub-texture maps are named according to the layer they belong to. For example, the sub-texture map of layer R1 is called the R1 sub-texture map, and so on.
[0043] In this embodiment of the invention, the total texture map of the target image is the result of weighted superposition of textures within the frames of 24 layers. Since the texture direction of the frame in each layer has 8 possibilities, and the texture direction of the same frame may differ across different layers, the texture of the frames in the total texture map is often in a grid pattern after multiple layers are superimposed. Let the area of the frame be S, and the smallest color block unit of the total texture map be a right-angled triangle with an area of S / 8. Therefore, by extracting the texture of the target image in units of the frame, the resolution of the total texture map obtained in this invention is 8 times higher than that of the frame mask. When the frame is set to 3x3 pixels, the area of each pixel is S / 9, and the smallest resolvable color block area of the total texture map is S / 8. This suggests that the smallest color block area of the total texture map is 1.125 times that of a single pixel. Therefore, when the window frame is set to 3x3 pixels, the final overall texture map has a detail resolution close to that of a single pixel, which is similar to that of the original image, resulting in good integrity and fineness of the extracted texture information.
[0044] Traditional edge detection algorithms perform well on grayscale images with clear textures, but perform poorly on color images or natural environment images with weak or complex textures. In contrast, this invention demonstrates excellent texture extraction performance across various image types, including abstract images, scatter plots, black and white images, color images, images of people, environmental images, and so on.
[0045] Because the total texture map extracted by this invention not only retains all texture information but also visually represents the color difference characteristics of each texture point using RGB values, the textures of different objects in a target image can be separated by utilizing the principle that textures of the same object often have similar color difference characteristics (illustration required). It also has great application prospects in subsequent image processing techniques such as object separation and object recognition.
[0046] In an optional embodiment, the method further includes: By setting the RGB value range, the overall texture map is filtered for texture color blocks to obtain the final texture map output result.
[0047] This method allows for flexible filtering of the texture information in the overall texture map by setting the range of RGB values, thereby obtaining texture results with different degrees of simplification.
[0048] In this embodiment of the invention, the total texture map contains all texture information of the target image and displays the color difference characteristics of each texture point using intuitive RGB values. This gives the texture data contained in the total texture map a large potential for exploration and extremely simple operation. For example, by setting RGB value filtering conditions with different ranges, the total texture map can be filtered to obtain different texture results. For example, setting an RGB value filtering condition of R, G, B ∈ (8, 255] will filter out all texture color blocks with RGB values less than 8 simultaneously; or the RGB value filtering condition can be further improved by setting an RGB value filtering condition of R, G, B ∈ (16, 255] to filter out texture color blocks with RGB values less than 16 simultaneously, further simplifying the texture. By setting different RGB value filtering conditions, color blocks in the total texture map that do not meet the RGB value filtering conditions can be directly deleted. The image formed by the remaining color blocks is the result image with a clear texture direction, making the texture result customizable.
[0049] Meanwhile, since the total texture map of the present invention includes all texture information with color difference values from 1 to 255, it is possible to detect textures that are easily overlooked or difficult to identify even by the naked eye.
[0050] In other embodiments, a region-based ranking filtering method can also be used to filter the overall texture map, specifically including: The overall texture map is divided into i columns, j rows, and ixj sub-regions. Color patches are filtered independently within each sub-region. The filtering criteria are set to delete all color patches within the sub-region whose color difference value ranks below n%, and to filter out extremely weak textures with RGB values less than m. Here, n and m are preset constants.
[0051] By filtering the overall texture map using a regional ranking method, it can be ensured that each sub-region retains a certain amount of texture, so that the relatively strong textures in the weak texture area can be preserved. These relatively strong textures are often important textures that are difficult to extract due to interference from lighting and shadow environment, thus avoiding interference from ambient lighting on texture extraction.
[0052] Example 2 Please see Figure 10 This invention provides an image texture extraction device, comprising: The color conversion module 1 is used to convert the color value of each pixel in the target image into a number array for each pixel; wherein the number base of the color value of the pixel after conversion is lower than the number base of the color value of the pixel before conversion. Layer decomposition module 2: used to decompose the target image into several layers according to the digital array; The sub-texture map extraction module 3 is used to extract texture information from each of the layers using a window frame mask to obtain a sub-texture map for each layer. The total texture extraction module 4 is used to superimpose the weights of all the sub-texture maps to synthesize the total texture map of the target image.
[0053] In one optional embodiment, the color conversion module is used to convert the color values of each pixel of the target image into N-ary format to obtain a digital array for each pixel. In this context, the color level values of the R, G, and B channels of each pixel are represented in N-ary form, so the RGB value of each pixel is represented as a 3×M-bit digital array; where M represents the maximum color value of the pixel in N-ary form.
[0054] In one optional embodiment, the control conversion module includes... A binary conversion unit is used to convert the color values of each pixel in the target image into binary values to obtain a 3×8-bit digital array for each pixel. The layer decomposition module includes: The same number clustering unit is used to cluster and merge each number of each color channel in all pixels into a single layer based on the number array of each pixel.
[0055] In one optional embodiment, the sub-texture map extraction module includes: A layer texture extraction unit is used to cover each layer using the window frame mask; wherein, the window frame mask is composed of a plurality of window frames; The window frame texture extraction unit is used to extract texture information of the layer area where each window frame is located by using at least two contrast groups for each layer and each window frame. Each contrast group consists of two detection points on opposite sides of the window frame. The window frame splicing unit is used to splice the texture information of all window frames in the window frame mask to obtain the sub-texture map of the corresponding layer.
[0056] In one optional embodiment, a first comparison group and a second comparison group are provided at the boundary of each window frame, wherein the angle between the line connecting two detection points in the first comparison group and the line connecting two detection points in the second comparison group is 360° / 2n, where n represents the number of comparison groups; The window frame texture extraction unit includes: The numerical comparison unit is used to extract the layer pixel values of the detection points in the first comparison group and the second comparison group respectively, and perform numerical comparison. When the two detection points of the first comparison group have the same value and the two detection points of the second comparison group have the same value, it is determined that there is no texture between the first comparison group and the second comparison group, and no color filling process is performed. When the two detection points in the first comparison group have different values and the two detection points in the second comparison group have the same value, it is determined that there is a texture in the first comparison group and no texture in the second comparison group; the window frame is divided into two according to the vertical line of the first comparison group, and the half of the window frame where the detection point with a value of 1 in the first comparison group is located is filled with color, while the other half is not filled with color. When the two detection points of the first comparison group are different and the two detection points of the second comparison group are different, it is determined that there is texture between the first comparison group and the second comparison group. The fill color of the window frame is the texture information of the corresponding window frame.
[0057] In one optional embodiment, the window frame splicing unit is specifically used to merge the texture information of all window frames according to their positions in the window frame mask after each window frame has completed the color filling process of its area, thereby forming a sub-texture map of the layer.
[0058] In one optional embodiment, the total texture extraction module is used to superimpose the weights of all the sub-texture maps to synthesize the total texture map of the target image.
[0059] In an optional embodiment, the device further includes: The texture filtering module is used to filter the texture information of the overall texture map according to a preset RGB value range to obtain the final overall texture map. It should be noted that the implementation principle and technical effects of the embodiments of the present invention are the same as those of the first embodiment, and will not be repeated here.
[0060] Example 3 Please see Figure 11 This invention provides an image texture extraction device, including at least one processor 11, such as a CPU, at least one network interface 14 or other user interface 13, a memory 15, and at least one communication bus 12 for connecting and communicating between these components. The user interface 13 may optionally include a USB interface and other standard interfaces, or a wired interface. The network interface 14 may optionally include a Wi-Fi interface and other wireless interfaces. The memory 15 may include high-speed RAM, or it may also include non-volatile memory, such as at least one disk storage device. Optionally, the memory 15 may include at least one storage device located remotely from the aforementioned processor 11.
[0061] In some implementations, memory 15 stores executable modules or data structures, or subsets thereof, or extended sets thereof: Operating system 151 contains various system programs used to implement various basic business functions and handle hardware-based tasks; Program 152.
[0062] Specifically, processor 11 is used to call program 152 stored in memory 15 to execute the image texture extraction method described in the above embodiments, for example... Figure 1 Step S1 is shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, such as a binary conversion module.
[0063] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the image texture extraction device.
[0064] The image texture extraction device can be a computing device such as a VCU, ECU, or BMS. The image texture extraction device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that the schematic diagram is merely an example of an image texture extraction device and does not constitute a limitation on the image texture extraction device; it may include more or fewer components than illustrated, or combine certain components, or use different components.
[0065] The processor 11 may be a microcontroller unit (MCU), a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. The processor 11 is the control center of the image texture extraction device, connecting various parts of the entire image texture extraction device through various interfaces and lines.
[0066] The memory 15 can be used to store the computer program and / or modules. The processor 11 implements various functions of the image texture extraction device by running or executing the computer program and / or modules stored in the memory and calling the data stored in the memory. The memory 15 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 15 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0067] If the modules / units integrated into the image texture extraction device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0068] Example 4 This invention provides a computer-readable storage medium including a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to perform an image texture extraction method as described in any one of the first embodiments.
[0069] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0070] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. An image texture extraction method, characterized in that, include: The color value of each pixel in the target image is converted to a base, resulting in a numerical array for each pixel; the base of the color value of the converted pixel is lower than the base of the color value of the pixel before conversion. Based on the digital array, the target image is decomposed into several layers; Texture information is extracted for each layer using a window frame mask to obtain a sub-texture map for each layer; All the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image; The step of extracting texture information for each layer using a window frame mask to obtain a sub-texture map for each layer includes: Each layer is covered using the window frame mask; wherein, the window frame mask is composed of a plurality of window frame units; Each window frame uses at least two contrast groups to extract textures from its layer area to obtain texture information for each window frame's layer area; each contrast group consists of two detection points on opposite sides of the window frame; The texture information of all window frames in the window frame mask is stitched together to obtain the sub-texture map of the corresponding layer.
2. The image texture extraction method as described in claim 1, characterized in that, The step of converting the color value of each pixel in the target image into a number array includes: The color values of each pixel in the target image are converted to N-ary to obtain a digital array for each pixel; The color level values of the R, G, and B color channels of each pixel are represented in N-ary form. Therefore, the RGB value of each pixel is represented as a 3×M-bit number array. Here, N-ary is less than the current base of the color value, and M represents the number of bits corresponding to the maximum color level value of the color channel in N-ary.
3. The image texture extraction method as described in claim 2, characterized in that, The step of converting the color values of each pixel in the target image into an N-ary representation to obtain a digital array for each pixel includes: The color values of each pixel in the target image are converted into a number system to obtain a 3×M-bit digital array for each pixel; Then, based on the digital array, the target image is decomposed into several layers, including: Based on the digital array of each pixel, the bits of each color channel in all pixels are clustered and merged into a single layer.
4. The image texture extraction method as described in claim 1, characterized in that, A first comparison group and a second comparison group are set at the boundary of each window frame, wherein the angle between the line connecting the two detection points in the first comparison group and the line connecting the two detection points in the second comparison group is 360° / 2n, where n represents the number of comparison groups; Then, for each window frame, at least two pairs of contrast groups are used to extract the texture of its layer area to obtain the texture information of the layer area where each window frame is located, including: Extract the layer pixel values of the detection points in the first comparison group and the second comparison group respectively, and perform numerical comparison; When the two detection points of the first comparison group have the same value and the two detection points of the second comparison group have the same value, it is determined that there is no texture between the first comparison group and the second comparison group, and the window frame is not filled with color. When the two detection points in the first comparison group have different values and the two detection points in the second comparison group have the same value, it is determined that there is a texture in the first comparison group and no texture in the second comparison group; the window frame is divided into two according to the vertical line of the first comparison group, and the half of the window frame where the detection point with a value of 1 in the first comparison group is located is filled with color, while the other half is not filled with color. When the two detection points of the first comparison group are different and the two detection points of the second comparison group are different, it is determined that there is a common texture between the first comparison group and the second comparison group. The window frame is divided into two parts by the vertical line of any two detection points of the four detection points of the first comparison group and the second comparison group that are different from each other. The half of the window frame containing the two detection points with a value of 1 is filled with color, and the half containing the two detection points with a value of 0 is not filled with color. The color fill result of the window frame is the texture information of the corresponding window frame.
5. The image texture extraction method as described in claim 4, characterized in that, The step of stitching together the texture information of all window frames in the window frame mask to obtain the sub-texture map of the corresponding layer includes: After each window frame completes the color filling process for its area, the texture information of all window frames is merged according to their positions in the window frame mask to form a sub-texture map of the layer.
6. The image texture extraction method as described in claim 1, characterized in that, The step of weighting and superimposing all the sub-texture maps to synthesize the total texture map of the target image includes: All the sub-texture maps are weighted and superimposed to synthesize the total texture map of the target image.
7. The image texture extraction method as described in claim 1, characterized in that, Also includes: By setting the RGB value range, the overall texture map is filtered for texture color blocks to obtain the final texture map output result.
8. An image texture extraction device, characterized in that, include: The color conversion module is used to convert the color value of each pixel in the target image into a number array for each pixel; wherein the number base of the color value of the converted pixel is lower than the number base of the color value of the pixel before conversion. Layer decomposition module: used to decompose the target image into several layers according to the digital array; The sub-texture map extraction module is used to extract texture information from each of the layers using a window frame mask to obtain a sub-texture map for each layer. The total texture extraction module is used to superimpose the weights of all the sub-texture maps to synthesize the total texture map of the target image; The sub-texture map extraction module includes: A layer texture extraction unit is used to cover each layer using the window frame mask; wherein, the window frame mask is composed of a plurality of window frames; The window frame texture extraction unit is used to extract texture information of the layer area where each window frame is located by using at least two contrast groups for each layer and each window frame. Each contrast group consists of two detection points on opposite sides of the window frame. The window frame splicing unit is used to splice the texture information of all window frames in the window frame mask to obtain the sub-texture map of the corresponding layer.
9. An image texture extraction device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the image texture extraction method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the image texture extraction method as described in any one of claims 1-7.