Calibration method, system and storage medium
By using a calibration plate containing calibration blocks, the image processing of the shooting device is performed to calculate the calibration value, and the problems of complex calibration and low accuracy in the prior art are solved, and the calibration effect with high precision is achieved.
Patent Information
- Application Number
- CN202210338043.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2042-03-31
AI Technical Summary
In the prior art, the calibration method of the shooting device is complex, and the calibration needle production process is high, making it difficult to achieve high-precision calibration effect.
The calibration plate containing calibration blocks is used for calibration. By performing image processing steps such as grayscale processing, effective area extraction, angle correction, etc. on the target calibration image of the calibration plate, the target value is calculated and matched with the actual value to obtain the final calibration value.
It improves calibration accuracy, reduces the cost of calibration materials, is logically intuitive, and simplifies the calibration process.
Smart Images

Figure CN114648591B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular, to a calibration method and system and a storage medium. Background Art
[0002] Currently, photographing devices such as X-ray cameras are widely used in defect detection such as internal defect detection of battery cells. When using the photographing device, it is necessary to calibrate it to achieve better photographing effects.
[0003] The commonly used calibration method is to use a calibration needle for calibration. However, the algorithm logic used in the calibration process is extremely complex, and the manufacturing process of the calibration needle is extremely demanding, making it difficult to achieve a high calibration accuracy. Summary of the invention
[0004] In view of the above problems, the purpose of the embodiments of the present application is to provide a calibration method and system, which uses a calibration plate containing a calibration block to calibrate the shooting device, firstly, the target calibration image of the calibration plate is grayed; after obtaining the grayscale image, the effective area is extracted; after processing the effective area, the required target value is obtained, and the target value and the actual value are processed to obtain the final calibration value; the calibration method provided in the embodiments of the present application is logically intuitive, and the calibration problem is converted into an image processing problem, which effectively improves the calibration accuracy.
[0005] In a first aspect, an embodiment of the present application provides a calibration method, characterized in that the method is applied to the calibration of a shooting device, and the method includes: obtaining a target calibration image of a calibration plate; wherein the calibration plate includes a calibration block; gray-scaling the image to obtain a gray-scale image of the calibration plate; obtaining an image of an effective area of the calibration image based on the gray-scale image of the calibration plate; performing angle correction on the image of the effective area to obtain an image of a target calibration area and an image of the calibration block; obtaining a target value of the target calibration area based on the image of the target calibration area and the image of the calibration block; and obtaining a calibration value based on the target value of the target calibration area and an actual value of the target calibration area.
[0006] In the above implementation process, a target calibration image is photographed for a calibration plate including a calibration block, and the target calibration image of the calibration plate is grayed; after obtaining the gray image, effective area extraction is performed; after processing the effective area, the required target value is obtained, and the target value and the actual value are processed to obtain the final calibration value; the calibration block used in the above process has the characteristics of low cost, easy production, and long-term use, which overcomes the problem of expensive calibration materials in the current calibration technology; and at the same time, a high-precision calibration method is provided.
[0007] Optionally, in an embodiment of the present application, the target value includes a pixel value; obtaining the target value of the target calibration area according to the image of the target calibration area and the image of the calibration block includes: obtaining the image outer contour of the target calibration area and the image inner contour of the calibration block; fitting the image outer contour of the target calibration area and the image inner contour of the calibration block into a rectangle; obtaining the midpoint of the fitted rectangle of the calibration block; averaging the midpoints of the fitted rectangle of the calibration block in a first direction to obtain a first midpoint; and averaging two adjacent first midpoints in a second direction to obtain a second midpoint; wherein the first direction is orthogonal to the second direction, and the first midpoint and the second midpoint constitute a midpoint set; and obtaining the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area.
[0008] In the above implementation process, the outer contour of the target calibration area and the inner contour of the calibration block are accurately found during the calculation process, and the final pixel value is obtained by processing the midpoint of the calibration block. The pixel value of the calibration block is accurately calculated and applied to the calculation of the calibration value to obtain an accurate calibration value.
[0009] Optionally, in an embodiment of the present application, one of the first direction and the second direction is a vertical direction, and the other is a horizontal direction; obtaining the pixel value of the target calibration area based on the midpoint set and the image outer contour of the target calibration area includes: obtaining two points in the first direction on the outer contour based on the midpoint set and the image outer contour of the target calibration area; and subtracting the two points in the first direction on the outer contour to obtain the pixel value of the target calibration area.
[0010] In the above implementation process, the midpoint value is obtained in two orthogonal directions to obtain a midpoint set, and the pixel value of the target calibration area is calculated using the point set and the extracted image outer contour of the target calibration area for subsequent calculations. Obtaining the midpoint in two directions for the calculation of the pixel value can make the calculation result more accurate, thereby obtaining a calibration result with higher accuracy.
[0011] Optionally, in an embodiment of the present application, the effective area includes a first effective area and a second effective area; performing angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block, including: performing angle correction on the image of the first effective area to obtain an image of the second effective area; performing angle correction on the image of the second effective area to obtain an image of the target calibration area and an image of the calibration block.
[0012] In the above implementation process, the first effective area is first extracted, the second effective area is obtained after processing the first effective area, and the image of the target calibration area and the image of the calibration block are obtained by processing the second effective area. The angle between the effective area and the horizontal plane is corrected by angle correction. The embodiment of the present application performs angle correction on the first effective area and the second effective area successively, so that the non-angle image can be directly processed in subsequent processing, which can improve the calibration efficiency.
[0013] Optionally, in an embodiment of the present application, an image of the first effective area is angle-corrected to obtain an image of the second effective area, including: inverting the pixel points of the first effective area; extracting the outer contour of the image of the first effective area, and fitting the outer contour of the image of the first effective area into a closed figure; wherein the closed figure includes two parallel sides; and performing angle correction on the angle of the first effective area relative to the horizontal plane according to the inner angle of the closed figure to obtain an image of the second effective area.
[0014] In the above implementation process, the first effective area is firstly inverted to make the calibration block more prominent in the image; then the outer contour of the first effective area is fitted as a closed geometric figure containing two parallel edges, and then the angle between the closed geometric image and the horizontal plane is corrected to obtain the image of the second effective area, which facilitates processing and improves the accuracy of the final calibration result.
[0015] Optionally, in an embodiment of the present application, extracting the image outer contour of the first effective area and fitting the image outer contour of the first effective area into a closed figure includes: extracting all contours in the first effective area, the contours being composed of points; sorting all contours to obtain the contour with the most points; determining the contour with the most points as the image outer contour of the first effective area; and fitting the image outer contour of the first effective area into a closed figure with two parallel sides. By determining the contour with the most points as the outer contour of the first effective area, subsequent processing is made more accurate and effective.
[0016] Optionally, in an embodiment of the present application, obtaining an image of the effective area of the calibration image according to the grayscale image of the calibration plate includes: optimizing the grayscale image of the calibration plate; highlighting the calibration plate in the grayscale image of the calibration plate; and obtaining an image of the effective area of the calibration image. By optimizing the obtained grayscale image and highlighting the area containing the calibration block in the entire image, the accuracy of the overall calibration result is improved.
[0017] Optionally, in an embodiment of the present application, obtaining a calibration value according to a target value of the target calibration area and an actual value of the target calibration area includes: obtaining the actual value of the target calibration area; and obtaining an image conversion ratio of the target calibration area according to the target value of the target calibration area and the actual value of the target calibration area; wherein the pixel conversion ratio represents the calibration value. In an embodiment of the present application, the pixel conversion ratio is used to represent the calibration value, and the ratio of the pixel value to the actual value is used as the calibration value, which can accurately reflect whether the calibration is accurate.
[0018] In a second aspect, an embodiment of the present application provides a calibration system, characterized in that the system includes: an image acquisition module, an image processing module, and a calibration value acquisition module; wherein the image acquisition module is used to acquire a target calibration image of a calibration plate; wherein the calibration plate includes a calibration block; the image acquisition module is also used to grayscale the image to obtain a grayscale image of the calibration plate; the image processing module is used to obtain an image of an effective area of the calibration image based on the grayscale image of the calibration plate; the image of the effective area is angle-corrected to obtain an image of a target calibration area and an image of the calibration block; the calibration value acquisition module is used to obtain a target value of the target calibration area based on the image of the target calibration area and the image of the calibration block; and obtain a calibration value based on the target value of the target calibration area and the actual value of the target calibration area.
[0019] In the above implementation process, the image acquisition module calibrates the shooting device with a calibration plate containing a calibration block, firstly graying the target calibration image of the calibration plate; after obtaining the grayscale image, the image processing module extracts the effective area; after processing the effective area, the desired target value is obtained, and the calibration value acquisition module processes the target value and the actual value to obtain the final calibration value. The whole system has good stability and strong anti-interference ability, and the calibration system provided by the embodiment of the present application can obtain accurate calibration values.
[0020] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, which can read computer program instructions stored in the storage medium. When the computer program instructions are read and executed by a processor, the steps in any of the above implementation methods are executed.
[0021] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the steps in any of the above-mentioned implementation methods are executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A flow chart of a calibration method provided in an embodiment of the present application;
[0024] Figure 2 A flowchart of pixel value calculation of a target calibration area provided in an embodiment of the present application;
[0025] Figure 3 A flowchart of processing a valid area provided in an embodiment of the present application;
[0026] Figure 4 A flow chart of performing angle correction on an effective area provided in an embodiment of the present application;
[0027] Figure 5 A flowchart for extracting the outer contour of a valid area provided in an embodiment of the present application;
[0028] Figure 6 A flowchart for obtaining a valid area provided in an embodiment of the present application;
[0029] Figure 7 A flow chart for calculating calibration values provided in an embodiment of the present application;
[0030] Figure 8 A module diagram of a calibration system provided in an embodiment of the present application;
[0031] Figure 9(a) to Figure 9(g) A schematic diagram of a specific calibration process provided in an embodiment of the present application;
[0032] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented by a dedicated hardware-based system that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0034] During the research process, the applicant found that the current calibration method for the shooting device is to use a calibration needle for calibration. However, the calibration needle is expensive and has high requirements for the manufacturing process. The algorithm logic used is also relatively complex, making it difficult to achieve a good calibration effect.
[0035] Based on this, in order to achieve a better calibration effect, this application provides a calibration method and a calibration system, which transforms the calibration problem into an image processing problem of machine vision, and uses a logically intuitive algorithm to obtain a high-precision calibration result. Figure 1 , Figure 1 A flow chart of a calibration method provided in an embodiment of the present application, the calibration method comprising:
[0036] Step S100: Acquire a target calibration image of a calibration plate; wherein the calibration plate includes a calibration block; the target calibration image may be an X-ray image. It should be understood that the target image processed in the embodiment of the present application is merely exemplary, and in practical applications, the target calibration image may be an X-ray image or other images, and the X-ray image in the above steps should not be understood as a limitation on the target calibration image.
[0037] In the above step S100, a target calibration image is firstly photographed on a calibration plate, and the calibration plate may be a calibration auxiliary device containing a target block.
[0038] Step S101: grayscale the image to obtain a grayscale image of the calibration plate.
[0039] In the above step S101, the X-ray image obtained in step S100 is binarized to obtain a grayscale image of the calibration plate. Exemplarily, the color image can be converted into a grayscale image using the grayscale formula: Gray(i, j) = 0.299 × R(i, j) + 0.587 × G(i, j) + 0.144 × B(i, j), where Gray represents the grayscale value, (i, j) represents the coordinates of each pixel in the image, and RGB represents the color of the three channels of red, green, and blue at each corresponding coordinate. In addition, other methods of image grayscale processing, such as averaging, maximum and minimum average, weighted average, inverted image, etc., can also be used to convert an image into a grayscale image.
[0040] Step S102: obtaining an image of a valid area of the calibration image according to the grayscale image of the calibration plate.
[0041] In the above step S102, the portion of the grayscale image acquired in step S101 that is not blocked by the device is extracted as a valid area.
[0042] Step S103: performing angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block.
[0043] In the above step S103, the angle between the image of the effective area and the horizontal plane is corrected to obtain the image of the target calibration area and the image of the calibration block, wherein the angle correction can use an angle correction method such as Hought transform method, Radon transform method, least squares method, two-point method or affine transformation method.
[0044] Step S104: obtaining a target value of the target calibration area according to the image of the target calibration area and the image of the calibration block.
[0045] In the above step S104, a target value of the target calibration area is obtained from the image of the target calibration area and the image of the calibration block. The target value can reflect the pixels of the target calibration area.
[0046] Step S105: obtaining a calibration value according to the target value of the target calibration area and the actual value of the target calibration area.
[0047] In the above step S105, the calibration value is obtained from the target value of the target calibration area and the actual value of the calibration area. It should be noted that the calibration value can be the ratio of the target value to the actual value.
[0048] It can be seen that the flowchart of a calibration method provided in the embodiment of the present application obtains a grayscale image after processing the acquired color image; then extracts the effective area containing the calibration plate from the grayscale image; further performs angle correction on the effective area; and finally obtains the calibration value based on the calculated target value and actual value that can reflect the pixel. In the above process, the calibration plate is used as an auxiliary device for calibration. Since the calibration block is easy to make and inexpensive, the cost of calibration is greatly reduced; at the same time, the calibration is converted into image processing. The whole process is logically concise and easy to implement, which effectively improves the calibration accuracy.
[0049] Please see Figure 2 , Figure 2 A flowchart of calculating pixel values of a target calibration area provided in an embodiment of the present application, the method includes:
[0050] Step S200: obtaining the image outer contour of the target calibration area and the image inner contour of the calibration block.
[0051] In the above step S200, the image outer contour of the target calibration area and the image inner contour of the calibration block are obtained. It should be noted that the outer contour of the target calibration area is composed of a number of points.
[0052] Step S201: Fitting the image outer contour of the target calibration area and the image inner contour of the calibration block into a rectangle.
[0053] In the above step S201: the image outer contour of the target calibration area extracted in step S200 and the image inner contour of the calibration block are fitted into a rectangle.
[0054] Step S202: Obtain the midpoint of the calibration block fitting rectangle.
[0055] In the above step S202, the midpoint of the contour fitting rectangle in the calibrated block image in the above step S201 is extracted.
[0056] Step S203: average the midpoints of the calibration block fitting rectangle in the first direction to obtain a first midpoint; and average the two adjacent first midpoints in the second direction to obtain a second midpoint; wherein the first direction is orthogonal to the second direction, and the first midpoint and the second midpoint constitute a midpoint set.
[0057] In the above step S203, the midpoints of the calibration block fitting rectangle obtained in the above step S202 in any direction are first averaged to obtain the first midpoint; the first midpoints in another direction are averaged to obtain the second midpoint; it should be noted that the above two directions are orthogonal, and the first midpoints and the second midpoints in the above two directions form a midpoint set.
[0058] Step S204: obtaining pixel values of the target calibration area according to the midpoint set and the image outer contour of the target calibration area.
[0059] In the above step S204, the pixel value of the target calibration area is obtained according to the midpoint set obtained in the above step S203 and the outer contour of the target calibration area obtained in step S201.
[0060] It can be seen that the pixel value calculation flowchart of the target calibration area provided in the embodiment of the present application extracts the outer contour of the target calibration area and the inner contour of the calibration block, further obtains the midpoint of the calibration block, and then calculates the pixel value of the target calibration area based on the midpoint and the outer contour of the target calibration area.
[0061] In an optional embodiment, one of the first direction and the second direction is a vertical direction, and the other is a horizontal direction; obtaining the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area includes: obtaining two points in the first direction on the outer contour according to the midpoint set and the image outer contour of the target calibration area; and subtracting the two points in the first direction on the outer contour to obtain the pixel value of the target calibration area. Exemplarily, if the first direction is a horizontal direction and the second direction is a vertical direction; firstly, the midpoints of the calibration block in the vertical direction are averaged to obtain the first midpoint; the two adjacent first midpoints are averaged in turn in the horizontal direction to obtain the second midpoint; the second midpoint and the first midpoint constitute a midpoint set; the midpoint set can be assigned to a function y=x with an independent variable x, and then intersected with the outer contour of the target calibration area to obtain the intersection points; the two intersection points are subtracted in the vertical direction, and the absolute value of the difference is the pixel value of the target calibration area.
[0062] Please see Figure 3 , Figure 3 An embodiment of the present application provides a flowchart for processing a valid area, the method comprising:
[0063] It should be noted that the image of the effective area of the calibration image in step S102 of the above embodiment, wherein the effective area includes a first effective area and a second effective area; these two effective areas represent the gradual reduction of the processing area, reflecting the accuracy of the processing.
[0064] Step S300: performing angle correction on the image of the first effective area to obtain the image of the second effective area.
[0065] In the above step S300, an image of the first effective area is obtained according to the grayscale image of the calibration plate in step S101, and the angle of the first effective area is corrected to obtain the second effective area.
[0066] Step S301: performing angle correction on the image of the second effective area to obtain an image of the target calibration area and an image of the calibration block.
[0067] In the above step S301, the second effective area obtained in step S300 is angle-corrected to obtain a target calibration area.
[0068] It can be seen that the flowchart of processing the effective area provided in the embodiment of the present application shows that the image processing area is gradually reduced, and the area containing the calibration block is more accurately aligned step by step, thereby ensuring the final accurate calibration result.
[0069] Please see Figure 4 , Figure 4 An embodiment of the present application provides a flowchart for processing a valid area, the method comprising:
[0070] Step S400: inverting the pixels in the first effective area.
[0071] In the above step S400, the pixels of the first effective area are inverted. It can be understood that the pixel value of the grayscale image obtained in step S101 is 0 or 255, so here 0 is changed to 255 and 255 is changed to 0, and the black and white colors of the inverted image are reversed from those of the image before inversion.
[0072] Step S401: extracting the image outer contour of the first effective area, and fitting the image outer contour of the first effective area into a closed figure; wherein the closed figure includes two parallel edges.
[0073] In the above step S401, the outer contour of the first effective area after the black and white are inverted is extracted, and the extracted outer contour is fitted into a closed figure with two parallel sides, and the closed figure can be a rectangle.
[0074] Step S402: performing angle correction on the angle of the first effective area relative to the horizontal plane according to the inner angle of the closed figure to obtain an image of the second effective area.
[0075] In the above step S402, the closed figure obtained in step S402 is relative to the inner angle of the horizontal plane to obtain an image of the second effective area. Exemplarily, angle correction can be performed according to the inner angle of the rectangle, and the correction method can be Hought transformation method, Radon transformation method, least square method, two-point method or affine transformation method, etc.; the corrected angle is the angle between the first effective area and the horizontal plane.
[0076] It can be seen that the flowchart for angle correction of the effective area provided in the embodiment of the present application performs angle correction on the effective area of the acquired image so that the angle between the angled image and the horizontal plane is 0, making the subsequent extraction of the non-angled image more accurate and reliable.
[0077] Please see Figure 5 , Figure 5 The present application provides a flowchart for extracting the outer contour of a valid area, the method comprising:
[0078] Step S500: extracting all contours in the first effective area, where the contours are composed of points.
[0079] In the above step S500, the above first effective area substantially includes the calibration block and the second effective area, and all contours in the first effective area are extracted. These contours can be understood as closed curves composed of a number of points.
[0080] Step S501: sort all contours to obtain the contour with the most points; determine the contour with the most points as the image outer contour of the first valid area.
[0081] In the above step S501, all contours extracted in step S500 are sorted to obtain a contour with the most points; it can be understood that the first effective area has the largest area, and its outer contour is a curve with the most points, so the contour with the most points is used as the outer contour of the first effective area.
[0082] Step S502: fitting the image outer contour of the first effective area into a closed figure with two parallel sides.
[0083] In the above step S502, the outer contour of the first effective area extracted in step S501 is fitted into a closed figure with two parallel sides. For example, the closed figure can be a rectangle, a trapezoid, a parallelogram, etc.
[0084] The contour with the most points is taken as the outer contour of the first effective area, and then the outer contour of the first effective area is fitted to fit it into a closed figure of the characteristic shape. In this way, the calibration problem is successfully transformed into an image processing problem, and the image processing area is accurately obtained, which is conducive to obtaining high-precision calibration values later.
[0085] See also Figure 6 , Figure 6 The flowchart of calculating the calibration value provided in the embodiment of the present application includes:
[0086] Step S600: Optimizing the grayscale image of the calibration plate.
[0087] In the above step S600, the grayscale image obtained in step S101 is optimized, and the optimization may be: denoising, enhancement and other optimization operations.
[0088] Step S601: highlighting the calibration plate in the grayscale image of the calibration plate.
[0089] In the above step S601, the calibration plate is highlighted in the grayscale image of the calibration plate, and the obtained image is the image of the first effective area.
[0090] Step S602: Obtain an image of the effective area of the calibration image.
[0091] In an optional embodiment, obtaining an image of the effective area of the calibration image according to the grayscale image of the calibration plate includes: optimizing the grayscale image of the calibration plate, and the optimization of the grayscale image may be: denoising, enhancement and other optimization operations. The calibration plate is highlighted in the grayscale image of the calibration plate; and obtaining an image of the effective area of the calibration image, where the effective area obtained should be the first effective area including the second effective area.
[0092] See also Figure 7 , Figure 7 The flowchart of calculating the calibration value provided in the embodiment of the present application includes:
[0093] Step S701: Obtain the actual value of the target calibration area.
[0094] In the above step S701, the actual value of the target calibration area is obtained according to the actual size of the calibration plate.
[0095] Step S702: obtaining an image conversion ratio of the target calibration area according to the target value of the target calibration area and the actual value of the target calibration area; wherein the pixel conversion ratio represents the calibration value.
[0096] In the above step S702, the image conversion ratio of the target calibration area is obtained by comparing the actual value of the target calibration area obtained in step S701 with the target value obtained in step S104. Exemplarily, the target value is compared with the actual value of the target calibration area to obtain a pixel conversion ratio, which can represent the calibration value.
[0097] The actual value of the target calibration area is calculated with the pixel value to obtain the pixel conversion ratio that reflects the calibration value. The calibration problem is converted into an image processing problem of robot vision, thereby improving the accuracy of the calibration. The logic is clear and easy to understand.
[0098] See also Figure 8 , Figure 8 A module diagram of a calibration system provided in an embodiment of the present application, the system includes: an image acquisition module 801, an image processing module 802, and a calibration value acquisition module 803.
[0099] The image acquisition module 801 is used to acquire a target calibration image of a calibration plate; the target calibration image may be an X-ray image, wherein the calibration plate includes a calibration block.
[0100] The image acquisition module 801 is also used to perform grayscale processing on the image to obtain a grayscale image of the calibration plate.
[0101] The image processing module 802 is used to obtain an image of the effective area of the calibration image according to the grayscale image of the calibration plate obtained by the image acquisition module 801; perform angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block;
[0102] The calibration value acquisition module 803 is used to obtain the target value of the target calibration area according to the image of the target calibration area and the image of the calibration block obtained by the image processing module 802; and obtain the calibration value according to the target value of the target calibration area and the actual value of the target calibration area.
[0103] In an optional embodiment, the target value obtained by the calibration value acquisition module 803 includes a pixel value; the calibration value acquisition module 803 obtains the target value of the target calibration area according to the image of the target calibration area and the image of the calibration block obtained by the image processing module 802, including: the calibration value acquisition module 803 obtains the image outer contour of the target calibration area and the image inner contour of the calibration block; fits the image outer contour of the target calibration area and the image inner contour of the calibration block into a rectangle; obtains the midpoint of the fitted rectangle of the calibration block; the calibration value acquisition module 803 averages the midpoints of the fitted rectangle of the calibration block in a first direction to obtain a first midpoint; and averages two adjacent first midpoints in a second direction to obtain a second midpoint; wherein the first direction is orthogonal to the second direction, and the first midpoint and the second midpoint constitute a midpoint set; and the calibration value acquisition module 803 obtains the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area.
[0104] In an optional embodiment, one of the first direction and the second direction is a vertical direction, and the other is a horizontal direction; the calibration value acquisition module 803 acquires the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area, including: the calibration value acquisition module 803 acquires two points in the first direction on the outer contour according to the midpoint set and the image outer contour of the target calibration area; and subtracts the two points in the first direction on the outer contour to obtain the pixel value of the target calibration area.
[0105] In an optional embodiment, the effective area includes a first effective area and a second effective area; the image processing module 802 performs angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block, including: the image processing module 802 performs angle correction on the image of the first effective area to obtain an image of the second effective area; the image processing module 802 performs angle correction on the image of the second effective area to obtain an image of the target calibration area and an image of the calibration block.
[0106] In an optional embodiment, the image processing module 802 performs angle correction on the image of the first effective area to obtain an image of the second effective area, including: the image processing module 802 inverts the pixel points of the first effective area; extracts the image outer contour of the first effective area, and fits the image outer contour of the first effective area into a closed figure; wherein the closed figure includes two parallel edges; the image processing module 802 performs angle correction on the angle of the first effective area relative to the horizontal plane according to the inner angle of the closed figure to obtain the image of the second effective area.
[0107] In an optional embodiment, the image processing module 802 extracts the image outer contour of the first effective area and fits the image outer contour of the first effective area into a closed figure, including: the image processing module 802 extracts all contours in the first effective area, and the contours are composed of points; all contours are sorted to obtain the contour with the most points; the contour with the most points is determined as the image outer contour of the first effective area; and the image processing module 802 fits the image outer contour of the first effective area into a closed figure with two parallel edges.
[0108] In an optional embodiment, the image processing module 802 obtains an image of the effective area of the calibration image based on the grayscale image of the calibration plate, including: the image processing module 802 optimizes the grayscale image of the calibration plate; highlights the calibration plate in the grayscale image of the calibration plate; and obtains an image of the effective area of the calibration image.
[0109] In an optional embodiment, the calibration value acquisition module 803 obtains the calibration value according to the target value of the target calibration area and the actual value of the target calibration area, including: the calibration value acquisition module 803 obtains the actual value of the target calibration area; and obtains the image conversion ratio of the target calibration area according to the target value of the target calibration area and the actual value of the target calibration area; wherein the pixel conversion ratio represents the calibration value.
[0110] In a preferred embodiment, please refer to FIG. 9, which is a schematic diagram of the specific calibration process provided by the embodiment of the present application. First, an X-ray color calibration image is taken with an X-ray camera, and the color image is grayed to obtain a gray image of the calibration plate. The gray image is further optimized, which may be an optimization operation such as noise reduction and artifact removal, thereby obtaining a first effective area. On the basis of the first effective area, the outer contour of the first effective area is extracted to obtain the outermost black rectangular frame 901 shown in FIG. 9 (a). The first effective area is further angle-corrected to obtain a second effective area, and the second effective area is shown in FIG. 9 (b), and the image contains the entire calibration plate. The second effective area is inverted, and then the angle correction is performed again to obtain the target calibration area shown in FIG. 9 (c), in which the calibration block is the middle black part 902 shown in FIG. 9 (c). Further, the outer contour of the target calibration area of FIG. 9 (c) is fitted, and its outer contour is fitted into a rectangle, that is, the black rectangular frame 903 shown in FIG. 9 (d). The outer contour image of the target calibration area in FIG9(d) is further extracted to include only the calibration block, and the inversion operation is performed; the image of the calibration block shown in FIG9(e) is obtained. The midpoint of each calibration block is found, as shown in 904 in FIG9(f); the midpoints in the vertical direction are averaged, and the average is averaged again, thereby obtaining 5 points in the horizontal direction on the image, and these 5 points constitute a midpoint set. The above midpoint set is combined with the function y=x to obtain 5 vertical straight lines 905 as shown in FIG9(g), and the intersection points of these straight lines and the outer contour of the target calibration area are further obtained to obtain 5 groups of intersection points; the ordinates of these 5 groups of intersection points are subtracted from each other to obtain the pixel value of the target calibration area. Finally, the calculated pixel value is compared with the actual value of the target calibration area to obtain the pixel conversion ratio, which can be regarded as the calibration value.
[0111] Those skilled in the art may understand that the above embodiment is only a specific embodiment, and when performing the first fitting, it may not be fitted into the rectangle shown in FIG. 9(a), but may be any closed figure including two parallel sides; the calibration blocks are not limited to the number, size, shape and arrangement in the above embodiment, and the setting of each calibration block may be based on the goal of fitting the shape into a rectangle; the method for obtaining the midpoint may also be other methods other than the above method of first obtaining the vertical direction and then the horizontal direction, such as first obtaining the midpoint in the horizontal direction and then obtaining the average of the midpoints in the horizontal direction, etc., without departing from the scope of the present invention.
[0112] See also Fig.10 , Fig.10The electronic device 1000 provided in the embodiment of the present application includes: a processor 1001 and a memory 1002, wherein the memory 1002 stores machine-readable instructions executable by the processor 1001, and when the machine-readable instructions are executed by the processor 1001, the above method is executed.
[0113] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the steps in any of the above implementation methods are executed.
[0114] The computer-readable storage medium may be a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or any other medium that can store program codes. The storage medium is used to store the program, and the processor executes the program after receiving the execution instruction. The method executed by the electronic terminal of the process definition disclosed in any embodiment of the present invention can be applied to the processor or implemented by the processor.
[0115] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0116] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0117] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0118] Alternatively, the present invention may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented by software, the present invention may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part.
[0119] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0120] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0121] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A calibration method, characterized in that: The method comprises: Acquire a target calibration image of a calibration plate; wherein the calibration plate includes a calibration block; Performing grayscale processing on the target calibration image to obtain a grayscale image of the calibration plate; Obtaining an image of a valid area of the target calibration image according to the grayscale image of the calibration plate; Performing angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block; Obtaining a target value of the target calibration area according to the image of the target calibration area and the image of the calibration block; and Obtaining a calibration value according to a target value of the target calibration area and an actual value of the target calibration area; Wherein, the target value includes a pixel value; obtaining the target value of the target calibration area according to the image of the target calibration area and the image of the calibration block includes: obtaining the image outer contour of the target calibration area and the image inner contour of the calibration block; fitting the image outer contour of the target calibration area and the image inner contour of the calibration block into a rectangle; obtaining the midpoint of the fitted rectangle of the calibration block; averaging the midpoints of the fitted rectangle of the calibration block in a first direction to obtain a first midpoint; and averaging two adjacent first midpoints in a second direction to obtain a second midpoint; wherein the first direction is orthogonal to the second direction, and the first midpoint and the second midpoint constitute a midpoint set; and obtaining the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area.
2. The method according to claim 1, characterized in that in, One of the first direction and the second direction is a vertical direction, and the other is a horizontal direction; and obtaining the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area includes: Obtain two points in a first direction on the outer contour according to the midpoint set and the image outer contour of the target calibration area; and Subtract two points in the first direction on the outer contour to obtain the pixel value of the target calibration area.
3. The method according to claim 1, characterized in that in, The effective area includes a first effective area and a second effective area; the angle correction of the image of the effective area to obtain an image of the target calibration area and an image of the calibration block includes: performing angle correction on the image of the first effective area to obtain an image of the second effective area; and Angle correction is performed on the image of the second effective area to obtain an image of the target calibration area and an image of the calibration block.
4. The method according to claim 3, characterized in that The step of performing angle correction on the image of the first effective area to obtain the image of the second effective area includes: Inverting the pixels of the first effective area; Extracting the image outer contour of the first effective area, and fitting the image outer contour of the first effective area into a closed figure; wherein the closed figure includes two parallel sides; and The angle of the first effective area relative to the horizontal plane is corrected according to the inner angle of the closed figure to obtain an image of the second effective area.
5. The method according to claim 4, characterized in that The step of extracting the image outer contour of the first effective area and fitting the image outer contour of the first effective area into a closed figure includes: Extract all contours in the first effective area, wherein the contours are composed of points; Sorting all the contours to obtain the contour with the most points; determining the contour with the most points as the image outer contour of the first valid area; and The image outer contour of the first effective area is fitted into a closed figure having the two parallel sides.
6. The method according to claim 1, characterized in that The step of obtaining an image of a valid area of the calibration image according to the grayscale image of the calibration plate comprises: Optimizing the grayscale image of the calibration plate; highlighting the calibration plate in a grayscale image of the calibration plate; and An image of a valid area of the calibration image is obtained.
7. The method according to claim 1, characterized in that The obtaining of the calibration value according to the target value of the target calibration area and the actual value of the target calibration area includes: Obtaining an actual value of the target calibration area; and A pixel conversion ratio of the target calibration area is obtained according to the target value of the target calibration area and the actual value of the target calibration area; wherein the pixel conversion ratio represents the calibration value.
8. A calibration system, characterized in that: The system comprises: an image acquisition module, an image processing module, and a calibration value acquisition module; wherein, The image acquisition module is used to acquire a target calibration image of a calibration plate; wherein the calibration plate includes a calibration block; The image acquisition module is further used to perform grayscale processing on the target calibration image to obtain a grayscale image of the calibration plate; The image processing module is used to obtain an image of the effective area of the target calibration image according to the grayscale image of the calibration plate; perform angle correction on the image of the effective area to obtain an image of the target calibration area and an image of the calibration block; The calibration value acquisition module is used to obtain a target value of the target calibration area according to the image of the target calibration area and the image of the calibration block; and to obtain a calibration value according to the target value of the target calibration area and the actual value of the target calibration area; wherein the target value includes a pixel value; the obtaining of the target value of the target calibration area according to the image of the target calibration area and the image of the calibration block includes: obtaining an image outer contour of the target calibration area and an image inner contour of the calibration block; fitting the image outer contour of the target calibration area and the image inner contour of the calibration block into a rectangle; obtaining the midpoint of the calibration block fitted rectangle; averaging the midpoints of the calibration block fitted rectangle in a first direction to obtain a first midpoint; and averaging two adjacent first midpoints in a second direction to obtain a second midpoint; wherein the first direction is orthogonal to the second direction, and the first midpoint and the second midpoint constitute a midpoint set; and obtaining the pixel value of the target calibration area according to the midpoint set and the image outer contour of the target calibration area.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the steps in the method according to any one of claims 1 to 7 are executed.