A method, device, medium and equipment for determining a test target image ROI region
By preprocessing the test chart image and determining the target square, the problem of low efficiency in determining the ROI region in non-full-image grid chart images is solved, achieving efficient ROI region determination, which is suitable for mass production.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- KUNSHAN QIUTI PHOTOELECTRIC TECH CO LTD
- Filing Date
- 2026-02-10
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, the determination of ROI regions in non-full-map grid chart images is inefficient and cannot be applied to mass production.
By preprocessing the test target image, the target squares are determined and the center squares are traversed. Image processing is performed using Gaussian filters, erosion kernels, and edge mask maps to filter out the ROI regions of the target squares and reduce the calculation of invalid regions.
It improves the efficiency of ROI region determination, is suitable for mass production, reduces manual intervention, and enhances the robustness and accuracy of the algorithm.
Smart Images

Figure CN122244414A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, medium, and device for determining the Region of Interest (ROI) of a test target image. Background Technology
[0002] SFR (Spatial Frequency Response) is a metric that measures the ability of an imaging system (such as a camera, lens, or sensor) to reproduce details at different spatial frequencies, primarily used to measure image sharpness. The SFR algorithm quantifies image sharpness by analyzing the SFR of a region of interest (ROI) in a specific test target image. The ROI can be defined as follows: Figure 1 As shown in the red box.
[0003] Measurement markers can be broadly classified into two categories: one is non-full-map grid markers, represented by an "X" shape (such as...). Figure 2 As shown), another type is the full-map grid pattern represented by a chessboard (such as...). Figure 3 (As shown). Methods for determining the Region of Interest (ROI) in full-map grid chart images are relatively mature. However, in non-full-map grid chart images, the location coordinates and size of the ROI are typically determined manually to complete the SFR analysis. But this method is inefficient and cannot be applied to mass production.
[0004] Therefore, there is an urgent need for a method to determine the ROI region in a test chart image, so as to improve the efficiency of ROI region determination in non-full-map grid chart images. Summary of the Invention
[0005] To address the problems existing in the prior art, embodiments of the present invention provide a method, apparatus, medium, and device for determining the ROI region of a test chart image, so as to solve or partially solve the technical problem that the determination efficiency cannot be guaranteed when determining the ROI region in a non-full-image grid chart image in the prior art.
[0006] A first aspect of the present invention provides a method for determining the Region of Interest (ROI) of a test specimen image, the method comprising:
[0007] The test image of the test board is preprocessed to obtain the target image; Determine each target square in the target image; Determine the target vertex of each target square, and determine the region of interest (ROI) corresponding to the target square based on the target vertex of the target square; A center square is determined in the target square. Starting from the center square, all target squares are traversed in a preset order. During the traversal, the ROI regions of each target square are numbered sequentially to obtain the ROI region sequence.
[0008] In the above scheme, the preprocessing of the test target image to obtain the target image includes: The test image of the test board is converted into a color image, and the color image is converted into an initial grayscale image; The initial grayscale image is denoised using a Gaussian filter to obtain a denoised grayscale image; The denoised grayscale image is inverted to obtain an inverted grayscale image; The inverted grayscale image is filtered by using a pre-constructed edge mask image to obtain a filtered grayscale image. A grayscale threshold is determined, and the filtered grayscale image is binarized using the grayscale threshold to obtain the target image.
[0009] In the above scheme, determining the grayscale threshold includes: The target image is etched using a preset first etch kernel to obtain a first etched image; The target image is etched using a preset second etch kernel to obtain a second etched image; the size of the second etch kernel is smaller than the size of the first etch kernel. The difference between the first erosion image and the second erosion image is obtained by performing a subtraction operation; The difference image is binarized to obtain an edge mask image; Extract the grayscale values of all pixels in the edge mask image, and determine the average value of the grayscale values of all pixels as the grayscale threshold.
[0010] In the above scheme, determining each target square in the target image includes: Determine the first normalized central moment of the standard square in the test template; For each contour in the target image, the second normalized central moment of each contour is determined; Each eigenvalue of the second normalized center matrix is matched sequentially with the eigenvalue of the first normalized center matrix, and the contour corresponding to the successfully matched eigenvalue of the second normalized center matrix is determined as a square contour. For each square outline, determine whether the area of the square outline is within a preset area range and whether the rotation angle of the square outline is within a preset angle range; If the area of the square outline is within the preset area range and the rotation angle of the square is within the preset angle range, then the square outline is determined to be the target square.
[0011] In the above scheme, determining the vertex of each target square includes: For each target square, determine the coordinates of all pixels in the target square to obtain a set of contour points; Perform convex hull detection on the set of contour points to obtain the convex hull of the set of contour points; Determine the minimum circumscribed rectangle of the convex hull; The vertices of the minimum circumscribed rotating rectangle are determined as the initial vertices of the target square; The subpixel optimization algorithm is used to iteratively search within a preset region centered on the initial vertex until the iteration termination condition is met. The corner point of each target square is then output and the corner point is determined as the target vertex of the target square.
[0012] In the above scheme, determining the ROI region corresponding to the target square based on the target vertex of the target square includes: Determine the midpoint of each adjacent target vertex in turn; For each midpoint, a rectangular region is determined with the midpoint as the center and preset width and height parameters. The rectangular region is the ROI region.
[0013] In the above scheme, determining the center square in the target square includes: Determine the distance between each target square and the center point of the target image, and arrange all distances in ascending order to obtain a distance sequence; Obtain the previous distance sequence n The target square corresponding to each distance is obtained. n One target square; In order n The target image is rotated by a preset angle with each target square as the center point to obtain the corresponding rotated reference image, and the Euclidean distance between the rotated reference image and the target image is determined. The target square corresponding to the minimum Euclidean distance is determined as the center square.
[0014] A second aspect of the present invention provides an apparatus for determining the Region of Interest (ROI) of a test specimen image, the apparatus comprising: The preprocessing unit is used to preprocess the image to be tested on the test target plate to obtain the target image; The first determining unit is used to determine each target square in the target image; The second determining unit is used to determine the vertices of each target square and determine the region of interest (ROI) corresponding to the target square based on the vertices of the target square. The traversal unit is used to determine the center square in the target square, and traverse all target squares in a preset order starting from the center square. During the traversal, the ROI region of each target square is numbered in turn to obtain the ROI region sequence.
[0015] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in any of the first aspects.
[0016] A fourth aspect of the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the steps of the method described in any of the first aspects.
[0017] This invention provides a method, apparatus, medium, and device for determining the Region of Interest (ROI) area of a test template image, comprising: preprocessing the test template image to obtain a target image; determining each target square in the target image; determining the vertex of each target square, and determining the ROI area corresponding to the target square based on the vertex of the target square; determining the center square in the target square, and traversing all target squares in a preset order starting from the center square, numbering the ROI areas of each target square sequentially during the traversal process to obtain an ROI area sequence; thus, for non-full-image grid templates, the squares do not fill the entire test template, so by preprocessing the test image to filter out invalid information before determining the target squares, it is equivalent to first locking the carrier (square) of the ROI area, and then directly generating the ROI from the carrier, without traversing the entire image to find the ROI area, reducing the calculation of invalid areas, and the entire process does not require manual intervention, thus improving the efficiency of ROI area determination in mass production. Attached Figure Description
[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A schematic diagram of the ROI region in the prior art is shown; Figure 2 A schematic diagram of a full-map grid chart in the prior art is shown; Figure 3This diagram illustrates a non-full-map grid chart in the prior art. Figure 4 A schematic flowchart of a method for determining the ROI region of a test specimen image according to an embodiment of the present invention is shown. Figure 5 A schematic diagram of the original raw image of a test specimen image according to an embodiment of the present invention is shown; Figure 6 A schematic diagram illustrating the conversion of a raw Raw image into a color image in BGR format according to an embodiment of the present invention is shown. Figure 7 A schematic diagram of an initial grayscale image according to an embodiment of the present invention is shown; Figure 8 A schematic diagram of a noise-reduced grayscale image according to an embodiment of the present invention is shown; Figure 9 A schematic diagram of an inverted grayscale image according to an embodiment of the present invention is shown; Figure 10 A schematic diagram of an edge mask image according to an embodiment of the present invention is shown; Figure 11 A schematic diagram of a target image according to an embodiment of the present invention is shown; Figure 12 A schematic diagram of an image obtained after morphological denoising of a target image according to an embodiment of the present invention is shown. Figure 13 A schematic diagram of the contour contained in a target image according to an embodiment of the present invention is shown; Figure 14 A schematic diagram of a square outline in a target image according to an embodiment of the present invention is shown; Figure 15 A schematic diagram of the minimum bounding rectangle of a target grid according to an embodiment of the present invention is shown; Figure 16 A schematic diagram of the target vertices of a target grid according to an embodiment of the present invention is shown; Figure 17 A schematic diagram of the ROI region of a target grid according to an embodiment of the present invention is shown; Figure 18 A schematic diagram showing all target squares numbered according to an embodiment of the present invention is provided. Figure 19 A schematic diagram of a target image after numbering the ROI region of each target square according to an embodiment of the present invention is shown. Figure 20 A schematic diagram of the output target ROI region according to an embodiment of the present invention is shown; Figure 21A schematic diagram of ROI region marking for a certain type of non-full-map grid test chart according to an embodiment of the present invention is shown; Figure 22 A schematic diagram is shown of ROI region marking for another type of non-full-map grid test template according to an embodiment of the present invention; Figure 23 A schematic diagram is shown of ROI region marking for another type of non-full-map grid test template according to an embodiment of the present invention; Figure 24 A schematic diagram is shown of ROI region marking for another type of non-full-map grid test template according to an embodiment of the present invention; Figure 25 A schematic diagram is shown of ROI region marking for another type of non-full-map grid test template according to an embodiment of the present invention; Figure 26 A schematic diagram is shown of ROI region marking for another type of non-full-map grid test template according to an embodiment of the present invention; Figure 27 A schematic diagram of a device for determining the ROI region of a test specimen image according to an embodiment of the present invention is shown. Detailed Implementation
[0019] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0020] This invention provides a method for determining the Region of Interest (ROI) in a test chart image. The test chart is primarily a non-full-image grid chart, such as... Figure 4 As shown, the method includes the following steps: S410 preprocesses the image to be tested on the test target plate to obtain the target image.
[0021] In this invention, an image acquisition device is used to photograph the test target to obtain the original image, which is then copied to obtain the image to be tested. That is, the image to be tested is a copy of the original image. Since subsequent SFR analysis needs to be performed on the original image without any processing, this invention determines the location of the target ROI region in the image to be tested, then maps the coordinates of the target ROI region onto the original image, and crops the corresponding image to be analyzed from the original image for SFR analysis.
[0022] The test image of the test target is a Bayer Raw image, which needs to be preprocessed to obtain the target image. In one embodiment, the preprocessing of the test image of the test target to obtain the target image includes: The test image of the test board is converted into a color image, and the color image is then converted into an initial grayscale image. The initial grayscale image is denoised using a Gaussian filter to obtain a denoised grayscale image; Invert the grayscale of the denoised grayscale image to obtain the inverted grayscale image; The inverted grayscale image is filtered by using a pre-constructed edge mask image to obtain a filtered grayscale image. Determine the grayscale threshold, and use the grayscale threshold to perform binarization processing on the filtered grayscale image to obtain the target image.
[0023] Specifically, the image to be tested can be converted into a BGR color image using the demosaic method, as follows: Determine the Bayer array of the Raw image. The Bayer array can be either an RGGB array or a BGGR array. Each pixel in the Bayer array belongs to only one of the R, G, and B channels. Therefore, for each pixel, first determine the color channel of that pixel, and then use the difference between adjacent pixels to fill in the remaining two color channels to obtain RGB data. The RGB data are rearranged according to the channel order in the BGR image to obtain a color image in BGR format. The image under test (Raw image) can be represented as follows: Figure 5 As shown, a color image in BGR format can be displayed as follows: Figure 6 As shown.
[0024] Next, convert the BGR format color image to an initial grayscale image, as shown below. Figure 7 As shown. To improve image quality, the initial grayscale image also needs to be denoised using a Gaussian filter to obtain a denoised grayscale image; the denoised grayscale image is shown below. Figure 8 As shown. For example, a Gaussian kernel (a convolution kernel that conforms to a Gaussian distribution) is used to convolve the initial grayscale image to smooth the noise in the initial grayscale image and preserve the image details of the initial grayscale image, thereby achieving the purpose of noise reduction.
[0025] To highlight the squares, the denoised grayscale image needs to be inverted. This will set the black squares in the denoised grayscale image to white and the irrelevant background to black, resulting in an inverted grayscale image. The inverted grayscale image is shown below. Figure 9 As shown. Grayscale inversion (also called phase inversion) is a basic pixel transformation operation in digital image processing. Its core is to invert the grayscale values of an image to achieve the visual effect of "black to white and white to black".
[0026] To reduce interference from corner regions in the inverted grayscale image and improve the accuracy of target square recognition, a pre-constructed edge mask image is used to filter the inverted grayscale image, resulting in a filtered grayscale image. The edge mask image is shown below. Figure 10 As shown.
[0027] The edge mask image is a binary image with the same size as the inverted grayscale image. If you want to keep the middle area, the mask pixel value of the middle area of the edge mask image can be 255 (which is valid); if you want to exclude the corner area, the mask pixel value of the corner area of the edge mask image can be 0 (which is invalid).
[0028] The edge mask image is ANDed with the corresponding pixels in the inverted grayscale image. The result bit is 1 only if all corresponding bits are 1; otherwise, the result bit is 0. Since a bitwise AND of any number with 255 retains the original value, while a bitwise AND of any number with 0 results in 0, invalid areas can be cleared, while valid areas are retained, thus filtering out the valid areas and obtaining the filtered grayscale image.
[0029] Then, a grayscale threshold is determined, and the filtered grayscale images are binarized using this threshold to obtain the target image. The target image is as follows: Figure 11 As shown.
[0030] In one implementation, determining the grayscale threshold includes: The target image is eroded using a preset first erosion kernel to obtain a first erosion image; The target image is etched using a preset second etch kernel to obtain a second etched image; the size of the second etch kernel is smaller than the size of the first etch kernel. The difference image is obtained by subtracting the first erosion image and the second erosion image. The difference image is binarized to obtain the target mask image; Extract the grayscale values of all pixels in the target mask image, and determine the average grayscale value of all pixels as the grayscale threshold.
[0031] Specifically, in order to improve the accuracy of binarized images, this invention does not directly determine a grayscale threshold based on human experience as in traditional techniques. Instead, it transforms the fuzzy grayscale distribution into a clear bimodal distribution through complementary erosion and differential operations of dual structuring elements, thereby ensuring that the determined grayscale threshold is more accurate.
[0032] First, set up the first and second corrosion nuclei. The first corrosion nuclei can have 3... A 3-matrix structure, where the second erosion core can be 7. A 7-matrix erosion matrix is used to traverse the filtered grayscale image using the first erosion kernel. Each pixel in the filtered grayscale image is replaced with the minimum grayscale value within the first erosion coverage area, resulting in the first erosion image. ; The second erosion kernel is used to traverse the filtered grayscale image, and each pixel in the filtered grayscale image is replaced with the minimum grayscale value within the coverage area of the second erosion, thus obtaining the second erosion image. .
[0033] Using formula The difference image is obtained by subtracting the first erosion image and the second erosion image. The grayscale distribution of a differential image exhibits a bimodal characteristic: one peak corresponds to the boundary between the foreground and background, and the other peak corresponds to the pure background area.
[0034] Since the automatic thresholding algorithm can distinguish between edges and non-edges in the difference image, the difference image is binarized using the automatic thresholding algorithm to obtain an edge mask image. The width of the edge mask image depends on the size difference between the first erosion kernel and the second erosion kernel.
[0035] Extract the grayscale values of all pixels in the edge mask image, and determine the average grayscale value of all pixels as the grayscale threshold.
[0036] For the filtered grayscale image, the grayscale values of pixels with values greater than the grayscale threshold are set to 255, and the grayscale values of pixels with values less than the grayscale threshold are set to 0, thereby converting the filtered grayscale image into the target image.
[0037] S111, determine each target square in the target image.
[0038] To improve the accuracy of target grid determination, morphological denoising of the target image is required before determining each target grid. Specifically: The target image is sequentially opened and closed to eliminate different types of noise and imperfections.
[0039] The opening operation involves first eroding the target image, then dilating it to eliminate the black spots around the target squares.
[0040] The closing operation involves first dilating the target image, then eroding it. This fills in the small gaps in the target square outline, making the outline more complete. The image obtained after morphological denoising of the target image is shown below. Figure 12 As shown.
[0041] After performing morphological denoising on the target image, the target squares in the target image are determined, including: Determine the first normalized central moment of the standard square in the test template; For each contour in the target image, the second normalized central moment of each contour is determined; Each eigenvalue of the second normalized center matrix is matched sequentially with the eigenvalue of the first normalized center matrix, and the contour corresponding to the successfully matched eigenvalue of the second normalized center matrix is determined as a square contour. For each square outline, determine whether the area of the square outline is within a preset area range and whether the rotation angle of the square outline is within a preset angle range. If the area of the square outline is within the preset area range and the rotation angle of the square is within the preset angle range, then the square outline is determined as the target square.
[0042] Specifically, such as Figure 13 As shown, the target image contains many contours, but some contours are not square contours. Therefore, the contours in the target image need to be filtered to obtain square contours.
[0043] This invention utilizes a shape matching method based on normalized central moments (Mu invariant moments) to filter all contours in a target image. First, the first normalized central moment of the standard square grid in the test template is determined using the moment calculation function in the OpenCV library. Then, a computer function is used to determine the second normalized central moment of each contour in the target image. For each second normalized central moment, the Euclidean distance between the second and first normalized central moments is calculated. If the Euclidean distance is less than a preset threshold (e.g., 0.001), the match is successful, and the contour corresponding to the eigenvalue of the successfully matched second normalized central moment matrix is determined as a square contour. A square contour is shown below. Figure 14 As shown.
[0044] In addition, polygon fitting algorithms can be used to determine whether each contour is a square contour (e.g., the number of vertices is 4, the maximum difference in the length of the 4 sides is less than a preset threshold, and the interior angles are close to 90 degrees). If the above conditions are met, it means that it is a square contour.
[0045] Since not all of the determined square outlines are the same as the target square outlines, it is necessary to filter the square outlines based on the preset area range and preset angle range. If the area of the square outline is within the preset area range and the rotation angle of the square is within the preset angle range, then the square outline is determined as the target square.
[0046] Delete the square outlines that do not meet the requirements, and keep the target square.
[0047] S112, determine the target vertex of each target square, and determine the ROI region corresponding to the target square based on the target vertex of the target square.
[0048] Once the target squares are determined, the vertices of each target square need to be identified, and the corresponding ROI region is determined based on the vertices of the target squares.
[0049] In one implementation, determining the vertices of each target square includes: For each target square, determine the coordinates of all pixels in the target square to obtain the set of contour points; Perform convex hull detection on the set of contour points to obtain the convex hull of the set of contour points; Determine the minimum circumscribed rectangle of the convex hull; The vertices of the smallest bounding rectangle are determined as the vertices of the target square; The subpixel optimization algorithm is used to iteratively search within a preset region centered on the vertex until the iteration termination condition is met. The corner point of each target square is output and the corner point is determined as the target vertex of the target square.
[0050] Alternatively, the Harris corner detection method can be used to determine the corners of each target square, and the corners can be identified as the target vertices of the target square.
[0051] In one implementation, determining the ROI region corresponding to the target square based on the target vertex of the target square includes: Determine the midpoint of each adjacent target vertex in turn; For each midpoint, a rectangular region is defined with the midpoint as the center and the preset width and height parameters. This rectangular region is the ROI region.
[0052] Specifically, it is necessary to traverse all the target squares and determine the corresponding minimum bounding rectangle for each target square. The center of the minimum bounding rectangle is the center of the target square, and the vertices of the minimum bounding rectangle are the vertices of the target square.
[0053] First, for each target square, obtain the coordinates of all pixels of the corresponding contour of the target square, and extract the coordinates of all pixels of the target square to obtain the contour point set.
[0054] The Convex Hull algorithm from the OpenCV library is used to perform convex hull detection on the set of contour points. Concave points inside the contour are removed, and only the outermost convex vertices are retained to obtain the convex hull of the set of contour points.
[0055] Each edge of the convex hull of the contour point set is used as an edge of the reference bounding rectangle. This edge is rotated, and the area of the rectangle enclosing the convex hull is calculated, resulting in four rectangle areas. The rectangle corresponding to the smallest bounding area is determined as the minimum bounding rotated rectangle. The minimum bounding rotated rectangle is shown below. Figure 15 As shown.
[0056] For example, suppose the convex hull is a square tilted at 45 degrees, with vertices numbered A(50,100), B(100,50), C(150,100), and D(100,150), and the pixels are symmetrically distributed. Then the convex hull has 4 edges: Edge 1: A (50,100) → B (100,50) (sloping -45°) Side 2: B (100,50) → C (150,100) (incline +45°) Side 3: C (150,100) → D (100,150) (sloping -45°) Edge 4: D (100,150) → A (50,100) (slant +45°) Taking side 2 as an example, based on side 2, the rectangle needs to be rotated by +45 degrees to fit the convex hull. Therefore, the length of side 2 is:
[0057] The maximum span (width) of the convex hull in the direction perpendicular to side 2 is equal to the length of side 2. Since it is a square, the width of side 2 is also 70.71, so the area of the corresponding rectangle is approximately 5000 pixels.
[0058] Using the same method described above, the areas of all rectangles can be determined. The rectangle corresponding to the smallest rectangle area is then identified as the smallest circumscribed rectangle.
[0059] After determining the minimum bounding rectangle, its vertices are used as the initial vertices of the target square. To further improve the accuracy of vertex determination, a sub-pixel optimization algorithm can be used to iteratively search within a preset region centered on the initial vertices until the iteration termination condition is met (e.g., reaching the required number of iterations). Each target square's corner point is then output and designated as the target vertex. Since the sub-pixel corner points have fractional coordinates, the boundaries of the subsequent ROI can be more precise (e.g., the calculation error for the square's side length can be reduced from 1 pixel to within 0.1 pixels). Target vertices are as follows: Figure 16 As shown.
[0060] After the target vertices of the target square are determined, the midpoints of adjacent target vertices are determined sequentially. For each midpoint, a rectangular region is defined centered on the midpoint using preset width and height parameters; this rectangular region is the Region of Interest (ROI). Thus, each target square effectively contains four ROI regions. The ROI regions are as follows: Figure 17 The four rectangles in the image are shown.
[0061] S113, determine the center square in the target square, and traverse all target squares in a preset order starting from the center square. During the traversal, number the ROI region of each target square in turn to obtain the ROI region sequence.
[0062] In practical applications, users sometimes specify certain ROI regions as target ROI regions. Therefore, in order to output the corresponding target ROI regions according to the user's input instructions, it is also necessary to sort and number all ROI regions.
[0063] The present invention first determines the center square in the target square, and then traverses all target squares in a preset order starting from the center square. During the traversal, the ROI region of each target square is numbered in turn to obtain the ROI region sequence.
[0064] In one implementation, determining the center square within the target square includes: Determine the distance between each target square and the center point of the target image, and arrange all distances in ascending order to obtain a distance sequence; Obtain the previous distance sequence n The target square corresponding to each distance is obtained. n One target square; In order n The target image is rotated by a preset angle with each target square as the center point to obtain the corresponding rotated reference image, and the Euclidean distance between the rotated reference image and the target image is determined. The target square corresponding to the minimum Euclidean distance is determined as the center square.
[0065] Specifically, the value of n can be 5, and the target squares corresponding to the first 5 distances include the center square and the 4 squares in the innermost field of view. Therefore, the center square can be determined from these 5 target squares.
[0066] against n Each time, the target image is rotated 180 degrees with one target square as the center point, and finally, the result is obtained. n A rotated reference image. Since the measurement plate is centrally symmetric, the closer the square is to the center of the image, the closer the rotated reference image will be to the original image after rotating it 180 degrees around that square.
[0067] Then the Euclidean distance between each rotated reference image and target image can be determined, and the target square corresponding to the smallest Euclidean distance is determined as the center square.
[0068] Additionally, normalized correlation matching or correlation coefficient matching algorithms can be used to determine whether the rotated reference image and the target image are similar. The implementation logic of normalized correlation matching and correlation coefficient matching algorithms is the same; the following explanation uses the normalized correlation matching algorithm: To determine whether a rotated reference image is similar to a target image using a normalized correlation matching algorithm, we can first determine the first gray-scale mean of each rotated reference image and the second gray-scale mean of the target image. Based on the first and second gray-scale mean values, we can determine the normalized correlation coefficient between each rotated reference image and then determine the target square corresponding to the largest normalized correlation coefficient as the center square.
[0069] Once the center square is determined, a polar coordinate system is established with the center square as the origin. Starting from the center square, the traversal proceeds from the center to the edge, traversing all target squares in each field of view in a preset order (clockwise or counterclockwise). During the traversal, the Regions of Interest (ROIs) of each target square are numbered sequentially, resulting in a sequence of ROIs. Alternatively, the traversal can be performed column-wise or row-wise; there are no restrictions on this approach.
[0070] Specifically, refer to Figure 18 Each circle represents a field of view. Within each field of view, the system traverses from a preset position (e.g., the top position) in a preset order (clockwise or counterclockwise), with a preset angular step size during the traversal. When a target square is found during the traversal, a corresponding number is added to the target square, and the target square is added to a preset sequence. Furthermore, to avoid finding the same square repeatedly and thus improve the accuracy of square finding, a target square can also be deleted from the target image after being added to the sequence.
[0071] After traversing all fields of view using the method described above, all target squares are obtained, forming a square sequence. The square sequence stores the number of each target square and the position information of each target square.
[0072] To more vividly demonstrate the numbering effect of the squares and the ROI regions, this invention also generates a copy image of the image under test (a duplicate of the image under test). In the copy image of the image under test, each target square is marked with a corresponding number. The numbered target squares are shown below. Figure 18 As shown.
[0073] The target squares are traversed in ascending order of their numbers. During the traversal, the ROI regions of each target square can be numbered (e.g., from 0 to N) in a "top-right-bottom-left" order (or other preset order). After traversing all the target squares, the ROI region sequence is obtained. The effect of numbering the ROI regions of each target square can be seen in the following example. Figure 19 As shown.
[0074] Understandably, since each target square contains 4 ROI regions, the total number of ROI regions should be 4 times the total number of target squares.
[0075] In practical applications, a target ROI region filtering list roi_filtered[] can be constructed according to the user's actual needs. The target ROI region filtering list stores the numbers of the required target ROI regions in sequence. For example, when roi_filtered = [0,2,4,5,3,1], the target ROI regions numbered 0, 2, 4, 5, 3, and 1 can be extracted based on the target ROI region filtering list. That is, the first one is the target ROI region numbered 0, and the sixth one is the ROI region numbered 1.
[0076] If the user has no special requirements, that is, when the target ROI region filter list is empty, all ROI regions can be output for use in subsequent processes.
[0077] After outputting the target ROI region, refer to Figure 20 The target ROI region in the copy of the image to be tested is shown as a green box. Since SFR analysis requires preserving the grayscale and other details of the original image as much as possible, and the image to be tested is a copy of the original image, the location information of the target ROI region determined in the image to be tested can be mapped to the original image. The corresponding ROI region in the original image can then be cropped as the object for subsequent SFR analysis.
[0078] The ROI region determination method provided by this invention is applicable to most non-full-image grid charts. For different charts, only some parameters need to be adjusted without redeveloping the algorithm, thereby reducing software development costs and improving efficiency. Furthermore, by preprocessing the image to be tested to filter out invalid information, the anti-interference ability of the target image is improved, thus enhancing the robustness of the entire algorithm. Determining the target grid is equivalent to first locking the carrier (grid) of the ROI region, directly generating the ROI region from the carrier, eliminating the need to traverse the entire image to find the ROI region, reducing the calculation of invalid regions, and thus improving efficiency. Figures 21 to 26The six different types of non-full-map grid charts (in reality, there may be more types, but only a portion are shown here) can all quickly and accurately determine the ROI region.
[0079] Based on the same inventive concept as in the foregoing embodiments, this embodiment also provides a device for determining the ROI region of a test target image, such as... Figure 27 As shown, the device includes: The preprocessing unit 271 is used to preprocess the image to be tested on the test target plate to obtain the target image; The first determining unit 272 is used to determine each target square in the target image; The second determining unit 273 is used to determine the vertex of each target square and determine the ROI region corresponding to the target square based on the vertex of the target square; Traversal unit 274 is used to determine the center square in the target square, and traverse all target squares in a preset order starting from the center square. During the traversal, the ROI region of each target square is numbered in turn to obtain the ROI region sequence.
[0080] Since the apparatus described in the embodiments of the present invention is used for implementing the method of determining the ROI region of a test target image according to the embodiments of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in the embodiments of the present invention, and therefore will not be described in detail here. All apparatuses used in the methods of the embodiments of the present invention fall within the scope of protection of the present invention.
[0081] Based on the same inventive concept, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any step of the method described above.
[0082] Based on the same inventive concept, this embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods described above.
[0083] Through one or more embodiments of the present invention, the present invention has the following beneficial effects or advantages: This invention provides a method, apparatus, medium, and device for determining the Region of Interest (ROI) area of a test template image, comprising: preprocessing the test template image to obtain a target image; a non-full-image grid template; determining each target square in the target image; determining the vertex of each target square, and determining the ROI area corresponding to the target square based on the vertex of the target square; determining the center square in the target square, and traversing all target squares in a preset order starting from the center square, numbering the ROI areas of each target square sequentially during the traversal to obtain an ROI area sequence; thus, for a non-full-image grid template, the squares do not fill the entire test template, so by preprocessing the test image to filter out invalid information and then determining the target squares, it is equivalent to first locking the carrier (square) of the ROI area, and then directly generating the ROI from the carrier, without traversing the entire image to find the ROI area, reducing the calculation of invalid areas, and the entire process does not require manual intervention, thus improving the efficiency of ROI area determination in mass production.
[0084] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0085] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0086] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0087] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components of the gateway, proxy server, or system according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0088] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0089] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for determining the Region of Interest (ROI) in a test template image, characterized in that, The method includes: The test image of the test board is preprocessed to obtain the target image; Determine each target square in the target image; Determine the target vertex of each target square, and determine the region of interest (ROI) corresponding to the target square based on the target vertex of the target square; A center square is determined in the target square. Starting from the center square, all target squares are traversed in a preset order. During the traversal, the ROI regions of each target square are numbered sequentially to obtain the ROI region sequence.
2. The method as described in claim 1, characterized in that, The preprocessing of the test target image to obtain the target image includes: The test image of the test board is converted into a color image, and the color image is converted into an initial grayscale image; The initial grayscale image is denoised using a Gaussian filter to obtain a denoised grayscale image; The denoised grayscale image is inverted to obtain an inverted grayscale image; The inverted grayscale image is filtered by using a pre-constructed edge mask image to obtain a filtered grayscale image. A grayscale threshold is determined, and the filtered grayscale image is binarized using the grayscale threshold to obtain the target image.
3. The method as described in claim 2, characterized in that, Determining the grayscale threshold includes: The target image is subjected to an erosion operation using a preset first erosion kernel to obtain a first erosion image; The target image is etched using a preset second etch kernel to obtain a second etched image; the size of the second etch kernel is smaller than the size of the first etch kernel. The difference between the first erosion image and the second erosion image is obtained by performing a subtraction operation; The difference image is binarized to obtain an edge mask image; Extract the grayscale values of all pixels in the edge mask image, and determine the average value of the grayscale values of all pixels as the grayscale threshold.
4. The method as described in claim 1, characterized in that, Determining each target square in the target image includes: Determine the first normalized central moment of the standard square in the test template; For each contour in the target image, the second normalized central moment of each contour is determined; Each eigenvalue of the second normalized center matrix is matched sequentially with the eigenvalue of the first normalized center matrix, and the contour corresponding to the successfully matched eigenvalue of the second normalized center matrix is determined as a square contour. For each square outline, determine whether the area of the square outline is within a preset area range and whether the rotation angle of the square outline is within a preset angle range; If the area of the square outline is within the preset area range and the rotation angle of the square is within the preset angle range, then the square outline is determined to be the target square.
5. The method as described in claim 1, characterized in that, Determining the vertices of each of the target squares includes: For each target square, determine the coordinates of all pixels in the target square to obtain a set of contour points; Perform convex hull detection on the set of contour points to obtain the convex hull of the set of contour points; Determine the minimum circumscribed rectangle of the convex hull; The vertices of the minimum circumscribed rotating rectangle are determined as the initial vertices of the target square; The subpixel optimization algorithm is used to iteratively search within a preset region centered on the initial vertex until the iteration termination condition is met. The corner point of each target square is then output and the corner point is determined as the target vertex of the target square.
6. The method as described in claim 1, characterized in that, The step of determining the ROI region corresponding to the target square based on the target vertex of the target square includes: Determine the midpoint of each adjacent target vertex in turn; For each midpoint, a rectangular region is determined with the midpoint as the center and preset width and height parameters. The rectangular region is the ROI region.
7. The method as described in claim 1, characterized in that, Determining the center square in the target square includes: Determine the distance between each target square and the center point of the target image, and arrange all distances in ascending order to obtain a distance sequence; Obtain the previous distance sequence n The target square corresponding to each distance is obtained. n One target square; In order n The target image is rotated by a preset angle with each target square as the center point to obtain the corresponding rotated reference image, and the Euclidean distance between the rotated reference image and the target image is determined. The target square corresponding to the minimum Euclidean distance is determined as the center square.
8. An apparatus for determining the Region of Interest (ROI) of a test template image, characterized in that, The device includes: The preprocessing unit is used to preprocess the image to be tested on the test target plate to obtain the target image; The first determining unit is used to determine each target square in the target image; The second determining unit is used to determine the vertices of each target square and determine the region of interest (ROI) corresponding to the target square based on the vertices of the target square. The traversal unit is used to determine the center square in the target square, and traverse all target squares in a preset order starting from the center square. During the traversal, the ROI region of each target square is numbered in turn to obtain the ROI region sequence.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method according to any one of claims 1-7.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1-7.