A method and system for batch automatic correction of core photographs

By combining automatic rotation correction and bicubic interpolation algorithms, batch and rapid processing of core images has been achieved, solving the problems of low efficiency and insufficient accuracy in existing technologies, and generating core image results in a unified format.

CN122155959APending Publication Date: 2026-06-05POWERCHINA ZHONGNAN ENG

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
POWERCHINA ZHONGNAN ENG
Filing Date
2026-04-30
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies for editing and processing core images are inefficient and cannot meet the needs of large-scale engineering exploration projects for batch processing and rapid processing. Furthermore, the image correction accuracy is insufficient and the results are poorly standardized.

Method used

A batch automatic correction method for core images is provided. The method automatically rotates and corrects the images by extracting orientation markers from them. Technicians input corner coordinates on a graphical user interface, calculate the perspective transformation matrix, and resample the images using a bicubic interpolation algorithm to generate geometrically corrected core box images.

Benefits of technology

It enables batch automatic correction of core images, ensuring consistency in geometric accuracy and quality, improving work efficiency, simplifying the operation process, and preserving the original texture details and edge clarity of the cores.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122155959A_ABST
    Figure CN122155959A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of core image processing, and particularly relates to a batch automatic correction method and system for core photos, wherein the width and height of a target rectangle are calculated according to the coordinates of four corner points, a mapping relationship between the corner points and the top points of the target rectangle is established, and a perspective transformation matrix is solved, so that accurate geometric correction of shooting distortion is realized, and the corrected core tank image maintains correct geometric proportion. A bicubic interpolation algorithm model is used to resample the to-be-processed image, and a geometrically corrected core tank image is generated through weighted calculation of 16 surrounding neighborhood pixels, so that the geometric distortion is eliminated while the original texture details and edge definition of the core are effectively retained. The above steps are cyclically executed on all core photos, so that batch automatic correction of the core photos is realized, and it is ensured that the corrected images output in batches are consistent in geometric accuracy and image quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of core image processing technology, and specifically to a batch automatic correction method and system for core photographs. Background Technology

[0002] In the field of engineering geological exploration, borehole cores are one of the most direct and commonly used raw data for obtaining underground geological information. Borehole core photographs objectively and intuitively record the original state of the core, serving as a core basis for subsequent map drawing, report compilation, and engineering geological analysis and verification. Currently, in basic geological exploration work for water conservancy and hydropower projects, PowerPoint or Photoshop software is generally used for editing borehole core photographs. However, these software programs are general-purpose image or document processing tools, not specifically developed for core photograph editing, leading to the following prominent problems in practical applications: First, the operation process is extremely tedious, repetitive, and mechanical. Specific operations typically include: manually rotating and stretching each photograph to correct the shooting angle, manually inputting borehole numbers and depth information to generate titles, and manually importing scale images and repeatedly adjusting their size and position. Since an exploration project often involves a large number of core photographs, technicians are consumed by a large amount of low-value, repetitive labor, resulting in extremely low work efficiency.

[0003] Secondly, there is a lack of batch processing capabilities. Existing tools only support single-image editing and cannot achieve pipeline-style automated processing of multiple photos. Engineers must repeat the above tedious steps hundreds of times, which is not only extremely time-consuming but also prone to operational errors due to fatigue, affecting the overall progress and data accuracy of engineering geological exploration work.

[0004] Furthermore, manual editing methods also lead to problems such as poor standardization of outputs and insufficient image correction accuracy. For example, it is often difficult to unify the title format, scale ratio, and image alignment angle of photos processed by different personnel or in different batches; when manually stretching and correcting image distortion, it relies on personal experience and feel, making it difficult to guarantee the fidelity of core texture details and the accuracy of geometric proportions. Summary of the Invention

[0005] The main objective of this invention is to provide a batch automatic correction method and system for core images, in order to solve the technical problem that the core image editing and processing process in the prior art is inefficient and cannot meet the batch and rapid requirements of large-scale engineering exploration projects.

[0006] To achieve the above objectives, the present invention provides a batch automatic correction method for core images, comprising the following steps: S1. Obtain the current core image corresponding to the current core box, determine the orientation marker from the exchangeable image file format information of the current core image, and automatically rotate and correct the current core image according to the orientation marker to obtain the image to be processed after orientation correction. S2. Display the image to be processed on the graphical user interface, and receive the coordinates of the four corner points of the core box entered by the technician in a preset order on the graphical user interface; S3. Calculate the width and height of the target rectangle based on the coordinates of the four corner points; establish a mapping relationship between the four corner points and the four vertices of the target rectangle based on the width and height of the target rectangle; and obtain the perspective transformation matrix based on the mapping relationship. S4. Obtain a pre-set bicubic interpolation algorithm model, and resample the image to be processed according to the perspective transformation matrix using the bicubic interpolation algorithm model to generate a geometrically corrected core box image. S5. Repeat steps S1 to S4 for each core box of all core photos until all core photos generate geometrically corrected core box images.

[0007] Further, the step S1 of automatically rotating and correcting the current core image according to the orientation mark to obtain the orientation-corrected image to be processed specifically includes the following steps: S11. Read the orientation marker value from the exchangeable image file format information of the current core image; wherein, the orientation marker value is used to indicate the orientation state of the image sensor at the time of shooting; S12. Input the direction mark value into a predefined direction correction function; wherein, the direction correction function includes a mapping rule between the direction mark value and the rotation angle and / or flip operation; S13. The orientation correction function outputs the corresponding rotation angle and / or flip operation command according to the mapping rule; S14. Obtain the pixel matrix of the current core image, and perform corresponding rotation and / or flipping processing on the pixel matrix of the current core image according to the rotation angle and / or flip operation command to generate the image to be processed after orientation correction.

[0008] Furthermore, step S2 specifically includes the following steps: The image to be processed is displayed on a graphical user interface. Technicians click on the coordinates of the four corner points of the core box in the order of top left, top right, bottom left, and bottom right on the graphical user interface. The graphical user interface provides real-time feedback, including drawing marks and connecting lines at the clicked locations, and providing interactive functions such as undoing the previous point, rotating the image display, and skipping the current photo.

[0009] More preferably, step S3 specifically includes the following steps: S31. Based on the coordinates of the four corner points, calculate the first Euclidean distance between the top left corner point and the top right corner point as the upper side length, the second Euclidean distance between the bottom left corner point and the bottom right corner point as the lower side length, the third Euclidean distance between the top left corner point and the bottom left corner point as the left side length, and the fourth Euclidean distance between the top right corner point and the bottom right corner point as the right side length. S32. Calculate the arithmetic mean of the upper side length and the lower side length, and round the arithmetic mean to the nearest integer, and use the rounded result as the width value of the target rectangle. S33. Compare the left length with the right length, and take the maximum value of the left length and the right length as the height value of the target rectangle; S34. Based on the width and height of the target rectangle, determine the coordinates of the four vertices of the target rectangle, where the coordinates of the top left vertex are (0,0), the top right vertex is (0,0), and the height is (0,0). ,0), coordinates of the lower left vertex (0, ), coordinates of the lower right vertex ( , );in, This represents the width of the target rectangle. This represents the height value of the target rectangle; S35. Establish a point-to-point mapping relationship between the coordinates of the four corner points and the coordinates of the four vertices of the target rectangle; wherein, the coordinates of the four corner points are used as the source point set, and the coordinates of the four vertices of the target rectangle are used as the target point set; S36. Convert the coordinates of each source point in the source point set and the corresponding target point coordinates in the target point set into homogeneous coordinates. Construct a system of linear equations based on the homogeneous coordinates. Solve the system of linear equations to obtain a 3×3 perspective transformation matrix. The perspective transformation matrix satisfies the homogeneous coordinate relationship that maps any point in the source point set to the corresponding point in the target point set after transformation.

[0010] Furthermore, the bicubic interpolation algorithm model described in step S4 is defined as R(t), with the following expression: ; In the formula, t is the independent variable, which is the offset between the position to be calculated and the center of the neighboring pixels.

[0011] More preferably, step S4 specifically includes the following steps: S41. Obtain the width value of the target rectangle. and height value According to the width value and the height value Create a blank output image matrix O; wherein the number of rows in the output image matrix O is equal to the height value. The number of columns is equal to the width value. ; S42. Perform an inverse operation on the perspective transformation matrix to obtain the perspective transformation inverse matrix. The perspective transformation matrix is ​​M. S43. For each pixel in the output image matrix O, use the column coordinates of that pixel... As the x-coordinate and x-coordinate of the target point As the ordinate of the target point, construct the target point coordinate pair. ; S44. Pair the target point coordinates Convert to homogeneous coordinate form Then, with the inverse matrix of the perspective transformation Multiply to obtain the homogeneous coordinates of the source point in the image to be processed, corresponding to the coordinates of the target point. The calculation formula is: ; S45. For the homogeneous coordinates of the source point Normalization is performed to obtain the floating-point coordinates of the source point in the image to be processed. Where x = x′ / w′, y = y′ / w′, and the source point floating-point coordinates are... It includes a floating-point x-coordinate and a floating-point y-coordinate; S46. Round down the floating-point x-coordinate and the floating-point y-coordinate respectively to obtain the integer coordinates of the source point. , where i= j= And calculate the first decimal deviation Δx=xi between the floating-point abscissa x and the source point integer abscissa i, and the second decimal deviation Δy=yj between the floating-point ordinate y and the source point integer ordinate j; S47, using the source point integer coordinates Centered on the corresponding pixel, a 4×4 16-neighbor pixel set {I(i+m,j+n)|m∈[-1,2],n∈[-1,2]} is determined in the image to be processed, where I represents the pixel matrix of the image to be processed, and m and n are integer indices; S48. For each neighboring pixel I(i+m,j+n) in the set of 16 neighboring pixels, calculate the first weight coefficient R(m-Δx) in the row direction and the second weight coefficient R(n-Δy) in the column direction. Multiply the first weight coefficient and the second weight coefficient to obtain the comprehensive weight coefficient of the neighboring pixel. ; S49. Multiply the pixel value I(i+m,j+n) of each neighboring pixel in the 16-neighboring pixel set by the corresponding comprehensive weight coefficient. The 16 product results are summed to obtain the output pixel value corresponding to the target point coordinate pair q. The calculation formula is: ; S410, Output pixel value The value is assigned to the position in the output image matrix O. Matrix elements; S411. Traverse all pixels in the output image matrix and repeat steps S43 to S410 until all matrix elements are assigned values ​​to obtain a complete output image matrix O. The output image matrix O is the geometrically corrected core box image.

[0012] More preferably, step S4 further includes the following steps: Before executing step S47, determine the integer coordinates of the source point. Whether it is located within the boundary region of the image to be processed, the boundary region is defined as the region whose row coordinate is less than 1 or greater than or equal to the image height minus 2, or whose column coordinate is less than 1 or greater than or equal to the image width minus 2; If the source point integer coordinates If the pixel is located within the boundary region, the rules for determining the set of 16 neighboring pixels are adjusted, specifically including: When the integer y-coordinate j of the source point is less than 1, the row range is adjusted to be from 0 to 3; When the integer ordinate j of the source point is greater than or equal to H-2, the row range is adjusted to be from H-4 to H-1, where H is the height of the image to be processed; When the integer x-coordinate i of the source point is less than 1, the column range is adjusted to be from 0 to 3; When the integer x-coordinate of the source point i ≥ W-2, the column range is adjusted to be from W-4 to W-1, where W is the width of the image to be processed; The set of 16 neighboring pixels is redefined based on the adjusted row and column ranges; For each neighboring pixel in the newly determined set of 16 neighboring pixels, its corresponding row offset m and column offset n are recalculated based on the adjusted row and column ranges. Based on the recalculated row offset m and column offset n, steps S48 to S49 are executed to obtain the output pixel value O corresponding to the target point coordinate pair q. .

[0013] More preferably, after step S5, the following steps are also included: S6. Obtain a structured parameter file containing borehole identifiers, the total number of core boxes, and the termination depth data corresponding to each core box. Generate title text for each core box based on the borehole identifiers and termination depth data. Generate a title bar image based on the title text. S7. Obtain the preset scale configuration information for each box of rock cores, generate the corresponding scale image according to the scale configuration information, and stitch together the title bar image, scale image and geometrically corrected rock core box image of each box of rock cores according to the predetermined layout to generate a standardized result image of each box of rock cores, thereby completing the batch editing of rock core photos.

[0014] More preferably, the title bar image in step S6 is generated through the following steps: Obtain a pre-stored font matrix library. Based on the title text, retrieve the binarized matrix corresponding to each character from the font matrix library. Horizontally concatenate the binarized matrices of each character and scale them to a size that matches the width of the geometrically corrected core box image. Then, center them within the title area of ​​a preset height.

[0015] More preferably, the scale image in step S7 includes a horizontal scale and / or a vertical scale; the horizontal scale is loaded with a corresponding horizontal scale image according to the scale length selected by the technician, and the width of the horizontal scale image is scaled to be equal to the width of the geometrically corrected core box image before being stitched to the bottom of the image; the vertical scale is selected from a preset set of vertical scale sizes according to the height-to-width ratio of the geometrically corrected core box image, and the corresponding vertical scale image is loaded with a corresponding vertical scale image, and the height of the vertical scale image is scaled to be equal to the height of the geometrically corrected core box image before being stitched to the left side of the image.

[0016] This invention also provides a batch automatic correction system for core images, which applies the batch automatic correction method for core images as described above, including: The parameter input module is used to acquire and parse the structured parameter file and generate title text that corresponds one-to-one with the core photos of each box of cores; The image preprocessing module is used to obtain the current core image corresponding to the current core box, determine the orientation mark from the exchangeable image file format information of the current core image, and automatically rotate and correct the current core image according to the orientation mark to obtain the orientation-corrected image to be processed. The interactive calibration module is used to display images on the graphical user interface and receive the coordinates of the four corner points of the core box as input by technicians. The geometric correction module is used to determine the size of the target rectangle based on the coordinates of the four corner points, solve the perspective transformation matrix, and use a bicubic interpolation algorithm to resample the image to obtain the geometrically corrected core box image. The plotting and compositing module is used to generate a title bar image based on the title text, generate a scale image based on the preset scale configuration information, and combine the title bar image, scale image and geometrically corrected core box image into a standardized result image. The output module is used to save the standardized output diagram to a storage medium; The control module is used to control the cyclic processing of core photos from each box of cores until all core photos have been processed.

[0017] Compared with the prior art, the present invention has the following beneficial effects: This invention eliminates image orientation ambiguity caused by shooting posture by extracting orientation markers from core photographs and automatically rotating and correcting them, ensuring that subsequent processing is based on images with a unified orientation. The graphical user interface receives the coordinates of the four corner points of the core box, entered by technicians in a preset order, simplifying the complex image correction task into an intuitive interactive calibration and lowering the operational threshold. The width and height of the target rectangle are calculated based on the four corner point coordinates, establishing a mapping relationship between the corner points and the vertices of the target rectangle, and solving the perspective transformation matrix, achieving precise geometric correction of shooting distortion and maintaining the correct geometric proportions of the corrected core box image. A bicubic interpolation algorithm is used to resample the image to be processed, generating a geometrically corrected core box image through weighted calculation of the surrounding 16 neighboring pixels, effectively preserving the original texture details and edge sharpness of the core while eliminating geometric distortion. The above steps are repeated for all core photographs, achieving batch automatic correction of core photographs and ensuring that the corrected images output in batches maintain consistent geometric accuracy and image quality. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating a batch automatic correction method for core images according to an embodiment of the present invention.

[0020] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0021] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0023] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.

[0024] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Additionally, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed by this invention.

[0025] Please see Figure 1 This embodiment provides a batch automatic correction method for core images, including the following steps: S1. Obtain the current core image corresponding to the current core box, determine the orientation marker from the exchangeable image file format information (EXIF information) of the current core image, and automatically rotate and correct the current core image according to the orientation marker to obtain the image to be processed after orientation correction. S2. Display the image to be processed on the graphical user interface, and receive the coordinates of the four corner points of the core box entered by the technician in a preset order on the graphical user interface; S3. Calculate the width and height of the target rectangle based on the coordinates of the four corner points; establish a mapping relationship between the four corner points and the four vertices of the target rectangle based on the width and height of the target rectangle; and obtain the perspective transformation matrix based on the mapping relationship. S4. Obtain a pre-set bicubic interpolation algorithm model, and resample the image to be processed according to the perspective transformation matrix using the bicubic interpolation algorithm model to generate a geometrically corrected core box image. S5. Repeat steps S1 to S4 for each core box of all core photos until all core photos generate geometrically corrected core box images.

[0026] This embodiment eliminates image orientation ambiguity caused by shooting posture by extracting orientation markers from core images and automatically rotating and correcting them, ensuring that subsequent processing is based on images with a unified orientation. The graphical user interface receives the coordinates of the four corner points of the core box, entered by technicians in a preset order, simplifying the complex image correction task into an intuitive interactive calibration and lowering the operational threshold. The width and height of the target rectangle are calculated based on the four corner point coordinates, establishing a mapping relationship between the corner points and the vertices of the target rectangle, and solving the perspective transformation matrix, achieving precise geometric correction of shooting distortion and maintaining the correct geometric proportions of the corrected core box image. A bicubic interpolation algorithm is used to resample the image to be processed, generating a geometrically corrected core box image through weighted calculation of the surrounding 16 neighboring pixels, effectively preserving the original texture details and edge sharpness of the core while eliminating geometric distortion. The above steps are repeated for all core images, achieving batch automatic correction of core images and ensuring that the corrected images output in batches maintain consistent geometric accuracy and image quality.

[0027] In this embodiment, step S1, which involves automatically rotating and correcting the current core image based on the orientation marker to obtain the orientation-corrected image to be processed, specifically includes the following steps: S11. Read the orientation marker value from the exchangeable image file format information of the current core image; wherein, the orientation marker value is used to indicate the orientation state of the image sensor at the time of shooting; S12. Input the direction mark value into a predefined direction correction function; wherein, the direction correction function includes a mapping rule between the direction mark value and the rotation angle and / or flip operation; S13. The orientation correction function outputs the corresponding rotation angle and / or flip operation command according to the mapping rule; S14. Obtain the pixel matrix of the current core image, and perform corresponding rotation and / or flipping processing on the pixel matrix of the current core image according to the rotation angle and / or flip operation command to generate the image to be processed after orientation correction.

[0028] In this embodiment, specifically, for the i-th core image, the system reads the pixel matrix of the current core image. In the formula, H represents a non-negative integer, H represents the height, and W represents the width.

[0029] The orientation marker value θ in the EXIF ​​information of the current core image is detected. The pixel matrix of the current core image is then automatically rotated or flipped using the commonly used orientation correction function Orient(·) to obtain the correctly oriented image to be processed. This embodiment ensures that each core image is automatically aligned to a uniform observation direction before entering the subsequent process, eliminating image orientation confusion caused by differences in shooting and holding postures, and making the orientation correction operation seamlessly connected with the subsequent corner point calibration steps.

[0030] Furthermore, step S2 specifically includes the following steps: The image to be processed is displayed on a graphical user interface. Technicians click on the coordinates of the four corner points of the core box in the order of top left, top right, bottom left, and bottom right on the graphical user interface. The graphical user interface provides real-time feedback, including drawing marks and connecting lines at the clicked locations, and providing interactive functions such as undoing the previous point, rotating the image display, and skipping the current photo.

[0031] Specifically, the image to be processed is displayed through a graphical interface. The graphical user interface guides technicians to click in a fixed order, such as top left → top right → bottom left → bottom right, to select the four corner points of the core box and form a point set. ,in The graphical user interface provides real-time feedback during the interaction: left-click to select a point and draw a red marker and connecting line; left-click to undo the previous point; press the R key to rotate the image to be processed 90° clockwise to adapt to different shooting angles; press the S key to skip the current core image; press the spacebar to confirm and proceed to the next step after selecting 4 points.

[0032] As a further preferred embodiment, step S3 specifically includes the following steps: S31. Based on the coordinates of the four corner points, calculate the first Euclidean distance between the top left corner point and the top right corner point as the upper side length, the second Euclidean distance between the bottom left corner point and the bottom right corner point as the lower side length, the third Euclidean distance between the top left corner point and the bottom left corner point as the left side length, and the fourth Euclidean distance between the top right corner point and the bottom right corner point as the right side length. S32. Calculate the arithmetic mean of the upper side length and the lower side length, and round the arithmetic mean to the nearest integer, and use the rounded result as the width value of the target rectangle. S33. Compare the left length with the right length, and take the maximum value of the left length and the right length as the height value of the target rectangle; S34. Based on the width and height of the target rectangle, determine the coordinates of the four vertices of the target rectangle, wherein the coordinates of the four vertices are the top left vertex (0,0), the top right vertex (width,0), the bottom left vertex (0,height), and the bottom right vertex (width,height). S35. Establish a point-to-point mapping relationship between the coordinates of the four corner points and the coordinates of the four vertices of the target rectangle; wherein, the coordinates of the four corner points are used as the source point set, and the coordinates of the four vertices of the target rectangle are used as the target point set; S36. Convert the coordinates of each source point in the source point set and the corresponding target point coordinates in the target point set into homogeneous coordinates. Construct a system of linear equations based on the homogeneous coordinates. Solve the system of linear equations to obtain a 3×3 perspective transformation matrix. The perspective transformation matrix satisfies the homogeneous coordinate relationship that maps any point in the source point set to the corresponding point in the target point set after transformation.

[0033] Specifically, the formula is: ; In the formula, ‖·‖ represents the Euclidean distance, and round(·) represents rounding to the nearest integer. The width value of the target rectangle. This represents the height of the target rectangle.

[0034] Establish source set With the target point set The mapping relationship is obtained by solving the linear equation system. The 3×3 perspective transformation matrix M satisfies the transformation relationship D'~M·S' in homogeneous coordinates, where S' and D' are the homogeneous coordinate forms of S and D, respectively.

[0035] This embodiment calculates the Euclidean distances between the four corner points to obtain the lengths of the top, bottom, left, and right sides, providing a precise geometric measurement basis for correction. The arithmetic mean of the top and bottom lengths is rounded down to obtain the target rectangle width, and the maximum of the left and right lengths is taken as the target rectangle height, ensuring the corrected core box image is visually proportionally consistent and retains all valid content. A point-to-point mapping relationship is established between the corner coordinates and the vertex coordinates of the target rectangle. A system of linear equations is constructed using homogeneous coordinates to solve the perspective transformation matrix, achieving a precise geometric transformation from the distorted image to a regular rectangle. This transformation matrix can map any point in the source point set to the homogeneous coordinate position of the corresponding point in the target point set, providing an accurate pixel position mapping basis for subsequent image resampling and ensuring the correct geometric relationship of the corrected image.

[0036] In one embodiment, the bicubic interpolation algorithm model described in step S4 is defined as R(t), with the following expression: ; In the formula, t is the independent variable, which is the offset between the position to be calculated and the center of the neighboring pixels.

[0037] In this embodiment, step S4 is further preferably included in the following steps: S41. Obtain the width value of the target rectangle. and height value According to the width value and the height value Create a blank output image matrix O; wherein the number of rows in the output image matrix O is equal to the height value. The number of columns is equal to the width value. ; S42. Perform an inverse operation on the perspective transformation matrix M to obtain the perspective transformation inverse matrix. ; S43. For each pixel in the output image matrix O, use the column coordinates of that pixel... As the x-coordinate and x-coordinate of the target point As the ordinate of the target point, construct the target point coordinate pair. ; S44. Pair the target point coordinates Convert to homogeneous coordinate form Then, with the inverse matrix of the perspective transformation Multiply to obtain the homogeneous coordinates of the source point in the image to be processed, corresponding to the coordinates of the target point. The calculation formula is: ; S45. For the homogeneous coordinates of the source point Normalization is performed to obtain the floating-point coordinates of the source point in the image to be processed. Where x = x′ / w′, y = y′ / w′, and the source point floating-point coordinates are... It includes a floating-point x-coordinate and a floating-point y-coordinate; S46. Round down the floating-point x-coordinate and the floating-point y-coordinate respectively to obtain the integer coordinates of the source point. , where i= j= And calculate the first decimal deviation Δx=xi between the floating-point abscissa x and the source point integer abscissa i, and the second decimal deviation Δy=yj between the floating-point ordinate y and the source point integer ordinate j; S47, using the source point integer coordinates Centered on the corresponding pixel, a 4×4 16-neighbor pixel set {I(i+m,j+n)|m∈[-1,2],n∈[-1,2]} is determined in the image to be processed, where I represents the pixel matrix of the image to be processed, and m and n are integer indices; S48. For each neighboring pixel I(i+m,j+n) in the set of 16 neighboring pixels, calculate the first weight coefficient R(m-Δx) in the row direction and the second weight coefficient R(n-Δy) in the column direction. Multiply the first weight coefficient and the second weight coefficient to obtain the comprehensive weight coefficient of the neighboring pixel. ; S49. Multiply the pixel value I(i+m,j+n) of each neighboring pixel in the 16-neighboring pixel set by the corresponding comprehensive weight coefficient. The 16 product results are summed to obtain the output pixel value corresponding to the target point coordinate pair q. The calculation formula is: ; S410, Output pixel value The value is assigned to the position in the output image matrix O. Matrix elements; S411. Traverse all pixels in the output image matrix and repeat steps S43 to S410 until all matrix elements are assigned values ​​to obtain a complete output image matrix O. The output image matrix O is the geometrically corrected core box image.

[0038] This embodiment creates a blank output image matrix by obtaining the width and height values ​​of the target rectangle, providing a precise storage structure for the corrected image. The perspective transformation matrix is ​​inverted to convert the coordinates of each target point in the output image into homogeneous coordinates, which are then multiplied by the inverse matrix to calculate the corresponding homogeneous coordinates of the source point in the original image. The homogeneous coordinates of the source point are normalized to obtain floating-point coordinates. By rounding down, integer coordinates are obtained, and the first and second decimal deviations are calculated, establishing a precise positional correspondence between the target point and the pixels in the original image. A 16-neighborhood pixel set is determined centered on the integer coordinates of the source point. The row offset minus the first decimal deviation and the column offset minus the second decimal deviation are input into the bicubic interpolation algorithm model. The first and second weighting coefficients are calculated and multiplied to obtain the comprehensive weighting coefficient. The pixel values ​​of the 16 neighboring pixels are multiplied by their corresponding comprehensive weighting coefficients and summed to obtain the output pixel value of the target point, which is then assigned to the corresponding position in the output image matrix. Repeat the above process by traversing all pixels in the output image matrix to finally generate a complete geometrically corrected core box image, which preserves the texture details and edge sharpness of the original core to the greatest extent while correcting geometric distortion.

[0039] In one embodiment, as a further preferred embodiment, step S4 further includes the following steps: Before executing step S47, determine the integer coordinates of the source point. Whether it is located within the boundary region of the image to be processed, the boundary region is defined as the region whose row coordinate is less than 1 or greater than or equal to the image height minus 2, or whose column coordinate is less than 1 or greater than or equal to the image width minus 2; If the source point integer coordinates If the pixel is located within the boundary region, the rules for determining the set of 16 neighboring pixels are adjusted, specifically including: When the integer y-coordinate j of the source point is less than 1, the row range is adjusted to be from 0 to 3; When the integer ordinate j of the source point is greater than or equal to H-2, the row range is adjusted to be from H-4 to H-1, where H is the height of the image to be processed; When the integer x-coordinate i of the source point is less than 1, the column range is adjusted to be from 0 to 3; When the integer x-coordinate of the source point i ≥ W-2, the column range is adjusted to be from W-4 to W-1, where W is the width of the image to be processed; The set of 16 neighboring pixels is redefined based on the adjusted row and column ranges; For each neighboring pixel in the newly determined set of 16 neighboring pixels, its corresponding row offset m and column offset n are recalculated based on the adjusted row and column ranges. Based on the recalculated row offset m and column offset n, steps S48 to S49 are executed to obtain the output pixel value O corresponding to the target point coordinate pair q. .

[0040] This embodiment proactively identifies edge pixel locations requiring special processing by determining whether the source point's integer coordinates are located within the image boundary region before resampling. When the source point's integer coordinates are located within the boundary region, the row and column ranges of the sixteen neighboring pixel set are dynamically adjusted based on its specific location, ensuring that the neighboring pixels are always within the effective pixel range of the image to be processed. The adjusted row and column offsets are recalculated, and weight coefficients are calculated and weighted summation is performed based on the adjusted offsets, ensuring that the target point coordinates in the boundary region also obtain complete neighboring pixels for interpolation. This dynamic adjustment mechanism guarantees that the entire corrected image, from the center to the edge, can be processed using a consistent bicubic interpolation algorithm, avoiding computational deviations caused by missing neighbors for boundary pixels, and ensuring that the corrected core box image maintains the same texture detail preservation capability and visual continuity throughout the entire image.

[0041] More preferably, after step S5, the following steps are also included: S6. Obtain a structured parameter file containing borehole identifiers, the total number of core boxes, and the termination depth data corresponding to each core box. Generate title text for each core box based on the borehole identifiers and termination depth data. Generate a title bar image based on the title text. S7. Obtain the preset scale configuration information for each box of rock cores, generate the corresponding scale image according to the scale configuration information, and stitch together the title bar image, scale image and geometrically corrected rock core box image of each box of rock cores according to the predetermined layout to generate a standardized result image of each box of rock cores, thereby completing the batch editing of rock core photos.

[0042] More preferably, the title bar image in step S6 is generated through the following steps: Obtain a pre-stored font matrix library. Based on the title text, retrieve the binarized matrix corresponding to each character from the font matrix library. Horizontally concatenate the binarized matrices of each character and scale them to a size that matches the width of the geometrically corrected core box image. Then, center them within the title area of ​​a preset height.

[0043] Specifically, create a height of The yellow stripe (RGB(253,253,0)) serves as the title area. Using a "movable type printing" method, the binary matrix corresponding to each character in the title text is retrieved from a pre-stored font matrix library. These binary matrices are then horizontally concatenated, scaled to a suitable size, and centered within the title area.

[0044] More preferably, the scale image in step S7 includes a horizontal scale and / or a vertical scale; the horizontal scale is loaded with a corresponding horizontal scale image according to the scale length selected by the technician, and the width of the horizontal scale image is scaled to be equal to the width of the geometrically corrected core box image before being stitched to the bottom of the image; the vertical scale is selected from a preset set of vertical scale sizes according to the height-to-width ratio of the geometrically corrected core box image, and the corresponding vertical scale image is loaded with a corresponding vertical scale image, and the height of the vertical scale image is scaled to be equal to the height of the geometrically corrected core box image before being stitched to the left side of the image.

[0045] Specifically, for the horizontal ruler: if the technician selects the ruler length L (0.8m or 1.0m), then load the corresponding ruler image, scale its width to W, and stitch it to the bottom of the image.

[0046] For the vertical scale: calculate the visual scale factor r=H of the core box. i / W i The physical height is derived to be approximately L×r. The closest size is selected from the preset size set {0.20, 0.25, …, 0.60}, the corresponding vertical scale image is loaded, and its height is scaled to Hᵢ before being stitched to the left side of the image.

[0047] Furthermore, following the sequence of "vertical scale - title block - corrected core image - horizontal scale", the image blocks are stitched together in the vertical or horizontal direction to generate the final standard result image.

[0048] Preferably, the final standard output image is saved in JPEG format with a compression quality set to 97%, controlling the file size while ensuring visual losslessness. The filename uses title text and is uniformly stored in a folder named after the borehole number.

[0049] The above embodiments significantly improve work efficiency: the batch processing function reduces the editing time of dozens of core images from several hours to just a few minutes. They also improve image processing accuracy: employing bicubic interpolation perspective transformation effectively eliminates shooting distortion and preserves core texture details. Unified output format: automatically generated titles and scales conform to geological exploration mapping standards, enhancing the professionalism and consistency of the data. Lowered operational threshold: the graphical user interface is simple and intuitive, requiring no professional image processing skills to operate. High adaptability and scalability: supporting multiple image formats and scale types, it can be configured and expanded according to different engineering needs. Advancing digitization and standardization: providing a high-quality image foundation for the digital management, intelligent identification, and analysis of geological exploration data.

[0050] This invention also provides a batch automatic correction system for core images, which applies the batch automatic correction method for core images as described above, including: The parameter input module is used to acquire and parse the structured parameter file and generate title text that corresponds one-to-one with the core photos of each box of cores; The image preprocessing module is used to obtain the current core image corresponding to the current core box, determine the orientation mark from the exchangeable image file format information of the current core image, and automatically rotate and correct the current core image according to the orientation mark to obtain the orientation-corrected image to be processed. The interactive calibration module is used to display images on the graphical user interface and receive the coordinates of the four corner points of the core box as input by technicians. The geometric correction module is used to determine the size of the target rectangle based on the coordinates of the four corner points, solve the perspective transformation matrix, and use a bicubic interpolation algorithm to resample the image to obtain the geometrically corrected core box image. The plotting and compositing module is used to generate a title bar image based on the title text, generate a scale image based on the preset scale configuration information, and combine the title bar image, scale image and geometrically corrected core box image into a standardized result image. The output module is used to save the standardized output diagram to a storage medium; The control module is used to control the cyclic processing of core photos from each box of cores until all core photos have been processed.

[0051] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A batch automatic correction method for core images, characterized in that, Includes the following steps: S1. Obtain the current core image corresponding to the current core box, determine the orientation marker from the exchangeable image file format information of the current core image, and automatically rotate and correct the current core image according to the orientation marker to obtain the image to be processed after orientation correction. S2. Display the image to be processed on the graphical user interface, and receive the coordinates of the four corner points of the core box entered by the technician in a preset order on the graphical user interface; S3. Calculate the width and height of the target rectangle based on the coordinates of the four corner points; establish a mapping relationship between the four corner points and the four vertices of the target rectangle based on the width and height of the target rectangle; and obtain the perspective transformation matrix based on the mapping relationship. S4. Obtain a pre-set bicubic interpolation algorithm model, and resample the image to be processed according to the perspective transformation matrix through the bicubic interpolation algorithm model to generate a geometrically corrected core box image. S5. Repeat steps S1 to S4 for each core box of all core photos until all core photos generate geometrically corrected core box images.

2. The batch automatic correction method for core images according to claim 1, characterized in that, Step S1, which involves automatically rotating and correcting the current core image based on the orientation markers to obtain the orientation-corrected image to be processed, specifically includes the following steps: S11. Read the orientation marker value from the exchangeable image file format information of the current core image; wherein, the orientation marker value is used to indicate the orientation state of the image sensor at the time of shooting; S12. Input the direction mark value into a predefined direction correction function; wherein, the direction correction function includes a mapping rule between the direction mark value and the rotation angle and / or flip operation; S13. The orientation correction function outputs the corresponding rotation angle and / or flip operation command according to the mapping rule; S14. Obtain the pixel matrix of the current core image, and perform corresponding rotation and / or flipping processing on the pixel matrix of the current core image according to the rotation angle and / or flip operation command to generate the image to be processed after orientation correction.

3. The batch automatic correction method for core images according to claim 1, characterized in that, Step S3 specifically includes the following steps: S31. Display the image to be processed on the graphical user interface. The technician clicks on the input coordinates of the four corner points of the core box on the graphical user interface in the order of top left, top right, bottom left, and bottom right. Based on the coordinates of the four corner points, calculate the first Euclidean distance between the top left and top right corner points as the top length, the second Euclidean distance between the bottom left and bottom right corner points as the bottom length, the third Euclidean distance between the top left and bottom left corner points as the left length, and the fourth Euclidean distance between the top right and bottom right corner points as the right length. S32. Calculate the arithmetic mean of the upper side length and the lower side length, and round the arithmetic mean to the nearest integer, and use the rounded result as the width value of the target rectangle. S33. Compare the left length with the right length, and take the maximum value of the left length and the right length as the height value of the target rectangle; S34. Based on the width and height of the target rectangle, determine the coordinates of the four vertices of the target rectangle, where the coordinates of the top left vertex are (0,0), the top right vertex is (0,0), and the height is (0,0). ,0), coordinates of the lower left vertex (0, ), coordinates of the lower right vertex ( , );in, This represents the width of the target rectangle. This represents the height value of the target rectangle; S35. Establish a point-to-point mapping relationship between the coordinates of the four corner points and the coordinates of the four vertices of the target rectangle; wherein, the coordinates of the four corner points are used as the source point set, and the coordinates of the four vertices of the target rectangle are used as the target point set; S36. Convert the coordinates of each source point in the source point set and the corresponding target point coordinates in the target point set into homogeneous coordinates. Construct a system of linear equations based on the homogeneous coordinates. Solve the system of linear equations to obtain a 3×3 perspective transformation matrix. The perspective transformation matrix satisfies the homogeneous coordinate relationship that maps any point in the source point set to the corresponding point in the target point set after transformation.

4. The batch automatic correction method for core images according to claim 1, characterized in that, The bicubic interpolation algorithm model described in step S4 is defined as R(t), and its expression is as follows: ; In the formula, t is the independent variable, which is the offset between the position to be calculated and the center of the neighboring pixels.

5. The batch automatic correction method for core images according to claim 4, characterized in that, Step S4 specifically includes the following steps: S41. Obtain the width value of the target rectangle. and height value According to the width value and the height value Create a blank output image matrix O; wherein the number of rows in the output image matrix O is equal to the height value. The number of columns is equal to the width value. ; S42. Perform an inverse operation on the perspective transformation matrix to obtain the perspective transformation inverse matrix. The perspective transformation matrix is ​​M. S43. For each pixel in the output image matrix O, use the column coordinates of that pixel... As the x-coordinate and x-coordinate of the target point As the ordinate of the target point, construct the target point coordinate pair. ; S44. Pair the target point coordinates Convert to homogeneous coordinate form Then, with the inverse matrix of the perspective transformation Multiply to obtain the homogeneous coordinates of the source point in the image to be processed, corresponding to the coordinates of the target point. The calculation formula is: ; S45. For the homogeneous coordinates of the source point Normalization is performed to obtain the floating-point coordinates of the source point in the image to be processed. Where x = x′ / w′, y = y′ / w′, and the source point floating-point coordinates are... It includes a floating-point x-coordinate and a floating-point y-coordinate; S46. Round down the floating-point x-coordinate and the floating-point y-coordinate respectively to obtain the integer coordinates of the source point. , where i= j= And calculate the first decimal deviation Δx=xi between the floating-point abscissa x and the source point integer abscissa i, and the second decimal deviation Δy=yj between the floating-point ordinate y and the source point integer ordinate j; S47, using the source point integer coordinates Centered on the corresponding pixel, a 4×4 16-neighbor pixel set {I(i+m,j+n)|m∈[-1,2],n∈[-1,2]} is determined in the image to be processed, where I represents the pixel matrix of the image to be processed, and m and n are integer indices; S48. For each neighboring pixel I(i+m,j+n) in the set of 16 neighboring pixels, calculate the first weight coefficient R(m-Δx) in the row direction and the second weight coefficient R(n-Δy) in the column direction. Multiply the first weight coefficient and the second weight coefficient to obtain the comprehensive weight coefficient of the neighboring pixel. ; S49. Multiply the pixel value I(i+m,j+n) of each neighboring pixel in the 16-neighboring pixel set by the corresponding comprehensive weight coefficient. The 16 product results are summed to obtain the output pixel value corresponding to the target point coordinate pair q. The calculation formula is: ; S410, Output pixel value The value is assigned to position O in the output image matrix. Matrix elements; S411. Traverse all pixels in the output image matrix and repeat steps S43 to S410 until all matrix elements are assigned values ​​to obtain a complete output image matrix O. The output image matrix O is the geometrically corrected core box image.

6. The batch automatic correction method for core images according to claim 5, characterized in that, Step S4 also includes the following steps: Before executing step S47, determine the integer coordinates of the source point. Whether it is located within the boundary region of the image to be processed, the boundary region is defined as the region whose row coordinate is less than 1 or greater than or equal to the image height minus 2, or whose column coordinate is less than 1 or greater than or equal to the image width minus 2; If the source point integer coordinates If the pixel is located within the boundary region, the rules for determining the set of 16 neighboring pixels are adjusted, specifically including: When the integer y-coordinate j of the source point is less than 1, the row range is adjusted to be from 0 to 3; When the integer ordinate j of the source point is greater than or equal to H-2, the row range is adjusted to be from H-4 to H-1, where H is the height of the image to be processed; When the integer x-coordinate i of the source point is less than 1, the column range is adjusted to be from 0 to 3; When the integer x-coordinate of the source point i ≥ W-2, the column range is adjusted to be from W-4 to W-1, where W is the width of the image to be processed; The set of 16 neighboring pixels is redefined based on the adjusted row and column ranges; For each neighboring pixel in the newly determined set of 16 neighboring pixels, its corresponding row offset m and column offset n are recalculated based on the adjusted row and column ranges. Based on the recalculated row offset m and column offset n, steps S48 to S49 are executed to obtain the output pixel value O corresponding to the target point coordinate pair q. .

7. The batch automatic correction method for core images according to claim 1, characterized in that, Step S5 is followed by the following steps: S6. Obtain a structured parameter file containing borehole identifiers, the total number of core boxes, and the termination depth data corresponding to each core box. Generate title text for each core box based on the borehole identifiers and termination depth data. Generate a title bar image based on the title text. S7. Obtain the preset scale configuration information for each box of rock cores, generate the corresponding scale image according to the scale configuration information, and stitch together the title bar image, scale image and geometrically corrected rock core box image of each box of rock cores according to the predetermined layout to generate a standardized result image of each box of rock cores, thereby completing the batch editing of rock core photos.

8. The batch automatic correction method for core images according to claim 7, characterized in that, The title bar image mentioned in step S6 is generated through the following steps: Obtain a pre-stored font matrix library. Based on the title text, retrieve the binarized matrix corresponding to each character from the font matrix library. Horizontally concatenate the binarized matrices of each character and scale them to a size that matches the width of the geometrically corrected core box image. Then, center them within the title area of ​​a preset height.

9. The batch automatic correction method for core images according to claim 7, characterized in that, The scale image in step S7 includes a horizontal scale and / or a vertical scale. The horizontal scale image is loaded according to the scale length selected by the technician, and the width of the horizontal scale image is scaled to be equal to the width of the geometrically corrected core box image before being stitched to the bottom of the image. The vertical scale image is loaded according to the height-to-width ratio of the geometrically corrected core box image, selecting the closest size from a preset set of vertical scale sizes, and the corresponding vertical scale image is loaded. The height of the vertical scale image is scaled to be equal to the height of the geometrically corrected core box image before being stitched to the left side of the image.

10. A batch automatic correction system for core images, employing the batch automatic correction method for core images as described in any one of claims 1-9, characterized in that, include: The parameter input module is used to acquire and parse the structured parameter file and generate title text that corresponds one-to-one with the core photos of each box of cores; The image preprocessing module is used to acquire the current core image corresponding to the current core box, determine the orientation marker from the exchangeable image file format information of the current core image, and automatically rotate and correct the current core image according to the orientation marker to obtain the orientation-corrected image to be processed. The interactive calibration module is used to display images on the graphical user interface and receive the coordinates of the four corner points of the core box as input by technicians. The geometric correction module is used to determine the size of the target rectangle based on the coordinates of the four corner points, solve the perspective transformation matrix, and use a bicubic interpolation algorithm to resample the image to obtain the geometrically corrected core box image. The plotting and compositing module is used to generate a title bar image based on the title text, generate a scale image based on the preset scale configuration information, and combine the title bar image, scale image and geometrically corrected core box image into a standardized result image. The output module is used to save the standardized output diagram to a storage medium; The control module is used to control the cyclic processing of core photos from each box of cores until all core photos have been processed.