Image enhancement method and device, and electronic device

By generating a histogram of the initial grayscale image, finding and removing noise areas, converting it into an intermediate color image for enhancement, and finally inversely converting it into the target grayscale image, the problem of dark imaging of X-ray images of automotive parts is solved, and the structural and texture details are significantly enhanced.

CN120198338BActive Publication Date: 2025-09-09SHENZHEN XINRUN FULIAN DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510656996.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2025-09-09
Estimated Expiration
2045-05-21

AI Technical Summary

Technical Problem

Due to the limitation of dynamic range, X-ray images of automotive parts are dark, and existing technologies cannot effectively display details of internal structural defects such as shrinkage, shrinkage holes, cracks and slag inclusions.

Method used

By generating the histogram of the initial grayscale image, finding and removing the noise area, converting it into an intermediate color image for enhancement, and finally inversely converting it into the target grayscale image, the frequency domain processing is used to enhance the image structure and details.

Benefits of technology

It significantly enhances the structural and texture details in the image, solves the problem of poor image enhancement effect in existing technologies, and clearly displays the internal defects of automotive parts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198338B_ABST
    Figure CN120198338B_ABST
Patent Text Reader

Abstract

The present invention provides an image enhancement method and device, and an electronic device, wherein the method includes: generating a histogram of an initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; searching for a noise area in the initial grayscale image according to the histogram; denoising the noise area in the initial grayscale image to obtain an intermediate grayscale image; converting the intermediate grayscale image into an intermediate color image; enhancing the intermediate color image to obtain a target color image; and inversely converting the target color image into a target grayscale image. Through the embodiments of the present invention, the technical problem of poor enhancement effect of grayscale images in the related art is solved, and the structural and texture details in the image are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial control technology, and in particular to an image enhancement method and device, and an electronic device. Background Art

[0002] During the automotive parts production process, X-rays are used to inspect internal structural defects. A 16-bit high-dynamic-range digital flat-panel detector has a total pixel count of 1024×1024 and a pixel size of 200μm×200μm. Because automotive parts contain both thin and thick areas, with the thick areas being the majority, the window width is often set very wide and the window position is low, resulting in an overall dark X-ray image. Using functions like positive / negative conversion, brightness / contrast conversion, and magnification conversion fails to fully capture the details of the automotive part structure and defects such as shrinkage, cavities, cracks, pores, and slag inclusions, resulting in poor inspection results and accuracy.

[0003] For the above-mentioned problems existing in related technologies, no efficient and accurate solutions have been found yet. Summary of the Invention

[0004] The present invention provides an image enhancement method and device, and an electronic device to solve the above-mentioned technical problems existing in the related art.

[0005] According to one embodiment of the present invention, a method for enhancing an image is provided, comprising: generating a histogram of an initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; searching for a noise region in the initial grayscale image according to the histogram; denoising the noise region in the initial grayscale image to obtain an intermediate grayscale image; converting the intermediate grayscale image into an intermediate color image; enhancing the intermediate color image to obtain a target color image; and inversely converting the target color image into a target grayscale image.

[0006] Optionally, searching for the noise area in the initial grayscale image according to the histogram includes: dividing the histogram into peak segments and trough segments; and locating the pixel area corresponding to the trough segment as the noise area in the initial grayscale image.

[0007] Optionally, the noise area in the initial grayscale image is denoised to obtain an intermediate grayscale image, including: reading the initial grayscale value of each pixel in the noise area; determining, for each pixel, the grayscale segment to which the initial grayscale value belongs; searching for a denoised grayscale value that matches the grayscale segment, and replacing the initial grayscale value with the denoised grayscale value; after the initial grayscale values ​​of all pixels in the noise area are replaced, an intermediate grayscale image is obtained.

[0008] Optionally, the intermediate color image is enhanced to obtain a target color image, including: parsing the brightness value of the first channel in the intermediate color image; denoising the intermediate color image based on the brightness value to obtain a first color image; converting the first color image from the spatial domain to the frequency domain, and extracting the frequency domain matrix of the first color image; and performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image.

[0009] Optionally, the intermediate color image is denoised based on the brightness value to obtain a first color image, including: obtaining an initial weight matrix; traversing the pixels of the intermediate color image, and extracting the neighborhood matrix of each pixel pixel by pixel; for each pixel, iteratively performing the following steps until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product between the weight of the current cycle and the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; judging whether the difference is less than a threshold; if the difference is greater than or equal to the threshold, adjusting the weight matrix of the next cycle based on the difference.

[0010] Optionally, detail enhancement is performed on the first color image based on the frequency domain matrix to obtain a target color image, including: locating the zero-frequency component in the frequency domain matrix and transferring the zero-frequency component to the center of the spectrum; for each pixel of the first color image, calculating the distance value from the frequency domain coordinate to the center of the spectrum; calculating the filter mask of the frequency domain matrix based on the distance value, wherein the filter mask is used to balance the sharpening intensity and transition smoothness during image enhancement; multiplying the frequency domain matrix by the filter mask to obtain a frequency domain enhancement matrix; and inversely converting the frequency domain enhancement matrix into the spatial domain to obtain the target color image.

[0011] Optionally, calculating the filter mask of the frequency domain matrix based on the distance value includes: configuring the adjustment order n of the Butterworth high-pass filter; and calculating the filter mask of the frequency domain matrix using the following formula: : ;in, is the distance between the frequency domain coordinate of the pixel point and the center of the spectrum, is the cutoff frequency.

[0012] Optionally, generating a histogram of the initial grayscale image to be enhanced includes: reading the grayscale value of each pixel in the initial grayscale image; counting the number of pixels corresponding to each grayscale value; and generating a histogram of the initial grayscale image with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate.

[0013] According to another embodiment of the present invention, an image enhancement device is provided, comprising: a generation module for generating a histogram of an initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; a search module for searching for a noise area in the initial grayscale image according to the histogram; a denoising module for denoising the noise area in the initial grayscale image to obtain an intermediate grayscale image; a conversion module for converting the intermediate grayscale image into an intermediate color image; an enhancement module for enhancing the intermediate color image to obtain a target color image; and an inverse conversion module for inversely converting the target color image into a target grayscale image.

[0014] Optionally, the search module includes: a division unit, configured to divide the histogram into peak segments and trough segments; and a positioning unit, configured to position a pixel area corresponding to the trough segment as a noise area in the initial grayscale image.

[0015] Optionally, the denoising module includes: a reading unit for reading the initial grayscale value of each pixel in the noise area; a determination unit for determining, for each pixel, the grayscale segment to which the initial grayscale value belongs; a replacement unit for finding a denoising grayscale value that matches the grayscale segment and replacing the initial grayscale value with the denoising grayscale value; and a processing unit for obtaining an intermediate grayscale image after the initial grayscale values ​​of all pixels in the noise area are replaced.

[0016] Optionally, the enhancement module includes: an analysis unit for analyzing the brightness value of the first channel in the intermediate color image; a denoising unit for denoising the intermediate color image based on the brightness value to obtain a first color image; a conversion unit for converting the first color image from the spatial domain to the frequency domain and extracting the frequency domain matrix of the first color image; and an enhancement unit for performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image.

[0017] Optionally, the denoising unit includes: an acquisition subunit for acquiring an initial weight matrix; a traversal subunit for traversing the pixels of the intermediate color image and extracting the neighborhood matrix of each pixel pixel by pixel; an iteration subunit for iteratively performing the following steps for each pixel until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product of the weight of the current cycle with the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; judging whether the difference is less than a threshold; if the difference is greater than or equal to the threshold, adjusting the weight matrix of the next cycle based on the difference.

[0018] Optionally, the enhancement unit includes: a processing subunit, used to locate the zero-frequency component in the frequency domain matrix and transfer the zero-frequency component to the center of the spectrum; a first calculation subunit, used to calculate the distance value from the frequency domain coordinate to the center of the spectrum for each pixel of the first color image; a second calculation subunit, used to calculate the filter mask of the frequency domain matrix based on the distance value, wherein the filter mask is used to balance the sharpening intensity and transition smoothness during image enhancement; an operation subunit, used to multiply the frequency domain matrix with the filter mask to obtain a frequency domain enhancement matrix; and an inverse conversion subunit, used to inversely convert the frequency domain enhancement matrix into the spatial domain to obtain a target color image.

[0019] Optionally, the second calculation subunit is further used to: configure the adjustment order n of the Butterworth high-pass filter; calculate the filter mask of the frequency domain matrix using the following formula: : ;in, is the distance between the frequency domain coordinate of the pixel point and the center of the spectrum, is the cutoff frequency.

[0020] Optionally, the generation module includes: a reading unit for reading the grayscale value of each pixel in the initial grayscale image; a statistical unit for counting the number of pixels corresponding to each grayscale value; and a generation unit for generating a histogram of the initial grayscale image with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate.

[0021] According to yet another embodiment of the present invention, a storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above-mentioned apparatus embodiments when run.

[0022] According to another embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above device embodiments.

[0023] According to an embodiment of the present invention, a histogram of an initial grayscale image to be enhanced is generated, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; a noise area in the initial grayscale image is found according to the histogram; the noise area in the initial grayscale image is denoised to obtain an intermediate grayscale image; the intermediate grayscale image is converted into an intermediate color image; the intermediate color image is enhanced to obtain a target color image; and the target color image is inversely converted into a target grayscale image. Grayscale denoising can remove irrelevant details, and by enhancing the image in the frequency domain, fine features such as edges and textures can be enhanced while enhancing the large-scale structure of the image. This solves the technical problem of poor enhancement effect of grayscale images in related technologies and enhances the structural and texture details in the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0025] Figure 1 This is a hardware structure block diagram of a computer according to an embodiment of the present invention;

[0026] Figure 2 is a flow chart of an image enhancement method according to an embodiment of the present invention;

[0027] Figure 3 is a schematic diagram of a histogram in an embodiment of the present invention;

[0028] Figure 4 is an overall flow chart of image enhancement in an embodiment of the present invention;

[0029] Figure 5 Schematic diagram of the effects before and after image enhancement in an embodiment of the present invention;

[0030] Figure 6 This is a structural block diagram of an image enhancement device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0033] Example 1

[0034] The method embodiment provided in the first embodiment of the present application can be executed in a computing device such as a server, a computer, or a camera. For example, Figure 1 This is a hardware structure diagram of a computer according to an embodiment of the present invention. Figure 1 As shown, the computer may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data. Optionally, the computer may also include a transmission device 106 and an input / output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0035] Memory 104 can be used to store computer programs, such as software programs and modules of application software, such as the computer program corresponding to an image enhancement method in an embodiment of the present invention. Processor 102 executes the computer programs stored in memory 104 to perform various functional applications and data processing, thereby implementing the aforementioned method. Memory 104 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 104 may further include memory remotely located relative to processor 102, and such remote memory may be connected to the computer via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0036] Transmission device 106 is used to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by a computer's communications provider. In one embodiment, transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0037] In this embodiment, a method for enhancing an image is provided. Figure 2 is a flow chart of an image enhancement method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0038] Step S202, generating a histogram of the initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels;

[0039] Optionally, the initial grayscale image may be an 8-bit grayscale or a 16-bit grayscale. For example, the grayscale image generated by the X-ray detection device is a 16-bit grayscale image, and the grayscale value range of the 16-bit grayscale is 0-65535.

[0040] Optionally, the object of the initial grayscale image may be a workpiece such as an automobile part, such as a wheel hub.

[0041] Step S204, searching for a noise area in the initial grayscale image according to the histogram;

[0042] Step S206, denoising the noise area in the initial grayscale image to obtain an intermediate grayscale image;

[0043] Step S208, converting the intermediate grayscale image into an intermediate color image;

[0044] Step S210, enhancing the intermediate color image to obtain a target color image;

[0045] Step S212: inversely convert the target color image into a target grayscale image.

[0046] Through the above steps, a histogram of the initial grayscale image to be enhanced is generated, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; the noise area in the initial grayscale image is found according to the histogram; the noise area in the initial grayscale image is denoised to obtain an intermediate grayscale image; the intermediate grayscale image is converted into an intermediate color image; the intermediate color image is enhanced to obtain a target color image; and the target color image is inversely converted into a target grayscale image. Grayscale denoising can remove irrelevant details, and by enhancing the image in the frequency domain, fine features such as edges and textures can be enhanced while enhancing the large-scale structure of the image, thereby solving the technical problem of poor enhancement effect of grayscale images in related technologies and enhancing the structural and texture details in the image.

[0047] In this embodiment, generating a histogram of an initial grayscale image to be enhanced includes: reading the grayscale value of each pixel in the initial grayscale image; counting the number of pixels corresponding to each grayscale value; and generating a histogram of the initial grayscale image with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate.

[0048] Taking a 16-bit initial grayscale image as an example, the possible grayscale value of each pixel in the initial grayscale image is 0-65535. For example, the number of pixels with a grayscale value of 9000 is 350, and the coordinate point in the histogram is (9000, 350).

[0049] In one implementation of this embodiment, searching for the noise area in the initial grayscale image according to the histogram includes: dividing the histogram into peak segments and trough segments; and locating the pixel area corresponding to the trough segment as the noise area in the initial grayscale image.

[0050] When dividing into peak segments and trough segments, whether there are at least 30 consecutive pixels of grayscale is used as the dividing point. If there are at least 30 consecutive pixels of grayscale, it is a peak segment, otherwise it is a trough segment.

[0051] Figure 3 It is a schematic diagram of the histogram in the embodiment of the present invention. The number of peaks is determined. The number of peaks of the workpiece shown in the histogram is 3. According to the number of pixels, the dividing point between the peak segment and the non-peak segment in the histogram is found, and the non-peak segment (trough segment) can be separated.

[0052] In one example, the noise area in the initial grayscale image is denoised to obtain an intermediate grayscale image, including: reading the initial grayscale value of each pixel in the noise area; determining, for each pixel, the grayscale segment to which the initial grayscale value belongs; searching for a denoised grayscale value that matches the grayscale segment, and replacing the initial grayscale value with the denoised grayscale value; after the initial grayscale values ​​of all pixels in the noise area are replaced, an intermediate grayscale image is obtained.

[0053] In one implementation scenario, 0.17% (example, can be flexibly selected) of the grayscale pixels are used to replace the grayscale values ​​of the valley segment, and 8 (example, can be flexibly selected) denoised grayscale values ​​are used to replace all grayscales below 4671 (example, can be flexibly selected). 0-4671 is pre-divided into 8 grayscale segments, each grayscale segment corresponds to a denoised grayscale value, and the histogram of the intermediate grayscale image after replacement is as follows: Figure 3 shown.

[0054] In this embodiment, in the process of converting the intermediate grayscale image into the intermediate color image, the intermediate grayscale image is converted into the intermediate color image in the Lab color space through grayscale conversion. The conversion process includes:

[0055] Use the following formula for grayscale conversion:

[0056] = ;

[0057] Where g is the pixel single-channel matrix of the intermediate grayscale image after grayscale replacement.

[0058] A = ;

[0059] B = 500(f(x) - f(y)) + 32768

[0060] C = 200(f(y) - f(z)) + 32768

[0061] where f(t) = ;

[0062] [A, B, C] are the three channels of the intermediate color image converted from grayscale.

[0063] In the intermediate color image after conversion into the Lab color space, the first channel represents brightness, and the second and third channels represent color. By enhancing the first channel, the detail texture of the image can be enhanced.

[0064] In this embodiment, the intermediate color image is enhanced to obtain a target color image, including: parsing the brightness value of the first channel in the intermediate color image; denoising the intermediate color image based on the brightness value to obtain a first color image; converting the first color image from the spatial domain to the frequency domain and extracting the frequency domain matrix of the first color image; and performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image.

[0065] In one example, the intermediate color image is denoised based on the brightness value to obtain a first color image, including: obtaining an initial weight matrix; traversing the pixels of the intermediate color image and extracting a neighborhood matrix for each pixel pixel by pixel; iteratively performing the following steps for each pixel until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product between the weight of the current cycle and the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; determining whether the difference is less than a threshold; and if the difference is greater than or equal to the threshold, adjusting the weight matrix for the next cycle based on the difference.

[0066] In this example, the initialization parameters include a random initialization to obtain an initial weight matrix, including setting the step size and neighborhood size. The algorithm then iterates through the image pixels, extracting the neighborhood matrix pixel by pixel as the input signal. The weight matrix is ​​dynamically adjusted based on the error by calculating the output and the error: the output is the dot product of the weight and the neighborhood pixel, and the error is the difference between the original pixel value and the target pixel value. This process is repeated until the error stabilizes or a preset number of iterations (typically five) is reached, achieving iterative convergence.

[0067] This example uses denoising and removal of irrelevant details, and opens weight adjustment parameters. Larger values ​​make the image smoother and remove more noise and irrelevant details, while smaller parameter values ​​retain more details and remove less noise.

[0068] When the intermediate color image is subsequently enhanced to obtain a target color image, the enhanced brightness update value of the first channel is horizontally connected with the original values ​​of the second channel and the third channel in the intermediate color image to obtain the target color image.

[0069] In this embodiment, the spatial domain refers to the representation of an image in two-dimensional space. In the spatial domain, an image is composed of pixels, each of which has a specific position and grayscale value (or color value). Image processing methods in the spatial domain primarily focus on local features of the image, such as edges, textures, and shapes. The frequency domain refers to the representation of an image in frequency space. This embodiment converts the image in the spatial domain to the frequency domain through Fourier transform. In the frequency domain, the image is represented by a combination of sine and cosine waves of different frequencies. Image processing methods in the frequency domain primarily focus on global features of the image, such as smoothing, enhancement, and filtering. In the frequency domain, u and v are frequency variables used to represent the coordinates of the image in frequency space, corresponding to the frequencies in the horizontal and vertical directions, respectively.

[0070] When converting the first color image from the spatial domain to the frequency domain, a fast Fourier transform (FFT) is used to convert the image from the spatial domain to the frequency domain. Convert to the frequency domain and generate a complex frequency domain matrix :

[0071] = .

[0072] In one example, detail enhancement is performed on the first color image based on the frequency domain matrix to obtain a target color image, including: locating a zero-frequency component in the frequency domain matrix and transferring the zero-frequency component to the center of the spectrum; for each pixel of the first color image, calculating a distance value from the frequency domain coordinate to the center of the spectrum; calculating a filter mask of the frequency domain matrix based on the distance value, wherein the filter mask is used to balance the sharpening intensity and transition smoothness during image enhancement; multiplying the frequency domain matrix by the filter mask to obtain a frequency domain enhancement matrix; and inversely converting the frequency domain enhancement matrix into the spatial domain to obtain a target color image.

[0073] Move the zero-frequency component to the center of the spectrum to facilitate visualization and subsequent data processing, and calculate the frequency domain enhancement matrix :

[0074] = * ;

[0075] It is a filter mask. By multiplying the filter mask with the frequency domain matrix, the high-frequency components are enhanced, and the high-frequency region coefficients are nonlinearly amplified to further enhance the details.

[0076] Optionally, the processed frequency domain enhancement matrix is ​​inversely transformed back to the spatial domain to obtain the target color image. The modulus of the inverse transformation result is taken and normalized to the grayscale range of [0, 65535]. The resulting image is superimposed with the Laplacian operator to further enhance local details.

[0077] The filter mask (also called a mask or window) of this embodiment is a two-dimensional array used to define local neighborhood operations in image processing operations. It contains a set of coefficients that are convolved or correlated with the pixel values ​​of the image during the filtering process to achieve operations such as smoothing, sharpening, and edge detection on the image.

[0078] This embodiment selects a Butterworth high-pass filter, which includes a smoothing filter and a sharpening filter. The smoothing filter expects the sum of the filter coefficients to be 1 to maintain the overall brightness of the image. The sharpening filter expects the center coefficient of the filter to be greater than the surrounding coefficients to enhance the edge. The smoothing filter can also select a mean filter and a Gaussian filter. The sharpening filter can also select a Laplace filter and a high-pass filter.

[0079] Optionally, calculating the filter mask of the frequency domain matrix based on the distance value includes: configuring the adjustment order n of the Butterworth high-pass filter; and calculating the filter mask of the frequency domain matrix using the following formula: : ;in, is the distance between the frequency domain coordinate of the pixel point and the center of the spectrum, is the cutoff frequency.

[0080] By applying a Butterworth high-pass filter with an adjustable order n, it is possible to balance sharpening intensity with transition smoothness.

[0081] The solution of this embodiment proposes a method for enhancing the structural and texture details of 16-bit X-ray images. The method takes the enhancement of X-ray images of automobile parts as an example for explanation. If a histogram of an X-ray image of an automobile part is drawn, it will be found that the histogram has only 1-3 peaks and very few non-peak pixels. This embodiment removes a large number of non-peak grayscale pixels from the image and replaces them with a small number of grayscale pixels. After converting the grayscale image into a color image using a grayscale conversion function, the three channels of the color image are separated, and the first channel is extracted and converted into a 32-bit floating-point type to eliminate noise and irrelevant details. After enhancing the image in the frequency domain, it is converted into a 16-bit integer type and then merged with the remaining second and third channels. The image is converted back into a grayscale image using the inverse function of the grayscale conversion function, which is the enhanced image. This grayscale image can clearly display subtle features such as the structure, edges, and texture of the automobile parts in the image.

[0082] Figure 4FIG. 5 is an overall flow chart of image enhancement in an embodiment of the present invention, comprising the following steps:

[0083] Step 1: Count the number of pixels at each grayscale, draw a histogram of the input image with grayscale 0-65535 as the x-axis and the number of pixels as the y-axis;

[0084] Step 2: Determine the number of peaks based on the workpiece and steps of the photographed automotive parts. The number of peaks of the workpiece shown in the histogram above is 3;

[0085] Step 3: According to the number of pixels, find the dividing point between the peak segment and the non-peak segment in the histogram and separate the non-peak segment;

[0086] Step 4: Use 0.17% of the grayscale pixels to replace the grayscale in the non-peak section, and use 8 grayscales to replace all grayscales below 4671:

[0087] Step 5: Grayscale conversion:

[0088] =

[0089] Where g is the single-channel matrix of image pixels after grayscale replacement in step 4.

[0090] A = ;

[0091] B = 500(f(x) - f(y)) + 32768

[0092] C = 200(f(y) - f(z)) + 32768

[0093] where f(t) =

[0094] [A, B, C] are the three channels of the resulting image of grayscale conversion.

[0095] Step 6: Convert the matrix A in step 5 to 32-bit floating point data so that it is not easy to lose precision in the subsequent steps;

[0096] Step 7: Denoise and remove irrelevant details, and open the weight adjustment parameter. A larger value makes the image smoother and removes more noise and irrelevant details, while a smaller parameter value retains more details and removes less noise;

[0097] 7.1 Initialization parameters: Set the step size factor, neighborhood size, and randomly initialize the weight matrix.

[0098] 7.2 Traversing image pixels: extracting the neighborhood matrix pixel by pixel as input signal.

[0099] 7.3 Calculate output and error: The output is the dot product of the weight and the neighborhood pixels, and the error is the difference between the original value and the output.

[0100] 7.4 Dynamically update weights: adjust the weight matrix according to the error.

[0101] 7.5 Iteration convergence: Repeat until the error stabilizes or the preset number of iterations is reached, which is generally set to 5 times.

[0102] Step 8: Enhance the image in the frequency domain and open the weight adjustment parameters. Smaller values ​​will enhance low-frequency details, that is, the large-scale structure of the image; larger values ​​will enhance high-frequency details, such as edges, textures, and other subtle features;

[0103] 8.1 Use Fast Fourier Transform (FFT) to convert the image from the spatial domain to the frequency domain and generate a frequency domain matrix in complex form:

[0104] =

[0105] 8.2 Move the zero-frequency component to the center of the spectrum for easier visualization and processing.

[0106] 8.3 Apply a Butterworth high-pass filter with adjustable order n to balance sharpening intensity and transition smoothness:

[0107]

[0108] in, is the distance from the point to the center of the spectrum, is the cutoff frequency.

[0109] 8.4 Multiply the filter mask by the frequency domain matrix to enhance the high-frequency components and perform nonlinear amplification on the high-frequency region coefficients to further enhance the details:

[0110] = *

[0111] 8.5 Convert the processed frequency domain matrix back to the spatial domain, take the modulus of the inverse transformation result, and normalize it to the grayscale range of [0, 65535]. Superimpose the Laplacian operator on the resulting image to further enhance local details.

[0112] Step 9: Convert the data result in step 8 back to 16-bit integer and horizontally concatenate it with matrices B and C obtained in step 5, then apply the inverse process of grayscale conversion to obtain the enhanced image.

[0113] Figure 53 is a schematic diagram of the effects before and after image enhancement in an embodiment of the present invention. By adopting the solution of this embodiment, the structural and texture details in the 16-bit X-ray input image are significantly enhanced.

[0114] Through the description of the above embodiments, those skilled in the art will clearly understand that the methods according to the above embodiments can be implemented using software plus the necessary general-purpose hardware platform. Of course, hardware can also be used, but in many cases the former is a more preferred embodiment. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, or optical disk) and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0115] Example 2

[0116] This embodiment also provides an image enhancement device for implementing the aforementioned embodiments and preferred implementations. Details already described will not be repeated. The term "module" used below refers to a combination of software and hardware that implements the specified functionality. While the devices described in the following embodiments are preferably implemented in software, hardware, or a combination of software and hardware, is also contemplated.

[0117] Figure 6 FIG. 1 is a structural block diagram of an image enhancement device according to an embodiment of the present invention. Figure 6 As shown, the device includes:

[0118] A generating module 60 is configured to generate a histogram of the initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels;

[0119] A search module 61 is configured to search for a noise region in the initial grayscale image according to the histogram;

[0120] a denoising module 62 for denoising the noise region in the initial grayscale image to obtain an intermediate grayscale image;

[0121] A conversion module 63, configured to convert the intermediate grayscale image into an intermediate color image;

[0122] an enhancement module 64, configured to enhance the intermediate color image to obtain a target color image;

[0123] The inverse conversion module 65 is configured to inversely convert the target color image into a target grayscale image.

[0124] Optionally, the search module includes: a division unit, configured to divide the histogram into peak segments and trough segments; and a positioning unit, configured to position a pixel area corresponding to the trough segment as a noise area in the initial grayscale image.

[0125] Optionally, the denoising module includes: a reading unit for reading the initial grayscale value of each pixel in the noise area; a determination unit for determining, for each pixel, the grayscale segment to which the initial grayscale value belongs; a replacement unit for finding a denoising grayscale value that matches the grayscale segment and replacing the initial grayscale value with the denoising grayscale value; and a processing unit for obtaining an intermediate grayscale image after the initial grayscale values ​​of all pixels in the noise area are replaced.

[0126] Optionally, the enhancement module includes: an analysis unit for analyzing the brightness value of the first channel in the intermediate color image; a denoising unit for denoising the intermediate color image based on the brightness value to obtain a first color image; a conversion unit for converting the first color image from the spatial domain to the frequency domain and extracting the frequency domain matrix of the first color image; and an enhancement unit for performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image.

[0127] Optionally, the denoising unit includes: an acquisition subunit for acquiring an initial weight matrix; a traversal subunit for traversing the pixels of the intermediate color image and extracting the neighborhood matrix of each pixel pixel by pixel; an iteration subunit for iteratively performing the following steps for each pixel until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product of the weight of the current cycle with the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; judging whether the difference is less than a threshold; if the difference is greater than or equal to the threshold, adjusting the weight matrix of the next cycle based on the difference.

[0128] Optionally, the enhancement unit includes: a processing subunit, used to locate the zero-frequency component in the frequency domain matrix and transfer the zero-frequency component to the center of the spectrum; a first calculation subunit, used to calculate the distance value from the frequency domain coordinate to the center of the spectrum for each pixel of the first color image; a second calculation subunit, used to calculate the filter mask of the frequency domain matrix based on the distance value, wherein the filter mask is used to balance the sharpening intensity and transition smoothness during image enhancement; an operation subunit, used to multiply the frequency domain matrix with the filter mask to obtain a frequency domain enhancement matrix; and an inverse conversion subunit, used to inversely convert the frequency domain enhancement matrix into the spatial domain to obtain a target color image.

[0129] Optionally, the second calculation subunit is further used to: configure the adjustment order n of the Butterworth high-pass filter; calculate the filter mask of the frequency domain matrix using the following formula: : ;in, is the distance between the frequency domain coordinate of the pixel point and the center of the spectrum, is the cutoff frequency.

[0130] Optionally, the generation module includes: a reading unit for reading the grayscale value of each pixel in the initial grayscale image; a statistical unit for counting the number of pixels corresponding to each grayscale value; and a generation unit for generating a histogram of the initial grayscale image with the grayscale value as the horizontal coordinate and the number of pixels as the vertical coordinate.

[0131] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0132] Example 3

[0133] An embodiment of the present invention further provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0134] Optionally, in this embodiment, the storage medium may be configured to store a computer program for executing:

[0135] S1, generating a histogram of an initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels;

[0136] S2, searching for a noise area in the initial grayscale image according to the histogram;

[0137] S3, denoising the noise area in the initial grayscale image to obtain an intermediate grayscale image;

[0138] S4, converting the intermediate grayscale image into an intermediate color image;

[0139] S5, enhancing the intermediate color image to obtain a target color image;

[0140] S6, inversely converting the target color image into a target grayscale image.

[0141] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.

[0142] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0143] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0144] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:

[0145] S1, generating a histogram of an initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels;

[0146] S2, searching for a noise area in the initial grayscale image according to the histogram;

[0147] S3, denoising the noise area in the initial grayscale image to obtain an intermediate grayscale image;

[0148] S4, converting the intermediate grayscale image into an intermediate color image;

[0149] S5, enhancing the intermediate color image to obtain a target color image;

[0150] S6, inversely converting the target color image into a target grayscale image.

[0151] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0152] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0153] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0154] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0155] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0156] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0157] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk, or optical disk, etc., various media that can store program code.

[0158] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for enhancing an image, characterized in that: include: Generate a histogram of the initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; searching for a noise region in the initial grayscale image according to the histogram; Denoising the noise region in the initial grayscale image to obtain an intermediate grayscale image; Converting the intermediate grayscale image into an intermediate color image; enhancing the intermediate color image to obtain a target color image; Inversely converting the target color image into a target grayscale image; wherein, enhancing the intermediate color image to obtain a target color image comprises: parsing the brightness value of the first channel in the intermediate color image; denoising the intermediate color image based on the brightness value to obtain a first color image; converting the first color image from the spatial domain to the frequency domain, and extracting the frequency domain matrix of the first color image; performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image; wherein, denoising the intermediate color image based on the brightness value to obtain the first color image comprises: obtaining an initial weight matrix; traversing the pixels of the intermediate color image, and extracting the neighborhood matrix of each pixel pixel by pixel; iteratively performing the following steps for each pixel until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product between the weight of the current cycle and the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; judging whether the difference is less than a threshold; and if the difference is greater than or equal to the threshold, adjusting the weight matrix of the next cycle based on the difference.

2. The method according to claim 1, characterized in that Searching for a noise area in the initial grayscale image according to the histogram includes: Dividing the histogram into peak segments and trough segments; The pixel area corresponding to the trough segment is positioned as the noise area in the initial grayscale image.

3. The method according to claim 2, characterized in that Denoising the noise region in the initial grayscale image to obtain an intermediate grayscale image, comprising: Reading an initial grayscale value of each pixel in the noise area; For each pixel, determining the grayscale segment to which the initial grayscale value belongs; Searching for a denoised grayscale value that matches the grayscale segment, and replacing the initial grayscale value with the denoised grayscale value; After the initial grayscale values ​​of all pixels in the noise area are replaced, an intermediate grayscale image is obtained.

4. The method according to claim 1, wherein Performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image includes: Locating a zero-frequency component in the frequency domain matrix and shifting the zero-frequency component to a center of a frequency spectrum; For each pixel of the first color image, calculating a distance value from the frequency domain coordinate to the center of the spectrum; Calculating a filter mask of the frequency domain matrix based on the distance value, wherein the filter mask is used to balance sharpening intensity and transition smoothness during image enhancement; Multiplying the frequency domain matrix by the filter mask to obtain a frequency domain enhancement matrix; The frequency domain enhancement matrix is ​​inversely transformed into the spatial domain to obtain a target color image.

5. The method according to claim 4, characterized in that Calculating a filter mask of the frequency domain matrix based on the distance value includes: Configure the adjustment order n of the Butterworth high-pass filter; The filter mask of the frequency domain matrix is ​​calculated using the following formula: : ; in, is the distance between the frequency domain coordinate of the pixel point and the center of the spectrum, is the cutoff frequency.

6. The method according to claim 1, characterized in that Generate a histogram of the initial grayscale image to be enhanced, including: Reading the grayscale value of each pixel in the initial grayscale image; Count the number of pixels corresponding to each grayscale value; A histogram of the initial grayscale image is generated with the grayscale value as the abscissa and the number of pixels as the ordinate.

7. An image enhancement device, characterized in that: include: A generating module, configured to generate a histogram of the initial grayscale image to be enhanced, wherein the horizontal axis of the histogram is the grayscale value and the vertical axis is the number of pixels; A search module, configured to search for a noise area in the initial grayscale image according to the histogram; a denoising module, configured to denoise the noise region in the initial grayscale image to obtain an intermediate grayscale image; A conversion module, configured to convert the intermediate grayscale image into an intermediate color image; an enhancement module, configured to enhance the intermediate color image to obtain a target color image; An inverse conversion module, configured to inversely convert the target color image into a target grayscale image; The enhancement module includes: an analysis unit for analyzing the brightness value of the first channel in the intermediate color image; a denoising unit for denoising the intermediate color image based on the brightness value to obtain a first color image; a conversion unit for converting the first color image from a spatial domain to a frequency domain and extracting a frequency domain matrix of the first color image; and an enhancement unit for performing detail enhancement on the first color image based on the frequency domain matrix to obtain a target color image. The denoising unit includes: an acquisition subunit for acquiring an initial weight matrix; a traversal subunit for traversing the pixels of the intermediate color image and extracting the neighborhood matrix of each pixel pixel by pixel; an iteration subunit for iteratively performing the following steps for each pixel until the error is less than a threshold or the number of iterations reaches a preset number: performing a dot product of the weight of the current cycle with the neighborhood matrix to obtain a target pixel value; calculating the difference between the target pixel value and the original pixel value of the pixel; judging whether the difference is less than a threshold; if the difference is greater than or equal to the threshold, adjusting the weight matrix of the next cycle based on the difference.

8. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image enhancement algorithm based on wavelet transform and fusing high-frequency and low-frequency information

    CN111583123A

  • Intelligent denoising method for leather fiber MCT tomography image and application

    CN113313647A