Casting X-ray flaw detection 16-bit grayscale image adaptive enhancement method and system

By adaptively enhancing the 16-bit grayscale image of the cast X-ray detection casting, the problem of loss of details when the image is displayed on ordinary monitors is solved, and the effect of improving image quality and avoiding missed detection and missed detection is achieved.

CN120107137AActive Publication Date: 2025-06-06HUAZHONG UNIV OF SCI & TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510277487.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-06-06
Estimated Expiration
2045-03-10

AI Technical Summary

Technical Problem

Existing X-ray flaw detection images are missing details when displayed on ordinary monitors, resulting in missed and missed detection during manual video review.

Method used

The 16-bit grayscale image adaptive enhancement method is adopted to divide the 16-bit grayscale image into multiple grayscale subintervals or subgraphs, and each subinterval or subgraph is enhanced, combining image quality evaluation and optimization algorithm to obtain the best enhanced image.

Benefits of technology

It effectively avoids missed and missed detection of small defects, improves image quality, and ensures that important details in the image can be accurately identified during manual review.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120107137A_ABST
    Figure CN120107137A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and discloses a casting X-ray flaw detection 16-bit grayscale image adaptive enhancement method and system, and the method comprises the steps: dividing a 16-bit grayscale image into a plurality of grayscale subintervals and a plurality of subgraphs, and respectively mapping each grayscale subinterval and each subgraph into 8-bit images; performing enhancement processing on the 8-bit grey-scale images and then merging the 8-bit grey-scale images, and performing enhancement processing on each 8-bit sub-image; evaluating the image quality of the enhanced grey-scale map to obtain a first evaluation result; evaluating the image quality of each enhanced sub-image, and obtaining an average value of all evaluation results as a second evaluation result; taking the two evaluation results as target evaluation functions, and performing parameter combination optimization on the enhanced grayscale image and the enhanced sub-image to obtain a corresponding evaluation score, an optimal parameter and an enhanced image corresponding to the optimal parameter; and taking the enhanced image corresponding to the maximum evaluation score as a final enhanced image. According to the invention, the quality of the 16-bit grayscale image can be improved, and the problems of missing detection and false detection of small defects are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing, and more specifically, to a method and system for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection. Background Art

[0002] In recent years, X-ray flaw detection technology has been widely used in the detection of internal defects of castings. In order to obtain higher precision and better quality images, the flaw detection equipment will save the detection results as 16-bit grayscale images to ensure that each pixel can be represented by 65536 grayscale values. Ordinary monitors can generally only display 8-bit (256 levels) grayscale, while 16-bit grayscale images have 65536 levels of grayscale. Therefore, when a 16-bit grayscale image is directly displayed on an ordinary monitor, the following situations will occur: (1) Grayscale loss: Since the monitor can only display 8-bit grayscale, the grayscale information of the image will be compressed or lost. Usually, the 16-bit grayscale image will be simply truncated to 8 bits when displayed, that is, only the highest 256-level grayscale value will be displayed, resulting in the loss of details in the dark or bright parts of the image. (2) Visual effect deterioration: The details in the 16-bit image will be compressed to the dynamic range of the 8-bit monitor, causing the picture to appear overexposed or too dark, with insufficient details, and important details in the image may not be seen. When manually viewing a 16-bit grayscale image, a "window adjustment" is performed, that is, a specific grayscale range is selected and mapped to the 8-bit display range. In the process of manual film review, the window width and window position need to be adjusted repeatedly, and the slightest carelessness may cause errors such as missing minor defects and misdetecting similar defects. Summary of the invention

[0003] In view of the defects of the prior art, the purpose of this application is to provide a method and system for adaptive enhancement of 16-bit grayscale images of casting X-ray flaw detection, aiming to solve the problem of loss of details when the existing X-ray flaw detection images are displayed on ordinary monitors, which leads to missed detections and false detections during manual film evaluation.

[0004] To achieve the above objectives, the present application provides a method for adaptively enhancing a 16-bit grayscale image of a casting X-ray flaw detection, comprising: S1: dividing the 16-bit grayscale image into a plurality of grayscale sub-intervals, and mapping each grayscale sub-interval into an 8-bit grayscale image; dividing the 16-bit grayscale image into a plurality of sub-images, and mapping each sub-image into an 8-bit sub-image; S2 performs enhancement processing on the 8-bit grayscale images and then merges them to obtain an enhanced grayscale image; performs enhancement processing on each 8-bit sub-image to obtain an enhanced sub-image; S3 evaluates the image quality of the enhanced grayscale image to obtain a first evaluation result; evaluates the image quality of each enhanced sub-image, and obtains an average value of all evaluation results as a second evaluation result; S4 uses the first evaluation result and the second evaluation result as target evaluation functions, respectively, optimizes the parameter combinations of the enhanced grayscale image and the enhanced sub-image, and outputs the corresponding optimal parameters and the enhanced image corresponding to the optimal parameters; compares the evaluation scores corresponding to the optimal parameters output by the two optimization methods, and outputs the enhanced image corresponding to the maximum evaluation score as the final enhanced image.

[0005] Compared with the prior art, the above technical solution conceived by the present application enhances the 16-bit grayscale image through two division methods, obtains the corresponding evaluation result of the enhanced image as the optimization target, and combines the optimization algorithm to achieve the best enhancement processing of the 16-bit grayscale image, thereby avoiding the subsequent missed detection and false detection of small defects.

[0006] Furthermore, in step S2, the step of enhancing the 8-bit grayscale image includes: S201 performs edge enhancement processing on the 8-bit grayscale image to obtain an edge enhanced image; S202 performs overall image enhancement processing on the edge-enhanced image to obtain the enhanced grayscale image.

[0007] Furthermore, in step S201, the edge enhancement processing method is: identifying the edge of the 8-bit grayscale image, and sharpening the 8-bit grayscale image with the identified edge using the following formula to obtain an edge enhanced image:

[0008] in, is the enhancement factor, I 8 is an 8-bit grayscale image. is the image after Gaussian smoothing, (x,y) Represents image pixels.

[0009] Furthermore, in step S202, the overall image enhancement processing method is: Apply CLAHE parameter correction to the edge enhanced image to obtain a corrected image, and the correction formula is:

[0010] in, C limit _1 for CLAHE parameters, and , Then use the Gamma parameter to perform secondary correction on the corrected image to obtain the enhanced image. The secondary correction formula is:

[0011] in, γ 1 is the Gamma parameter, and , I enh _1 To enhance the image; The step of enhancing the 8-bit grayscale image is the same as the step of enhancing the grayscale image.

[0012] Furthermore, in step S3, the image quality of the enhanced grayscale image is evaluated, and the method for obtaining the first evaluation result is: obtaining the edge clarity index, local contrast index and image entropy index of the enhanced grayscale image; normalizing the edge clarity index, local contrast index and image entropy index, and obtaining the first evaluation result using the following formula:

[0013] in, is the normalized edge sharpness, is the normalized local contrast, is the normalized image entropy index; ω E ,ω C ,ω H They are different coefficients, and the sum of the three is 1, Q represents the first evaluation result; Furthermore, the method for evaluating the image quality of each enhanced sub-image is the same as the method for evaluating the image quality of the enhanced grayscale image.

[0014] Furthermore, the method for obtaining the edge clarity index of the enhanced grayscale image includes: S301 uses the Canny edge detection algorithm to respectively extract the edges of the enhanced grayscale image; S302 calculates the gradient amplitude of the corresponding edge pixel point, and obtains the average value of the gradient amplitude as an edge clarity index.

[0015] Furthermore, the method for obtaining the local contrast index of the enhanced grayscale image includes: S311: dividing the enhanced grayscale image into a plurality of local sub-blocks of the same size; S312: calculating the grayscale mean of pixels in each local sub-block, and obtaining the grayscale standard deviation using the grayscale mean; S313 obtains the average value of the grayscale standard deviation as a local contrast index.

[0016] Furthermore, the method for obtaining the image entropy index of the enhanced grayscale image includes: S321: Counting the grayscale histogram of the enhanced grayscale image, and calculating the total number of pixels of the grayscale histogram; S322 obtains the occurrence probability of each gray level by using the gray level histogram and the total number of pixels; S323 obtains the image entropy index based on the occurrence probability of each gray level using the following formula:

[0017] in, H score is the image entropy index, p (g) is the probability of occurrence of gray level, g=0,1,...,255。

[0018] Furthermore, in step S4, the first evaluation result and the second evaluation result are respectively used as target evaluation functions, and a particle swarm algorithm is used to optimize the parameter combination of the enhanced grayscale image and the enhanced sub-image, and the steps of the particle swarm algorithm are: The steps of the particle swarm algorithm are: S401 randomly generates M particles in the image parameter space, each particle represents a set of parameter combinations; S402 obtains the evaluation score of each particle, compares the evaluation score of each particle with the evaluation scores of two adjacent particles, and updates the position of the current particle to the particle with the highest evaluation score among the adjacent particles; S403 uses a tournament selection strategy to select a number of particles from the particles whose positions have been updated as parents; performs a crossover operation on the corresponding parameters of the parents in pairs to obtain offspring; uses an adaptive mutation strategy to mutate the offspring according to a preset probability, and during the mutation process, uses an elite retention strategy to directly retain excellent offspring, and uses a selection mechanism based on fitness ratio to screen the remaining offspring; S404 repeats steps S401 to S403 until a predetermined number of iterations is reached or the evaluation score converges, and then outputs the optimal parameters.

[0019] Furthermore, the parameter combination includes the following parameters: grayscale step size, window width, window level, edge enhancement parameter, CLAHE parameter and Gamma parameter.

[0020] According to another aspect of the present application, a system for implementing the aforementioned method for adaptively enhancing a 16-bit grayscale image of a casting X-ray flaw detection is also provided, comprising: A quantization module, used to divide the 16-bit grayscale image into a plurality of grayscale sub-intervals, and map each grayscale sub-interval into an 8-bit grayscale image; and also used to divide the 16-bit grayscale image into a plurality of sub-images, and map each sub-image into an 8-bit sub-image; An enhancement processing module, used for performing enhancement processing on the 8-bit grayscale images and then merging them to obtain an enhanced grayscale image; and also used for performing enhancement processing on each 8-bit sub-image to obtain an enhanced sub-image; An evaluation module, used to evaluate the image quality of the enhanced grayscale image to obtain a first evaluation result; and also used to evaluate the image quality of each enhanced sub-image and obtain an average value of all evaluation results as a second evaluation result; The optimization module is used to use the first evaluation result and the second evaluation result as target evaluation functions, respectively, to optimize the parameter combinations of the enhanced grayscale image and all enhanced sub-images, and output the corresponding optimal parameters and the enhanced images corresponding to the optimal parameters; it is also used to compare the evaluation scores corresponding to the optimal parameters outputted in the two optimization methods, and output the enhanced image corresponding to the maximum evaluation score as the final enhanced image.

[0021] Compared with the prior art, the above technical solution conceived by this application has the following beneficial effects: (1) This application enhances a 16-bit grayscale image through two parallel image processing methods, and performs quality assessment on the enhanced grayscale image and enhanced sub-image after the two enhancement processes. The respective quality assessment results are used as the optimization target evaluation function, and the optimization algorithm is used to optimize them respectively, thereby obtaining an enhanced processed image with the best image quality, thereby achieving the beneficial effect of avoiding subsequent missed detection and false detection of small defects.

[0022] (2) This application uses the same set of image quality evaluation systems to evaluate the two types of 8-bit images after enhancement processing. The evaluation indicators include edge clarity, local contrast and grayscale distribution (i.e., image entropy). These evaluation indicators are used to calculate a normalized comprehensive index, and the comprehensive index is used as the target evaluation function of the optimization algorithm. The enhanced processed image corresponding to the optimal parameter combination obtained by the optimization algorithm has higher image quality.

[0023] (3) The image adaptive enhancement method provided by this application is more adaptable and can adjust the evaluation index according to different needs, thereby obtaining different optimization target evaluation functions and optimization results. The selection, crossover and mutation operations of the genetic algorithm are interspersed in the optimization algorithm. The selection operation determines which individuals can reproduce offspring, the crossover operation introduces new parameter combinations, and the mutation operation increases the diversity of the population by introducing randomness to prevent the algorithm from falling into the local optimal solution. This can effectively balance the global search ability and local search ability of the algorithm, while avoiding the loss of excellent solutions caused by random operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a schematic diagram of a flow chart of a method for adaptively enhancing a 16-bit grayscale image of a casting X-ray flaw detection provided in an embodiment of the present application; Figure 2 1 is a schematic diagram of a processing method for adaptively enhancing a 16-bit grayscale image of a casting X-ray flaw detection provided in an embodiment of the present application; Figure 3 It is a schematic diagram of an image after dividing a 16-bit grayscale image into multiple grayscale intervals and enhancing the image provided by an embodiment of the present application; Figure 4 It is a schematic diagram of an image after dividing a 16-bit grayscale image into multiple sub-images and enhancing the image provided by an embodiment of the present application; Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0026] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0027] In addition, references throughout this specification to "one embodiment"; "one embodiment", "an example" or similar language indicate that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. Thus, appearances of the phrase "in one embodiment"; "in one embodiment" and similar language throughout this specification may, but do not necessarily, all refer to the same embodiment.

[0028] The present application embodiment provides a method for adaptively enhancing a 16-bit grayscale image of a casting X-ray flaw detection, such as Figure 1 and Figure 2 As shown, the method comprises the following steps: S1 divides the 16-bit grayscale image into multiple grayscale sub-intervals, and maps each grayscale sub-interval into an 8-bit grayscale image; divides the 16-bit grayscale image into multiple sub-images, and maps each sub-image into an 8-bit sub-image; S2 enhances the 8-bit grayscale image and merges it to obtain Figure 3 The enhanced grayscale image shown in FIG. 1 is enhanced by processing each 8-bit sub-image to obtain the following Figure 4 Enhancer maps shown; S3 evaluates the image quality of the enhanced grayscale image to obtain a first evaluation result; evaluates the image quality of each enhanced sub-image, and obtains an average value of all evaluation results as a second evaluation result; S4 uses the first evaluation result as the target evaluation function, optimizes the parameter combination of the enhanced grayscale image, and outputs the corresponding evaluation score, optimal parameters, and the enhanced image corresponding to the optimal parameters; uses the second evaluation result as the target evaluation function, optimizes the parameter combination of the complete image composed of all enhanced sub-images, and outputs the corresponding evaluation score, optimal parameters, and the enhanced image corresponding to the optimal parameters; compares the evaluation scores corresponding to the two optimal parameters, and outputs the enhanced image corresponding to the maximum evaluation score as the final enhanced image (i.e., output Figure 4 (top or bottom image in the last step of ).

[0029] In the above step S1, the width and height of the 16-bit grayscale image of the casting X-ray flaw detection are obtained, which are denoted as w and h respectively; assuming that the input image is I , I(x,y) Represents pixel coordinates (x,y) Gray value on , and 0≤ I(x,y) ≤65535, divide the 16-bit grayscale image into multiple grayscale sub-intervals, and map the grayscale sub-intervals into 8-bit grayscale images. The specific division steps include: S101 Set grayscale step size step , the grayscale interval is divided into n Grayscale sub-intervals are expressed as: (1) in, n represents the sequence number of the grayscale subinterval, and ; step Indicates the step length, the value is , such as the second subinterval is , No. n The sub-interval is , G min is the minimum grayscale value of a 16-bit grayscale image. G max is the maximum grayscale value of a 16-bit grayscale image; S102 maps the 1st to nth grayscale sub-intervals into an 8-bit range in sequence using the following formula: (2) in, WW n For the n The window width of the subintervals is WL n For the n The window level of each subinterval; S103 combines the images corresponding to all the mapped grayscale sub-intervals to obtain an 8-bit grayscale image.

[0030] In the aforementioned step S2, the step of enhancing the 8-bit grayscale image includes: S201 first performs edge enhancement processing on the 8-bit grayscale image to obtain an edge enhanced image.

[0031] Specifically, the Canny edge detection operator is used to process the 8-bit grayscale image to obtain the edge map E 1 The parameters of the Canny edge detection operator include the low threshold T low and high threshold T high , T low The value is [0.05×max_grad,0.15×max_grad], T high The value is [0.2×max_grad, 0.4×max_grad], where max_grad is the maximum gradient amplitude of the image; the enhancement coefficient λ ranges from 0.5 to 1.0. E 1 (x,y) = 1 means the pixel (x, y) is an edge pixel of the image, otherwise E 1 (x,y) = 0. The following formula is used to calculate the edge graph E 1 Sharpen to obtain an edge-enhanced image: (3) in, This is the edge enhanced image after Gaussian smoothing.

[0032] S202 performs overall image enhancement processing on the edge enhanced image to obtain an enhanced grayscale image. The overall image enhancement processing method is: Edge enhancement image Apply CLAHE parameter correction to obtain the corrected image. The correction formula is: (4) in, C limit _1 for CLAHE parameters, and , Then use the Gamma parameter to perform secondary correction on the corrected image to obtain the enhanced image. The secondary correction formula is: (5) in, γ 1 is the Gamma parameter, and , I enh_1 To enhance the image; In the aforementioned step S1, the step of dividing the 16-bit grayscale image into a plurality of sub-images and mapping each sub-image into an 8-bit sub-image includes: S111 divides the 16-bit grayscale image evenly into a plurality of sub-images, that is, evenly divides the image by rows and columns, such as cutting the image into 12 sub-images; S112 maps the grayscale values ​​of the multiple sub-images to an 8-bit range respectively according to the following formula: (6) in, For the n sub-images, For the n The window width of the sub-images, For the n The window position of each sub-image; S113 merges all mapped sub-images to obtain an 8-bit sub-image.

[0033] In this embodiment, the steps of enhancing the 8-bit sub-image are the same as the steps of enhancing the grayscale image, and the specific steps are: Use the Canny edge detection operator to process the 8-bit sub-image and obtain the edge map E 1 _ n The parameters of the Canny edge detection operator include the low threshold T low and high threshold T high , T low The value is [0.05×max_grad,0.15×max_grad], T high The value is [0.2×max_grad, 0.4×max_grad], where max_grad is the maximum gradient amplitude of the image; the enhancement coefficient λ n The range is 0.5~1.0, E 1 _ n (x,y) = 1 means the pixel (x, y) is an edge pixel of the image, otherwise E 1 _ n (x,y) = 0. The following formula is used to calculate the edge graph E 1 _ n (x,y) = 1 to obtain an edge-enhanced image: (7) in, This is the edge enhanced image after Gaussian smoothing.

[0034] Edge enhancement image Apply CLAHE parameter correction to obtain the corrected image. The correction formula is: (8) in, for CLAHE parameters, and .

[0035] Then use the Gamma parameter to perform secondary correction on the corrected image to obtain the enhanced image. The secondary correction formula is: (9) in, is the Gamma parameter, and , I enh_2_n To enhance the image.

[0036] In the aforementioned step S3, the image quality of the enhanced grayscale image is evaluated, and the method for obtaining the first evaluation result is: obtaining the edge clarity index, the local contrast index and the image entropy index of the enhanced grayscale image; normalizing the edge clarity index, the local contrast index and the image entropy index, and obtaining the first evaluation result using the following formula: (10) in, is the normalized edge sharpness, is the normalized local contrast, is the normalized image entropy index; ω E ,ω C ,ω H They are different coefficients, and the sum of the three is 1.

[0037] More specifically, when scoring, the entire image that is divided into multiple grayscale intervals and then enhanced is scored, and the score is used as the first evaluation result; the multiple enhanced sub-images that are divided into multiple sub-images and then enhanced are scored separately, and then the average of the scores of all enhanced sub-images is taken as the second evaluation result.

[0038] In this embodiment, the method for evaluating the image quality of each enhanced sub-image is the same as the method for evaluating the image quality of the enhanced grayscale image.

[0039] The method for obtaining the edge clarity index of the aforementioned enhanced grayscale image includes: S301 uses the Canny edge detection algorithm to extract the edges and pixels of the enhanced grayscale image. E(x,y)=1 The area is the edge pixel, otherwise E(x,y)=0 ; S302 calculates the gradient amplitude of the corresponding edge pixel point, and obtains the average value of the gradient amplitude as an edge clarity index; Calculate the enhanced 8-bit grayscale image The gradient component G x (x,y) With G y (x,y) : (11)

[0040] The gradient amplitude of each edge pixel is calculated using the aforementioned gradient components. The calculation formula is: (12) In all E(x,y)=1 In the edge pixel set, G(x,y) is averaged using the following formula: (13) The larger it is, the larger the average gradient amplitude of the image edge pixels is, and the higher the edge clarity is.

[0041] The method for obtaining the edge clarity index of the enhanced sub-image is the same as the method for obtaining the edge clarity index of the enhanced grayscale image.

[0042] The method for obtaining the local contrast index of the enhanced grayscale image includes: S311 divides the enhanced grayscale image into multiple local sub-blocks of the same size; divides the enhanced 8-bit grayscale image into M Local sub-blocks of the same size R k (For example, each sub-block is 16×16 pixels).

[0043] S312 calculates the grayscale mean of the pixels in each local sub-block, and uses the grayscale mean to obtain the grayscale standard deviation; the grayscale mean calculation formula in each sub-block is: (14) in, N k For the k The number of pixels in each sub-block; The grayscale standard deviation calculation formula is: (15) S313 obtains the average value of the grayscale standard deviation as a local contrast index; the calculation formula for taking the average value of the grayscale standard deviation of all sub-blocks is: (16) The larger it is, the more obvious the difference in grayscale distribution in the local area is, and the higher the local contrast is.

[0044] The method for obtaining the image entropy index of the enhanced sub-image is the same as the method for obtaining the image entropy index of the enhanced grayscale image mentioned above.

[0045] The method for obtaining the local contrast index of the enhanced grayscale image includes: S321 Grayscale histogram of statistically enhanced grayscale image h(g) , g=0,1,...,255, and calculate the total number of pixels in the grayscale histogram ; S322 uses the grayscale histogram and the total number of pixels to obtain the probability of occurrence of each grayscale level p(g) : (17) S323 obtains the image entropy index based on the occurrence probability of each gray level using the following formula: (18) in, H score is the image entropy index, p (g) is the probability of occurrence of gray level, g=0,1,...,255, when p(g) It is 0 o'clock.

[0046] In the above-mentioned step S4, the first evaluation result and the second evaluation result are respectively used as the target evaluation function, and the particle swarm algorithm is used to optimize the parameter combination of the enhanced grayscale image and the enhanced sub-image respectively; and / or, the parameter combination includes the following parameters: grayscale step size, window width, window position, edge enhancement parameter, CLAHE parameter and Gamma parameter.

[0047] In this embodiment, the first evaluation result and the second evaluation result are respectively used as the target evaluation function, and the particle swarm algorithm is used to optimize the parameter combination of the enhanced grayscale image and the enhanced sub-image. The specific optimization steps include: S401 Initialization: Randomly generate M particles in the parameter space, each particle represents a set of parameter combinations, each set of parameters includes: Grayscale step length step, the value is [1000,G max -G min ]; Window width , the value is 0.5 to 1 times of the current grayscale interval or sub-image width; Window Level , the value is 0.3 to 0.7 times the current grayscale interval or the average grayscale value of the sub-image; Edge enhancement parameters, low threshold Tlow and high threshold T high , T low The value is [0.05×max_grad,0.15×max_grad], T high The value is [0.2×max_grad, 0.4×max_grad], where max_grad is the maximum gradient amplitude of the image; the enhancement coefficient λ ranges from 0.5 to 1.0; CLAHE parameters, ; Gamma parameter, .

[0048] S402 runs a complete enhancement process for each particle parameter combination, calculates the evaluation score Q value (i.e., fitness) corresponding to each particle; updates the particle speed and position: updates according to the particle's historical optimal and global optimal positions, that is, compares the evaluation score of the current particle with the evaluation scores of the two adjacent particles, and updates the current particle to the position of the adjacent particle with a higher evaluation score, thereby making the particle group continuously approach the global optimal solution. The update formula is as follows: (19) and: (20) in, for k After iterations, particles i The flight velocity vector d Dimensional component, The particle position vector d Dimensional component; c 1 , c 2 is the acceleration constant, take 2; r 1 , r 2 are two random numbers in the range [0,1]; w is the inertia weight.

[0049] S403 In order to prevent particles from falling into local optimum, the selection, crossover and mutation operations of the genetic algorithm are introduced in the optimization process. Specifically, the tournament selection strategy is used to select several particles with the best fitness (i.e., the highest evaluation score) among the particles after the updated position as parents; any corresponding parameters in any two parents are crossed to obtain multiple offspring; an adaptive mutation strategy is used to mutate the offspring according to a preset probability. During the mutation process, an elite retention strategy is used to directly retain excellent offspring, and a selection mechanism based on fitness ratio is used to screen the remaining offspring.

[0050] More specifically, the purpose of the selection operation is to select excellent parents for crossover and mutation operations. The tournament selection strategy is selected, specifically: each time a certain number of particles (such as 10 particles) with the best evaluation scores are selected from the original particle population, and the best evaluation scores are selected from these particles as parents, and the remaining particles are placed in the original particle population for a second screening; during the second screening, a batch of particles with the best evaluation scores are selected from the particle population, and the best evaluation scores are selected from this batch of particles as parents; repeat the above selection steps until a sufficient number of parents are obtained for the next crossover operation. The corresponding parameters of the two parent generations are crossovered to obtain offspring. Specifically, the corresponding parameters contained in the two parent particles are randomly crossovered, such as exchanging the window width and window position corresponding to parent 1 and parent 2; exchanging the CLAHE parameters corresponding to parent 3 and parent 4, etc. The corresponding parameter information of 2-4 items can be randomly exchanged to obtain offspring 1, 2, 3, 4, etc.

[0051] Finally, the offspring after the exchange is mutated. According to the preset probability (such as 0.05), the value of a certain dimension of the particle is increased or decreased, and the dimension value is represented in binary form for mutation operation. For example, 11110001 may mutate to 11010001. During the mutation process, if the evaluation score of the offspring is high enough, such as the quality score is higher than the preset score of 85 points, the offspring can be directly copied to the next generation population to ensure that the excellent solution will not be lost; otherwise, based on the proportion of each particle in the total evaluation score of the parent and offspring as the retention probability, the appropriate particles are selected to enter the next generation. During the mutation process, ensure that the number of particles entering the next generation remains unchanged.

[0052] S404 repeats the iteration until a predetermined number of generations (such as 100) is reached or the fitness converges, and the optimal parameters corresponding to the two image division methods are output respectively. and , thus obtaining and The corresponding image enhancement optimization parameter set , and the corresponding enhanced image under this parameter set .

[0053] S405 compares the evaluation scores corresponding to the optimal parameters , select the one with the larger evaluation score and as the final output image.

[0054] In another embodiment, a system for implementing the aforementioned casting X-ray flaw detection 16-bit grayscale image adaptive enhancement method is provided, the system comprising: A quantization module, used to divide the 16-bit grayscale image into a plurality of grayscale sub-intervals, and map each grayscale sub-interval into an 8-bit grayscale image; and also used to divide the 16-bit grayscale image into a plurality of sub-images, and map each sub-image into an 8-bit sub-image; An enhancement processing module, used for performing enhancement processing on the 8-bit grayscale images and then merging them to obtain an enhanced grayscale image; and also used for performing enhancement processing on each 8-bit sub-image to obtain an enhanced sub-image; An evaluation module, used to evaluate the image quality of the enhanced grayscale image to obtain a first evaluation result; and also used to evaluate the image quality of each enhanced sub-image and obtain an average value of all evaluation results as a second evaluation result; The optimization module is used to use the first evaluation result and the second evaluation result as the target evaluation function, respectively, to optimize the parameter combination of the enhanced grayscale image and all enhanced sub-images, and output the corresponding optimal parameters and the enhanced image corresponding to the optimal parameters; it is also used to compare the evaluation scores corresponding to the optimal parameters output by the two optimization methods, and output the enhanced image corresponding to the maximum evaluation score as the final enhanced image.

[0055] It should be understood that the above-mentioned device is used to execute the method in the above-mentioned embodiment. The implementation principle and technical effect of the corresponding program module in the device are similar to those described in the above-mentioned method. The working process of the device can refer to the corresponding process in the above-mentioned method, which will not be repeated here.

[0056] Based on the method in the above embodiment, an embodiment of the present application provides an electronic device. The device may include: at least one memory for storing programs and at least one processor for executing the programs stored in the memory. When the program stored in the memory is executed, the processor is used to execute the method described in the above embodiment.

[0057] Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 5As shown, the electronic device may include: a processor 501, a communications interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communications interface 502 and the memory 503 communicate with each other via the communication bus 504. The processor 501 may call the software instructions in the memory 503 to execute the method described in the above embodiment.

[0058] In addition, the logic instructions in the above-mentioned memory 503 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the relevant technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application.

[0059] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method in the above embodiment.

[0060] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method in the above embodiment.

[0061] It is understandable that the processor in the embodiment of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.

[0062] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.

[0063] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can 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 the computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0064] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.

[0065] It is easy for those skilled in the art to understand that the above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for adaptively enhancing 16-bit grayscale images for X-ray flaw detection of castings, characterized in that: include: S1: dividing the 16-bit grayscale image into a plurality of grayscale sub-intervals, and mapping each grayscale sub-interval into an 8-bit grayscale image; dividing the 16-bit grayscale image into a plurality of sub-images, and mapping each sub-image into an 8-bit sub-image; S2 performs enhancement processing on the 8-bit grayscale images and then merges them to obtain an enhanced grayscale image; Enhance each 8-bit sub-image to obtain an enhanced sub-image; S3 evaluates the image quality of the enhanced grayscale image to obtain a first evaluation result; Evaluate the image quality of each enhanced sub-image, and obtain the average value of all evaluation results as the second evaluation result; S4 uses the first evaluation result and the second evaluation result as target evaluation functions, respectively, optimizes the parameter combinations of the enhanced grayscale image and all enhanced sub-images, and obtains the corresponding evaluation scores, optimal parameters and enhanced images corresponding to the optimal parameters; compares the two evaluation scores, and outputs the enhanced image corresponding to the maximum evaluation score as the final enhanced image.

2. The method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to claim 1, characterized in that: In step S2, the step of enhancing the 8-bit grayscale image includes: S201 performs edge enhancement processing on the 8-bit grayscale image to obtain an edge enhanced image; S202 performs overall image enhancement processing on the edge-enhanced image to obtain the enhanced grayscale image.

3. The method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to claim 2, characterized in that: In step S201, the edge enhancement processing method is: identifying the edge of the 8-bit grayscale image, and sharpening the 8-bit grayscale image with the identified edge using the following formula to obtain an edge enhanced image: in, is the enhancement factor, I 8 is an 8-bit grayscale image. is the image after Gaussian smoothing, (x,y) Represents image pixels.

4. The method for adaptively enhancing 16-bit grayscale images for X-ray flaw detection of castings according to claim 3, characterized in that: In step S202, the overall image enhancement processing method is: Apply CLAHE parameter correction to the edge enhanced image to obtain a corrected image, and the correction formula is: in, C limit _1 for CLAHE parameters, and , Then, the Gamma parameter is used to perform secondary correction on the corrected image to obtain an enhanced image. The secondary correction formula is: in, γ 1 is the Gamma parameter, and , I enh _1 To enhance the image; And / or, the step of enhancing the 8-bit sub-image is the same as the step of enhancing the grayscale image.

5. The method for adaptively enhancing 16-bit grayscale images for X-ray flaw detection of castings according to claim 1, characterized in that: In step S3, the image quality of the enhanced grayscale image is evaluated, and the method for obtaining the first evaluation result is: obtaining the edge clarity index, local contrast index and image entropy index of the enhanced grayscale image; normalizing the edge clarity index, local contrast index and image entropy index, and obtaining the first evaluation result using the following formula: in, is the normalized edge sharpness, is the normalized local contrast, is the normalized image entropy index; ω E ,ω C ,ω H They are different coefficients, and the sum of the three is 1; And / or, the method for evaluating the image quality of each enhanced sub-image is the same as the method for evaluating the image quality of the enhanced grayscale image.

6. The method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to claim 5, characterized in that: The method for obtaining the edge definition index of the enhanced grayscale image comprises: S301 uses the Canny edge detection algorithm to respectively extract the edges of the enhanced grayscale image; S302 calculates the gradient amplitude of the corresponding edge pixel point, and obtains the average value of the gradient amplitude as an edge clarity index.

7. The method for adaptively enhancing 16-bit grayscale images for X-ray flaw detection of castings according to claim 5, characterized in that: The method for obtaining the local contrast index of the enhanced grayscale image includes: S311: dividing the enhanced grayscale image into a plurality of local sub-blocks of the same size; S312: calculating the grayscale mean of pixels in each local sub-block, and obtaining the grayscale standard deviation using the grayscale mean; S313 obtains the average value of the grayscale standard deviation as a local contrast index.

8. The method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to claim 5, characterized in that: The method for obtaining the image entropy index of the enhanced grayscale image includes: S321: Counting the grayscale histogram of the enhanced grayscale image, and calculating the total number of pixels of the grayscale histogram; S322 obtains the occurrence probability of each gray level by using the gray level histogram and the total number of pixels; S323 obtains the image entropy index based on the occurrence probability of each gray level using the following formula: in, H score is the image entropy index, p (g) is the probability of occurrence of gray level, g=0,1,...,255 .

9. The method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to claim 1, characterized in that: In step S4, the first evaluation result and the second evaluation result are respectively used as target evaluation functions, and a particle swarm algorithm is used to optimize the parameter combination of the enhanced grayscale image and the enhanced sub-image. The steps of the particle swarm algorithm are as follows: S401 randomly generates M particles in the image parameter space, each particle represents a set of parameter combinations; S402 obtains the evaluation score of each particle, compares the evaluation score of each particle with the evaluation scores of two adjacent particles, and updates the position of the current particle to the particle with the highest evaluation score among the adjacent particles; S403 uses a tournament selection strategy to select a number of particles from the particles whose positions have been updated as parents; performs a crossover operation on the corresponding parameters of the parents in pairs to obtain offspring; uses an adaptive mutation strategy to mutate the offspring according to a preset probability, and during the mutation process, uses an elite retention strategy to directly retain excellent offspring, and uses a selection mechanism based on fitness ratio to screen the remaining offspring; S404 repeats steps S401 to S403 until a predetermined number of iterations is reached or the fitness converges, and then outputs the optimal parameters and the enhanced image corresponding to the optimal parameters.

10. A system for implementing the method for adaptively enhancing 16-bit grayscale images of casting X-ray flaw detection according to any one of claims 1 to 9, characterized in that: include: A quantization module is used to divide a 16-bit grayscale image into multiple grayscale sub-intervals and map each grayscale sub-interval into an 8-bit grayscale image; It is also used to divide the 16-bit grayscale image into a plurality of sub-images, and map each sub-image into an 8-bit sub-image; An enhancement processing module, used for performing enhancement processing on the 8-bit grayscale images and then merging them to obtain an enhanced grayscale image; It is also used to enhance each 8-bit sub-image to obtain an enhanced sub-image; An evaluation module, used for evaluating the image quality of the enhanced grayscale image to obtain a first evaluation result; It is also used to evaluate the image quality of each enhanced sub-image, and obtain the average value of all evaluation results as the second evaluation result; The optimization module is used to use the first evaluation result and the second evaluation result as target evaluation functions, respectively, to optimize the parameter combinations of the enhanced grayscale image and all enhanced sub-images, and output the corresponding optimal parameters and the enhanced images corresponding to the optimal parameters; it is also used to compare the evaluation scores corresponding to the optimal parameters outputted in the two optimization methods, and output the enhanced image corresponding to the maximum evaluation score as the final enhanced image.

Citation Information

Patent Citations

  • Self-adaptive contrast adjustment method and device based on image histogram equalization characteristic

    CN113989130A

  • Self-adaptive pseudo-color display enhancement method for X-ray negative film of solid engine

    CN116258646A

  • High dynamic range infrared image enhancement method and device based on SKWGIF

    CN119417742A

  • Intelligent image enhancement

    US20200349674A1

  • Real-time adaptive shadow and highlight enhancement

    US20210250531A1