Image region extraction method and device, storage medium and computer equipment
By constructing statistical regions of equivalent comparability, identifying texture units in image cards and constructing statistical regions of equivalent texture features, the problem of coupling between ROI texture characteristics and scene content in traditional sharpness calibration is solved, achieving accurate verification and efficient detection of camera imaging quality.
Patent Information
- Application Number
- CN202510825743.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-10-17
AI Technical Summary
In traditional sharpness calibration or verification tasks, the sharpness evaluation value of a fixed region of interest is strongly affected by the texture characteristics of the ROI and the scene content, resulting in incomparability of cross-module, cross-region, and cross-temporal data.
By constructing statistical regions with equivalent comparability, texture units in the image are identified, and the search strategy is dynamically adjusted according to the texture density type. Target texture units are searched at different preset test locations, constructing multiple statistical regions with equivalent texture features to adapt to different images and eliminate measurement bias.
It enables accurate verification of camera imaging quality under non-ideal conditions, eliminates measurement deviations across modules, regions, and time series, saves space and manpower costs, and balances high precision and high efficiency.
Smart Images

Figure CN120807876A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing and parameter measurement, and in particular to an image region extraction method and device, a storage medium and a computer device. BACKGROUND
[0002] In traditional sharpness calibration or other inspection tasks, when the scene is stable, the sharpness evaluation value is calculated for a fixed region of interest (ROI), and the focus extremum point is tracked by adjusting the lens motor position, so as to realize closed-loop control of the time sequence frame contrast. However, such evaluation values are affected by the strong coupling of ROI texture characteristics and scene content, resulting in non-comparability of cross-module, cross-region, and cross-time sequence data. SUMMARY
[0003] Therefore, the present application provides an image region extraction method and device, a storage medium and a computer device, which construct statistical regions with equivalent comparability, so that the statistical regions at different positions in a frame and even the corresponding regions across modules have objective comparability, thereby realizing accurate verification of camera imaging quality under non-ideal chart conditions.
[0004] According to a first aspect of the present application, an image region extraction method is provided, comprising:
[0005] identifying texture units in a chart image, wherein the chart image is obtained by a camera module under test shooting a chart, and the chart has regular textures, and adjacent texture units have different graphical features;
[0006] searching for target texture units corresponding to different preset test positions according to the texture density type of the chart;
[0007] constructing a plurality of statistical regions of the chart image according to the target texture units, so as to detect the camera module under test through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features.
[0008] According to a second aspect of the present application, an image region extraction device is provided, comprising:
[0009] a unit identification module configured to identify texture units in a chart image, wherein the chart image is obtained by a camera module under test shooting a chart, and the chart has regular textures, and adjacent texture units have different graphical features; and
[0010] searching for target texture units corresponding to different preset test positions according to the texture density type of the chart;
[0011] a region extraction module configured to construct a plurality of statistical regions of the graphic card image according to the target texture unit, so as to detect the camera module to be tested through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features.
[0012] According to a third aspect of the present application, a readable storage medium is provided, which stores a program or instructions, and the program or instructions are executed by a processor to implement the steps of the image region extraction method.
[0013] According to a fourth aspect of the present application, a computer device is provided, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the image region extraction method when executing the program.
[0014] According to the above technical solution, the complex texture in the graphic card image is converted into a plurality of smaller and regular pattern basic texture units according to different pattern features. The search strategy is dynamically adjusted according to the texture density type, and the target texture unit required is searched from the plurality of texture units at the same search strategy at different preset test positions. The statistical region of the preset test position is constructed by combining the target texture unit at the preset test position, so that the texture features in the statistical region at different positions in the image are highly consistent. Moreover, the plurality of statistical regions on the same image have the same shooting conditions. Therefore, the clarity, uniformity and other performance evaluation can be realized by using different statistical regions on an image, effectively eliminating the measurement deviation caused by cross-module, cross-region and cross-time sequence, and the existing repetitive texture graphic card resources of the calibration workstation can be reused, without the need to add independent workstations or customize special graphic cards, and without the need for ideal shooting environment. The system itself can extract multiple equivalent regions on the same image by matching the conditions, and then compensate the imaging deviation caused by the difference in shooting conditions, thereby significantly saving space and labor costs. In addition, the search strategy is adjusted according to the texture density type, which can adapt to different graphic cards and can balance the local detection of high precision and the image processing efficiency.
[0015] The above description is only a summary of the technical solutions of the present application. In order to more clearly understand the technical means of the present application, the content of the specification can be implemented, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS
[0016] The drawings described herein are used to provide further understanding of the present application, and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 An application environment schematic diagram of the image region extraction method provided by the embodiments of the present application is shown.
[0018] Figure 2 A flow diagram of the image region extraction method provided by the embodiments of the present application is shown;
[0019] Figure 3 A contour line diagram of the sparse type of card image provided by the embodiments of the present application is shown;
[0020] Figure 4 A figure unit diagram of the sparse type of card image provided by the embodiments of the present application is shown;
[0021] Figure 5 A texture unit diagram of the sparse type of card image provided by the embodiments of the present application is shown;
[0022] Figure 6 A figure unit aggregation logic diagram of the sparse type of card image provided by the embodiments of the present application is shown;
[0023] Figure 7 A target texture unit search logic diagram of the sparse type of card image provided by the embodiments of the present application is shown;
[0024] Figure 8 One of the statistical region diagrams of the sparse type of horizontal and vertical stripe card image provided by the embodiments of the present application is shown;
[0025] Figure 9 The second statistical region diagram of the sparse type of horizontal and vertical stripe card image provided by the embodiments of the present application is shown;
[0026] Figure 10 The statistical region diagram of the sparse type of chessboard card image provided by the embodiments of the present application is shown;
[0027] Figure 11 The statistical region diagram of the dense type of horizontal and vertical stripe card image provided by the embodiments of the present application is shown;
[0028] Figure 12 The statistical region diagram of the dense type of chessboard card image provided by the embodiments of the present application is shown;
[0029] Figure 13 A structure block diagram of the image region extraction device provided by the embodiments of the present application is shown;
[0030] Figure 14 An electronic structure diagram of the computer device provided by the embodiments of the present application is shown. DETAILED DESCRIPTION
[0031] Hereinafter, the application will be described in detail with reference to the drawings and examples. It should be noted that the examples in the application and the features in the examples can be combined with each other without conflict.
[0032] The embodiments of the application are described in detail below, examples of which are shown in the drawings, wherein the same or similar notations represent the same or similar elements or elements with the same or similar functions throughout. The examples described below by referring to the drawings are exemplary and are only used to explain the application, and cannot be interpreted as a limitation on the application.
[0033] Those skilled in the art can understand that the singular forms "a", "an" and "the" used herein also include the plural forms, unless specifically stated otherwise. It should be further understood that the use of the phrase "comprising" in the specification of the application means that the features, integers, steps, operations, elements and / or components exist, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we say an element is "connected" or "joined" to another element, it can be directly connected or joined to the other element, or there can be intermediate elements. In addition, "connected" or "joined" used herein can include wireless connection or wireless connection. The phrase "and / or" used herein includes all or any single unit and all combinations of the associated listed items.
[0034] Now, exemplary embodiments according to the present application will be described in more detail with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in various different forms, and should not be interpreted as being limited only to the embodiments set forth herein. It should be understood that these embodiments are provided so that the disclosure of the present application is complete and complete, and the concepts of these exemplary embodiments are fully conveyed to those skilled in the art.
[0035] The image region extraction method provided by the embodiments of the present application can be applied in the application environment (i.e. work station) of Figure 1 The work station includes a card 10, a magnifying mirror 60 (optional), a camera module to be tested 20, a clamp / structure limiting piece 50, a lower computer 40 and an upper computer 30. The lower computer 40 is a software and hardware system that can drive the camera imaging, such as a PCBA or a degree signal box with camera system software, which can integrate image processing algorithms and test algorithms and other functional algorithms. The upper computer 30 is installed with image processing software and test software to facilitate triggering image region extraction or clarity index calibration. The upper computer 30 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices. The application will be described in detail through specific examples. The camera module to be tested 20 can be an AF module, and can also be a light variable module.
[0036] An image region extraction method is provided in the embodiment, as shown in the method comprises: Figure 2
[0037] Step 110, identifying texture units in the chart image.
[0038] Wherein, the chart image is obtained by the camera module under test shooting a chart, for example, can be obtained by the host computer through the camera software, or can be the preview / shooting data obtained by the lower computer. The chart has regular texture, for example, a chessboard, a grid stripe, a sinusoidal stripe or a combination thereof, which can be selected according to different test task requirements.
[0039] Specifically, the file type of the chart image can be a camera encoded image (such as JPEG, BMP, PNG, etc.), can be a YUV image in the middle link of the camera preview process, or can be a camera RAW image, which is not limited in the embodiment.
[0040] Preferably, the chart image is a full-resolution image of the chart shot by the camera module under test in the focus state at the expected magnification.
[0041] In this embodiment, the complex texture in the chart image is identified by image processing, and is split into standardized texture units according to the graphic features, so as to ensure that the texture features in each texture unit are single and controllable. The same condition reference unit can be provided for subsequent combination and statistical region to ensure that the test data of different statistical regions are directly comparable.
[0042] It should be noted that the texture unit (texture primitive) refers to the smallest area unit in the texture image that has uniform local features constituting the texture. The graphic features (such as color, direction, frequency) of the graphics in the same texture unit are the same, and the graphic features of adjacent texture units are different. As shown in the figure, Figure 5 Each texture unit contains four long rectangular shapes to form a stripe, and the horizontal stripe texture unit and the vertical stripe texture unit are arranged alternately.
[0043] In actual application scenarios, step 110, i.e., identifying the texture units in the chart image, specifically includes the following steps:
[0044] Step 111, obtaining the contour line in the chart image.
[0045] Specifically, as shown in the figure, Figure 3 The present application can use a conventional contour extraction algorithm in the prior art to identify the contour line in the chart image, and the embodiment of the present application is not limited. The cv: findContours API of the OpenCV open source library can be used for contour line extraction.
[0046] Further, before step 111, the image of the card can be pre-processed (e.g. grayscale, down-sampling, binarization, filtering, etc.) to eliminate image noise, reduce background interference, enhance the contrast of the graphic boundary, and improve the accuracy of the contour line measurement and the recognition speed.
[0047] Further, after step 111, as shown in FIG. 6, the contour lines with a length exceeding the length range of the graphic of the card can be deleted to filter out invalid contour lines and improve the contour recognition rate, wherein the length range of the graphic can be reasonably set according to the actual graphic size of the card and the magnification of the camera module. Considering that the stripes at the edges are usually incomplete / truncated, the contour lines connected to the edges of the image of the card can also be deleted. As shown in the figure, the green lines are the filtered valid contour lines, so as to facilitate the subsequent identification of complete shape units. Figures 3 to 5
[0048] Step 112, connecting the contour lines with similar end point coordinates to form a graphic unit.
[0049] The graphic unit is the minimum area of a single visual element in a texture unit, which can be a simple geometric shape, a line, a spot, or the like. For example, in a "checkerboard texture", each black and white square is a texture unit, and the uniform color or micro-noise inside the square is a graphic unit thereof.
[0050] In this embodiment, after the contour lines are identified, the end point coordinates of the contour lines are compared, and the distance between the end points is calculated. When the distance between two end points is less than a preset distance, it is determined that the two end points belong to the same graphic, and then the two end points are connected to form a graphic unit. In this way, even if the contour line recognition is truncated, the complete graphic unit can be identified, which provides an accurate semantic basis for subsequent analysis and avoids overall misjudgment caused by local defects.
[0051] It is worth mentioning that for any graphic unit, the width and height thereof are compared to determine the stripe direction: if the width < the height, it is a horizontal stripe, and vice versa. As shown in FIG. 7, the green box corresponds to a horizontal stripe, and the blue box corresponds to a vertical stripe. Figure 4
[0052] Step 113, if the texture pattern type of the card includes stripes, the graphic units are clustered to determine a texture unit.
[0053] The graphic features of the multiple graphic units in the texture unit are the same.
[0054] In one embodiment, in step 113, the graphic units are clustered to determine texture units, specifically including: calculating the center point distance between adjacent graphic units; if the center point distance is less than or equal to a preset distance, determining that the adjacent graphic units are neighboring samples of each other; and generating texture units based on graphic units that have the same stripe direction and are neighboring samples of each other.
[0055] Among them, the preset distance (neighborhood radius) is determined according to the length of the longer side of the graphic unit, which not only avoids the neighborhood misjudgment problem caused by the fixed threshold in areas where the image content suddenly changes (such as object edges and noise interference areas), but also enhances scene adaptability and robustness.
[0056] In this embodiment, neighborhood relationships between samples are defined using adaptive preset distances, and directional filtering is used to eliminate irrelevant cells, clustering neighborhood samples into texture units. This replaces the traditional fuzzy judgment based on pixel proximity. This effectively eliminates isolated noise points, preserves relevant and effective texture structures, and ensures that clustering results conform to the physical distribution patterns of stripes. Even for irregularly shaped graphics, the geometric center distance is used as the basis for determining density distribution, avoiding neighborhood misjudgments due to differences in unit shape.
[0057] For example, the obtained shape unit set of horizontal and vertical stripes is used as a sample set, that is, D = {B1, B2, ..., B n The center point distance between shape units is taken as the sample distance. For shape unit B i 、B j , whose center points are C i 、C j , the distance between the two center points is dist(i,j)=|C i C j ∣. Let the long side of the shape unit be L i , k×L i As the preset distance, for example, k = 0.5. Figure 6 As shown in the figure, the distance between the centers of adjacent stripes in the same texture unit is significantly smaller than the distance between the centers of stripes in non-same texture units. C0, C1, C2, and C3 are the midpoints of the horizontal stripes in the same texture unit. The same is true for the vertical stripes. Obviously, |C0C1|, |C1C2|, and |C2C3| are approximately equal and much smaller than the distance between any point in them and the midpoint of the stripes in other texture units (see Figure 6 For shape unit B i 、B j , if it satisfies dist(i,j)<k×L i , and B i 、B j If the stripes have the same direction, they are neighboring samples of each other.
[0058] In another embodiment, the clustering of the pattern units in step 113 determines the texture units, specifically including: dividing the pattern units into multiple clusters according to the stripe direction and the number of cluster centers; splitting the cluster if the dispersion of the pattern units belonging to the same cluster is greater than a preset dispersion or the number of the pattern units belonging to the same cluster is greater than a preset number; and merging the different clusters if the dispersion of the pattern units belonging to the different clusters in the same stripe direction is less than a preset dispersion and the number of the pattern units belonging to the different clusters in the same stripe direction is less than a preset number.
[0059] In the formula, the number of cluster centers is configured as the product of the number of pattern units and a preset coefficient, that is, the number of cluster centers is initialized based on the number of pattern units, which helps to improve the stability of the clustering result. The dispersion can be represented by variance, standard deviation, distance or similarity.
[0060] It can be understood that the preset number (minimum neighborhood sample number) can be determined according to the number of stripe patterns corresponding to each texture unit, for example, as shown in FIG. 4, each texture unit corresponds to 4 horizontal stripes or 4 vertical stripes, and the preset number is set to 4. Figures 4 to 6
[0061] In this embodiment, the number of cluster centers is initialized based on the number of pattern units, so that the multiple clusters obtained by the initial clustering are more consistent with the distribution rule of the pattern units, which helps to improve the stability and efficiency of the clustering result. Further, the cluster splitting and merging mechanism is dynamically executed by the intra-cluster dispersion until the convergence condition is met or the maximum iteration number is reached, which can optimize the stripe direction clustering. Thus, the geometric details are better preserved, the randomness of the result is reduced, the non-uniform stripes in the same direction (such as the gradually changing distance stripes caused by lens distortion) are prevented from being incorrectly classified into the same class, and the local feature independence is ensured. Further, the explainability of the clustering result is improved, and the scene adaptability and robustness are improved.
[0062] For example, the number of initial cluster centers is set to 1 / 4 of the number of horizontal and vertical stripe pattern units. The center point distance between the shape units is taken as the sample distance, that is, for shape units B i , B j , the center points are C i , C j , and the center point distance between them is dist(i,j) = |C i C j ∣. Analyze in horizontal or vertical directions separately to ensure that stripes with different directions cannot be grouped into one cluster, and clusters with inconsistent stripe directions cannot be merged. Set the minimum number of samples in each cluster to 4; the maximum variance within the cluster σ is taken as α times the expected variance of the horizontal / vertical texture unit center point (for example, α = 1.2). If the intra-cluster variance of a cluster is greater than σ, it is split; or if the number of samples within the cluster is greater than 4, it is split. Set the minimum distance d allowed for the cluster centers of two clusters min is β times the expected average side length of the texture unit (e.g., β = 1). If the distance between the cluster centers of two clusters is less than d min , then merge them.
[0063] Step 114: If the texture pattern type of the graphics card includes checkerboard, use the graphic unit as the texture unit.
[0064] For example, Figure 10 As shown, since the checkerboard pattern is arranged in grid units, each grid itself has the same graphic features, and a grid can be directly used as a texture unit.
[0065] In this embodiment, different texture unit extraction strategies are selected based on different texture pattern types to obtain texture units. This can better adapt to graphics cards with unique geometric texture patterns, facilitate the reuse of duplicate texture graphics resources at existing workstations, and facilitate the rapid identification of texture units and their arrangement patterns, thereby reducing equipment and labor costs for inspection tasks.
[0066] It is worth mentioning that, in one embodiment, before step 110, the image area extraction method further includes: obtaining a preview image of the image card of the camera module to be tested, hardware parameters of the detection system, and at least one of the shooting environment parameters of the space where the camera module to be tested is located; determining the configuration information of the detection system based on at least one of the preview image, hardware parameters, and shooting environment parameters; and displaying the configuration information or adjusting the detection system based on the configuration information.
[0067] Among them, Figure 1 As shown, the inspection system (workstation) includes a camera module 20 to be tested, a teleconverter 60, and / or a chart 10. The inspection system's hardware parameters include the operating parameters of the camera module to be tested (e.g., resolution, focal length, field of view, etc.) and chart information of the assembled chart (e.g., texture pattern type, texture density type, chart size, texture size, etc.). Shooting environment parameters include parameters such as light intensity and temperature that may affect imaging results. The inspection system can be used for clarity calibration or other inspection tasks.
[0068] In this embodiment, after assembling the detection system, at least one of the preview image obtained after the assembly of the chart, the hardware parameters and the shooting environment parameters can be used to recommend the configuration information of the detection system, or directly drive the structural components to complete the adjustment. Thus, the usability of the detection system can be tested without manual experience, so that the detection system can be in a better detection environment, and the precision, efficiency, robustness and ease of use of the detection system can be effectively improved.
[0069] In actual application scenarios, without assembling the chart, the corresponding recommended chart information and the application environment information associated with the recommended chart information can be screened from the database according to the resolution parameters of the camera module to be tested and the shooting environment parameters. The chart suitable for testing the camera module to be tested and the current environment can be recommended to the user. The user can further adjust the current environment to be as close to the best state as possible through the application environment information associated with the chart information.
[0070] The resolution parameters include MTF cutoff frequency, aperture size, sensor pixel size, etc.
[0071] In the case of having assembled the chart, the magnification can be matched according to the texture characteristics of the assembled chart and the sensor pixel size of the camera module to be tested, and the corresponding teleconverter recommendation information can be screened from the database according to the magnification. Thus, by selecting a suitable teleconverter model, the chart texture density can meet the subsequent detection requirements, and the original calibration / test task can not be affected.
[0072] In the case of having assembled the chart, the edge coordinates of the chart in the preview image can also be determined, and the width between the edge of the chart and the edge of the preview image can be calculated according to the edge coordinates. If the width exceeds the preset width range, it means that the chart imaging does not cover the image, and the adjustment distance between any two of the chart, the teleconverter and the camera module to be tested or the deflection angle of the chart relative to the camera module to be tested can be screened from the database according to the width. The relative positions between any two of the chart, the camera module to be tested and the teleconverter can be changed, so that the field of view of the camera module to be tested can cover the entire chart, providing the same shooting conditions for subsequent acquisition of the statistical area, and further ensuring the equivalent comparability of different statistical areas.
[0073] Further, when the detection system is installed with a sliding assembly and a rotation adjustment assembly, the distance between any two of the chart, the teleconverter and the camera module to be tested can be adjusted by adjusting the distance to control the sliding assembly of the detection system, or the angle of the chart relative to the camera module to be tested can be adjusted by adjusting the deflection angle to control the rotation adjustment assembly of the detection system. Thus, the adaptive adjustment of the detection system can be realized, and the human resources and the adjustment difficulty can be further reduced.
[0074] In step 120, according to the texture density type of the chart, the target texture unit corresponding to different preset test positions is searched.
[0075] wherein, as shown in Figures 3 to 12 the texture density type refers to the number of texture elements in a unit area, the complexity, including sparse type and dense type. The sparse type means that the width of the texture itself and the texture interval are both less than a specified value, and vice versa, the dense type means that the width of the texture itself or the texture interval is greater than or equal to the specified value. The preset test position can be reasonably set according to the test requirements. For example, the center and the four corners of the image are taken as the preset test positions, and the clarity of the center can be evaluated by comparing the clarity detected by the center with the reference value, and the uniformity of the clarity can be evaluated by comparing the clarity detected by the center and the four corners.
[0076] In this embodiment, the search strategy is dynamically adjusted according to the texture density type, and the target texture unit required is searched from multiple texture units at different preset test positions with the same search strategy. It can adapt to the difference in texture density, reduce the waste of computing resources, match the search time consumption with the texture complexity, and improve the search efficiency. At the same time, it provides a standardized basis for subsequent extraction of statistical areas, so that the texture features in the statistical areas at different positions in the subsequent card images are highly consistent.
[0077] In actual application scenarios, for sparse type card images, step 120, that is, searching for target texture units corresponding to different preset test positions according to the texture density type of the card, specifically includes: taking the preset test position as the reference point, and selecting the texture units near the preset test position as the target texture units according to the preset unit quantity.
[0078] wherein, the preset unit quantity is matched according to the texture density of the card, and the preset unit quantity includes the required number of texture units with different graphic features, so as to ensure that the texture units can be selected at different positions with uniform standards to realize equivalent comparability. The preset unit quantity can be reasonably set according to the size of the required texture unit, for example, the number of horizontal stripe texture units × the number of vertical stripe texture units in each statistical area can be 1 × 2, 2 × 1, 2 × 2, 2 × 3, 3 × 2, 3 × 3, 3 × 4, 4 × 3, etc. As shown in Figure 9 for the current scale of the card, the 2 × 2 number type is preferred. If the density increases, the number of texture units should be increased appropriately, but not more than 1 / 3 of the short side length of the drawing.
[0079] It should be noted that for the same scale of the card, the required number of texture units corresponding to the statistical areas of the center and the four corners should be consistent, but the directions of the target texture units corresponding to the positions (i.e. horizontal and vertical arrangement) can not be consistent, only the horizontal texture units are recorded as H and the vertical texture units are recorded as V. For H and V, it is enough to be equal to each other to ensure that the same direction texture units have comparability. For example, if statistical areas A and B are both composed of m horizontal and n vertical target texture units, then statistical areas A and B have equivalent comparability.Figures 8 to 10 As shown in FIG. 2, the target texture units of the obtained center and four corner (0-4) statistical regions are respectively: They have equivalent comparability.
[0080] In this embodiment, the preset test position is taken as a reference, and the target texture units are selected in a local range around the preset test position. It is ensured that the selected target texture units are strongly correlated with the preset test position in space, and since the texture of the card is regularly arranged, the texture units in the adjacent regions usually have similar physical properties, so as to ensure that the statistical regions at different positions have the same or similar geometric structure and optical conditions, and realize the equivalent comparability of the multiple statistical regions.
[0081] For the dense card image, step 120, i.e., searching the target texture units corresponding to different preset test positions according to the texture density type of the card, specifically includes: taking the preset test position as a reference point, and selecting the target texture units according to the preset size.
[0082] In this embodiment, considering that the number of dense textures is large and may be connected, since the textures are sufficiently dense, the textures in the regions of the same size can be considered to be approximately uniform, i.e., having equivalent comparability. Then, the target texture units are directly selected according to the preset size.
[0083] For example, as shown in FIG. 3 and FIG. 4, the ROI size is set to WxH (for example, W and H are each 1 / 5 of the short side of the image), the center ROI is in the center of the picture, and the four corner ROIs are uniformly distributed near the four corners (stacked left, right, up and down). Figure 11 and Figure 12 As shown in FIG. 2 and FIG. 3, the ROI size is set to WxH (for example, W and H are each 1 / 5 of the short side of the image), the center ROI is in the center of the picture, and the four corner ROIs are uniformly distributed near the four corners (stacked left, right, up and down).
[0084] In an embodiment, the texture units near the preset test position are selected as the target texture units according to the preset number of units, including: calculating the distance between the reference point and the center point of the texture unit; determining the texture unit with the smallest distance from the reference point as the reference texture unit; determining at least one search direction according to the relative position of the reference texture unit and the reference point; selecting the texture units adjacent to the reference texture unit as the adjacent texture units according to the preset number of units along the at least one search direction; and determining the reference texture unit and the adjacent texture units as the target texture units.
[0085] In this embodiment, one anchor point (reference point) is set for each preset test position. The texture unit closest to the anchor point is found from the texture unit set as the reference texture unit. The search direction is determined according to the relative position of the reference texture unit and the anchor point, and the remaining adjacent texture units are searched for near the reference texture unit according to the corresponding search direction. Thus, dynamic positioning is performed based on the reference texture unit close to the reference point, and dynamic direction determination is realized and the adjacency relationship is recursively expanded along the search direction. In this way, an ROI as close to the expected position as possible can be obtained under the premise of ensuring equivalent comparability. The geometric alignment and stability of the target texture unit are guaranteed, and the robustness of the target texture unit search is improved.
[0086] It should be noted that when searching for adjacent texture units in different directions, the number of units required for each search direction can be determined based on the preset number of units. Then, starting from the reference texture unit, texture units that are adjacent to the reference texture unit can be searched for as adjacent texture units based on the number of units selected. The sum of the number of units selected in all search directions and the number of one reference texture unit is the preset number of units.
[0087] For example, Figure 7 As shown in the figure, taking the 2×2 number type as an example, the center anchor point P0 is the center point of the picture, and the texture unit closest to the anchor point is found as the reference texture unit. The relative position of the reference texture unit and the anchor point P0 is determined: if the texture unit is in the upper left, search to the lower right; if the texture unit is in the upper right, search to the lower left; if the texture unit is in the lower left, search to the upper right; if the texture unit is in the lower right, search to the upper left. Figure 7 The middle reference texture unit is in the lower left, so search to the upper right (see the arrow direction) to get the remaining texture units in the right, upper and upper right neighborhoods. The corresponding target texture unit in the central area is Figure 7 The four texture units corresponding to the red solid box A in the middle. Figure 7 The red dotted boxes B, C, and D in the middle represent target texture units obtained from other possible search directions. Similarly, the search method for the anchor points at the four corners is as follows:
[0088] Upper left corner: anchor point P1 is the upper left corner of the image, searching towards the lower right;
[0089] Upper right corner: Anchor point P2 is the upper right corner of the image, searching towards the lower left;
[0090] Lower left corner: Anchor point P3 is the lower left corner of the image, searching towards the upper right;
[0091] Lower right corner: Anchor point P4 is the lower right corner of the image, and search towards the upper left.
[0092] Step 130: construct multiple statistical regions of the chart image according to the target texture unit.
[0093] The plurality of statistical regions have equivalent texture features, that is, the statistical regions contain an equal number of equivalent texture units or contain approximately identical textures.
[0094] Specifically, multiple statistical areas can be used to perform quality inspection on the camera module to be tested, such as comparing the clarity of statistical areas at different positions within a frame, and can even be used to compare the clarity between different modules.
[0095] The image region acquisition method provided by the present application converts complex textures in a chart image into multiple smaller, regular-patterned basic texture units based on different graphic features. The search strategy is dynamically adjusted based on the texture density type, and the target texture unit is searched for from multiple texture units using the same search strategy at different preset test locations. By combining the target texture units at the preset test locations, a statistical region for the preset test location is constructed, ensuring highly consistent texture features within the statistical region at different locations in the image. Furthermore, multiple statistical regions within the same image share the same shooting conditions. This allows for performance evaluation of clarity, uniformity, and other aspects using different statistical regions within a single image, effectively eliminating measurement bias caused by cross-module, cross-region, and cross-time series errors. Furthermore, the method can reuse duplicate texture chart resources from existing calibration stations, eliminating the need for additional independent stations or customized dedicated charts. Furthermore, without the need for ideal shooting conditions, the system can automatically extract multiple equivalent regions from the same image by matching conditions, thereby compensating for imaging bias caused by differences in shooting conditions, significantly saving space and labor costs. Furthermore, by adjusting the search strategy based on texture density type, the system can adapt to different charts and achieve both high-precision local detection and image processing efficiency.
[0096] For example, Figures 7 to 12 As shown, the center of the image and the four corners of the screen are used as preset test positions, with one area at each position, for a total of five statistical areas.
[0097] In actual application scenarios, step 130 can be implemented in the following manner:
[0098] Method 1: Figure 8 As shown in FIG, the minimum bounding rectangle of the target texture unit is used as the statistical region, so that the statistical region can cover the boundary of the target texture unit, thereby improving the consistency of the statistical region.
[0099] Method 2: Figure 9 As shown in FIG, the statistical region is determined based on the union boundary of the target texture units, i.e., the circumscribed boundary of the target texture units. This reduces the background area in the statistical region, helps reduce the impact of background noise on subsequent detection tasks, and improves detection accuracy.
[0100] It is worth mentioning that, for the second mode, if it is detected that the boundaries of adjacent target texture units in the statistical region are not aligned, the statistical region is expanded outward according to preset pixel values. Thus, the statistical region can contain complete texture boundaries.
[0101] The preset pixel values can be set according to the sequential error, for example, 1, 3, or 5 pixels.
[0102] It should be noted that the size of the serial number of each step in the above embodiments does not mean the order of execution. The execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0103] Further, as shown in Figure 13 As a specific implementation of the above image region extraction method, the embodiments of the present application provide an image region extraction device 500, which comprises a unit identification module 501 and a region extraction module 502.
[0104] The unit identification module 501 is configured to identify texture units in a chart image, wherein the chart image is obtained by a camera module under test shooting a chart, the chart has regular textures, and adjacent texture units have different graphical features; and search for target texture units corresponding to different preset test positions according to the texture density type of the chart.
[0105] The region extraction module 502 is configured to construct a plurality of statistical regions of the chart image according to the target texture units, so as to detect the camera module under test through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features.
[0106] Further, the unit identification module 501 is specifically configured to acquire contour lines in the chart image; connect contour lines with similar endpoint coordinates to form graphical units; if the texture pattern type of the chart includes stripes, perform clustering processing on the graphical units to determine texture units, wherein the graphical features of a plurality of graphical units in the texture units are the same; and if the texture pattern type of the chart includes a chessboard, the graphical units are taken as texture units.
[0107] Further, the unit identification module 501 is specifically configured to calculate the center point distance between adjacent graphical units; if the center point distance is less than or equal to a preset distance, determine that the adjacent graphical units are neighborhood samples of each other, wherein the preset distance is determined according to the length of the long side of the graphical units; and generate texture units according to graphical units with the same stripe direction and being neighborhood samples of each other.
[0108] Further, the unit identification module 501 is specifically configured to divide the graphic units into multiple clusters according to the stripe direction and a number of cluster centers, wherein the number of cluster centers is a product of a number of the graphic units and a preset coefficient; if a dispersion degree of the graphic units belonging to a same cluster is greater than a preset dispersion degree, or a number of the graphic units belonging to the same cluster is greater than a preset number, the cluster is split; if a dispersion degree of the graphic units belonging to different clusters in a same stripe direction is less than a preset dispersion degree, and a number of the graphic units belonging to the different clusters in the same stripe direction is less than a preset number, the different clusters are merged.
[0109] Further, the unit identification module 501 is further configured to delete the contour line whose length exceeds a graphic length range of the graphic card; and / or, delete the contour line connected with an edge of the graphic card image.
[0110] Further, the unit identification module 501 is specifically configured to, if the texture density type is sparse, take a preset test position as a reference point, and select, according to a preset number of units, a texture unit near the preset test position as a target texture unit, wherein the preset number of units is obtained according to the texture density of the graphic card, and the preset number of units includes a required number of texture units with different graphic features; if the texture density type is dense, take the preset test position as the reference point, and frame the target texture unit according to a preset size; wherein the preset test position includes a center and four corners of the graphic card image.
[0111] Further, the unit identification module 501 is specifically configured to calculate a distance between the reference point and a center point of the texture unit; determine, as a reference texture unit, the texture unit with the smallest distance from the reference point; determine, according to a relative position of the reference texture unit and the reference point, at least one search direction; select, according to the preset number of units, a texture unit adjacent to the reference texture unit as an adjacent texture unit along the at least one search direction; and determine the reference texture unit and the adjacent texture unit as the target texture unit.
[0112] Further, the region extraction module 502 is specifically configured to take a minimum bounding rectangle of the target texture unit as a statistical region, or determine the statistical region according to a union boundary of the target texture units.
[0113] Further, the region extraction module 502 is further configured to, if it is detected that boundaries of adjacent target texture units in the statistical region are not aligned, expand the statistical region outward according to a preset pixel value.
[0114] Further, the image region extraction apparatus 500 further comprises:
[0115] A matching module (not shown in the figure) is configured to acquire at least one of a preview image of a chart by a camera module to be tested, a hardware parameter of a detection system, and a shooting environment parameter of a space where the camera module to be tested is located, wherein the detection system comprises the camera module to be tested, a teleconverter, and / or the chart; and determine configuration information of the detection system according to at least one of the preview image, the hardware parameter, and the shooting environment parameter.
[0116] A display module (not shown in the figure) is configured to display the configuration information.
[0117] A driving module (not shown in the figure) is configured to adjust the detection system according to the configuration information.
[0118] Further, the matching module is specifically configured to, in a case where the chart is not assembled, screen corresponding recommended chart information and application environment information associated with the recommended chart information from a database according to a resolution parameter of the camera module to be tested and the shooting environment parameter; in a case where the chart is assembled, match a magnification according to a texture feature of the chart and a sensor pixel size of the camera module to be tested, and screen corresponding teleconverter recommended information from the database according to the magnification; determine edge coordinates of the chart in the preview image, and calculate a width between an edge of the chart and an edge of the preview image according to the edge coordinates; and if the width exceeds a preset width range, screen an adjustment distance between any two of the chart, the teleconverter, and the camera module to be tested or a deflection angle of the chart relative to the camera module to be tested from the database according to the width.
[0119] Further, the driving module is specifically configured to control a sliding assembly of the detection system to adjust the distance between any two of the chart, the teleconverter, and the camera module to be tested according to the adjustment distance; and control a rotation adjustment assembly of the detection system to adjust the angle of the chart relative to the camera module to be tested according to the deflection angle.
[0120] The specific limitation of the image region extraction device can refer to the limitation of the image region extraction method in the above, which will not be repeated here. Each module in the above image region extraction device can be realized by software, hardware, and combinations thereof, in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0121] Based on the above method as shown in Figure 2 Accordingly, the embodiments of the present application also provide a readable storage medium having a computer program stored thereon, which is executed by a processor to implement the above image region extraction method as shown in Figure 2 .
[0122] Based on the understanding, the technical scheme of the present application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.), and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the method described in various implementation scenarios of the present application.
[0123] Based on the above method as Figure 1 indicated, and Figure 13 the virtual device embodiment as Figure 14 indicated, in order to achieve the above-mentioned purpose, the embodiments of the present application also provide a computer device. The computer device 700 includes a processor 701 and a memory 702. The memory 702 stores programs or instructions that can be run on the processor 701. When the programs or instructions are executed by the processor 701, the image region extraction method as Figure 2 indicated above is implemented.
[0124] The memory 702 can be used to store software programs and various data. The memory 702 can mainly include a first storage area storing programs or instructions, and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, etc.), and the like. In addition, the memory 702 can include a volatile memory or a non-volatile memory, or the memory 702 can include both volatile and non-volatile memories. The non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synch link DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 702 in the embodiments of the present application includes but is not limited to these and any other suitable types of memories.
[0125] The processor 701 can include one or more processing units; optionally, the processor 701 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 701.
[0126] The computer device can specifically be a personal computer, a server, a network device, and the like.
[0127] Optionally, the computer device can further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, and the like. The user interface can include a display screen, an input unit such as a keyboard, and the like. Optionally, the user interface can further include a USB interface, a card reader interface, and the like. The network interface can optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, a WI-FI interface), and the like.
[0128] Those skilled in the art can understand that the computer device structure provided by the embodiment does not constitute a limitation on the computer device, and can include more or fewer components, or combine certain components, or different component arrangements.
[0129] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software and a necessary general hardware platform, or by hardware to identify the texture unit in the image of the card, wherein the image of the card is obtained by a camera module to be tested shooting a card, the card has regular texture, and the adjacent texture units have different graphical features; according to the texture density type of the card, the target texture unit corresponding to different preset test positions is searched; and according to the target texture unit, a plurality of statistical regions of the image of the card are constructed to detect the camera module to be tested through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features. Thus, the clarity, uniformity and other performance evaluation can be realized by using different statistical regions on an image, effectively eliminating the measurement deviation caused by cross-module, cross-region and cross-time sequence, and the existing calibration workstation can be reused without adding an independent workstation or customizing a special card, and an ideal shooting environment is not required, and the system itself can compensate for part of the imaging deviation by matching conditions, thereby significantly saving space and labor costs.
[0130] Those skilled in the art can understand that the modules in the device in the embodiments are not necessarily required to implement the present application. Those skilled in the art can understand that the modules in the device in the embodiments can be distributed in the device in the embodiments according to the description of the embodiments, or can be changed and located in one or more devices different from the embodiments. The modules in the above embodiments can be combined into one module, or can be further split into a plurality of sub-modules.
[0131] The above serial numbers of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments. The above disclosure is only a few specific embodiments of the present application, but the present application is not limited thereto. Any changes that can be thought of by those skilled in the art should fall within the protection scope of the present application.
Claims
1. A method for extracting an image region, characterized in that: The method comprises: Identifying texture units in a chart image, wherein the chart image is obtained by photographing a chart with a camera module to be tested, the chart having a regular texture, and adjacent texture units having different graphic features; Searching for target texture units corresponding to different preset test positions according to the texture density type of the image card; A plurality of statistical regions of the chart image are constructed according to the target texture unit, so as to detect the camera module to be tested through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features.
2. The image region extraction method according to claim 1, wherein: The identifying of the texture unit in the card image includes: Obtaining contour lines in the picture card image; connecting the contour lines having similar endpoint coordinates to form a graphic unit; If the texture pattern type of the image card includes stripes, clustering the graphic units to determine the texture unit, wherein the graphic features of multiple graphic units in the texture unit are the same; If the texture pattern type of the graphics card includes a checkerboard, the graphics unit is used as the texture unit.
3. The image region extraction method according to claim 2, characterized in that: The clustering process of the graphic units to determine the texture units includes: Calculating the center point distance between adjacent graphic units; If the center point distance is less than or equal to a preset distance, it is determined that the adjacent graphic units are neighborhood samples, wherein the preset distance is determined according to the length of the long side of the graphic unit; The texture unit is generated according to the graphic units that have the same stripe direction and are neighboring samples of each other.
4. The image region extraction method according to claim 2, wherein: The clustering process of the graphic units to determine the texture units includes: Dividing the graphic units into a plurality of clusters according to the stripe directions and the number of cluster centers, wherein the number of cluster centers is the product of the number of the graphic units and a preset coefficient; If the discreteness of the graphic units belonging to the same cluster is greater than a preset discreteness, or the number of the graphic units belonging to the same cluster is greater than the preset number, splitting the cluster; If the discreteness of the graphic units belonging to different clusters in the same stripe direction is less than a preset discreteness, and the number of the graphic units belonging to different clusters in the same stripe direction is less than the preset number, the different clusters are merged.
5. The image region extraction method according to claim 2, wherein: After obtaining the contour lines in the card image, the method further includes: Deleting the contour lines whose length exceeds the graphic length range of the chart; and / or, The contour line that is adjacent to the edge of the chart image is deleted.
6. The image region extraction method according to claim 1, wherein: The step of searching for target texture units corresponding to different preset test positions according to the texture density type of the image card includes: If the texture density type is sparse, taking the preset test position as a reference point, selecting the texture unit located near the preset test position as the target texture unit according to a preset number of units, wherein the preset number of units is obtained by matching the texture density of the image card, and the preset number of units includes the required number of texture units with different graphic features; If the texture density type is dense, the target texture unit is selected based on a preset size using the preset test position as a reference point; The preset test positions include the center and four corners of the chart image.
7. The image region extraction method according to claim 6, characterized in that: The step of selecting the texture unit located near the preset test position as the target texture unit according to the preset number of units includes: Calculating the distance between the reference point and the center point of the texture unit; Determine the texture unit with the smallest distance from the reference point as a reference texture unit; determining at least one search direction according to a relative position between the reference texture unit and the reference point; along the at least one search direction, selecting, according to the preset number of units, the texture units that are adjacent to the reference texture unit as adjacent texture units; The reference texture unit and the adjacent texture unit are determined as the target texture unit.
8. The image region extraction method according to claim 1, wherein: The step of constructing a plurality of statistical regions of the card image according to the target texture unit includes: The minimum circumscribed rectangle of the target texture unit is used as the statistical area, or the statistical area is determined according to the union boundary of the target texture units.
9. The image region extraction method according to claim 8, characterized in that: After determining the statistical area according to the union boundary of the target texture units, the method further includes: If it is detected that the boundaries of the adjacent target texture units in the statistical area are not aligned, the statistical area is expanded outward according to a preset pixel value.
10. The image region extraction method according to claim 1, wherein: The method further comprises: Obtaining at least one of a preview image of the camera module under test on the chart, hardware parameters of a detection system, and shooting environment parameters of a space in which the camera module under test is located, wherein the detection system includes the camera module under test, a teleconverter, and / or the chart; determining configuration information of the detection system according to at least one of the preview image, the hardware parameters, and the shooting environment parameters; Display the configuration information or adjust the detection system according to the configuration information.
11. The image region extraction method according to claim 10, characterized in that: The determining, based on at least one of the preview image, the hardware parameters, and the shooting environment parameters, the configuration information of the detection system includes: In the case where no image card is installed, corresponding recommended image card information and application environment information associated with the recommended image card information are filtered from a database according to the resolution parameters and shooting environment parameters of the camera module to be tested; In the case where a chart has been assembled, matching a magnification according to texture features of the chart and a sensor pixel size of the camera module to be tested, and filtering corresponding teleconverter recommendation information from a database according to the magnification; Determining edge coordinates of the image card in the preview image, and calculating a width between an edge of the image card and an edge of the preview image based on the edge coordinates; If the width exceeds a preset width range, selecting an adjustment distance between any two of the chart, the teleconverter, and the camera module to be tested, or a deflection angle of the chart relative to the camera module to be tested from a database according to the width; The adjusting the detection system according to the configuration information includes: Controlling the sliding assembly of the detection system to adjust the distance between any two of the chart, the teleconverter, and the camera module to be tested by adjusting the distance; The rotation adjustment component of the detection system is controlled by the deflection angle to adjust the angle of the chart relative to the camera module to be tested.
12. An image region extraction device, characterized in that: The device comprises: a unit recognition module, configured to recognize texture units in a chart image, wherein the chart image is obtained by photographing a chart with a camera module to be tested, the chart has a regular texture, and adjacent texture units have different graphic features; and Searching for target texture units corresponding to different preset test positions according to the texture density type of the image card; The region extraction module is used to construct a plurality of statistical regions of the chart image according to the target texture unit, so as to detect the camera module to be tested through the plurality of statistical regions, wherein the plurality of statistical regions have equivalent texture features.
13. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the image region extraction method according to any one of claims 1 to 11 are implemented.
14. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, wherein: When the processor executes the program, the steps of the image region extraction method according to any one of claims 1 to 11 are implemented.