An endoscopic image enhancement method, system, medium, and product
Patent Information
- Application Number
- CN202610177735.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-07
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2046-02-07
AI Technical Summary
[0004]然而,图像锐化技术主要侧重于增强图像的空间频率特征,对于图像的颜色信息缺乏针对性的处理
[0049] 1. By decomposing the initial RGB image of the endoscope to be processed into three independent grayscale channels (R, G, and B), and constructing an initial grayscale mapping function containing 256 optimization variables for each grayscale channel, the optimal mapping parameters are determined based on a preset optimization objective function. Finally, the enhanced image is obtained after fusion processing. Addressing the characteristics of monochromatic and low-contrast industrial endoscope images, this method achieves precise enhancement of subtle color differences through independent channel optimization. Compared to traditional global enhancement methods, it avoids image color distortion and background noise amplification, effectively improving the visual recognition of internal defects in aircraft engines (such as initial corrosion and microcracks), significantly reducing the false negative rate, and meeting the high-precision detection requirements for identifying defects or anomalies through color differences.
Smart Images

Figure CN122066590B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more particularly to an endoscopic image enhancement method, system, medium, and product. Background Technology
[0002] Industrial endoscope inspection is a key means of identifying internal defects and assessing the condition of aircraft engines. The quality of the images acquired directly affects the accuracy and reliability of the inspection results. In actual inspection, key components inside the engine, such as the combustion chamber and turbine blades, are often in an environment with limited color and light. This results in the overall color tone of the acquired images being concentrated, with low contrast and weak color gradation. As a result, the color changes of early minor defects (such as initial corrosion and microcracks) are difficult to be identified by the human eye or conventional algorithms, leading to missed detections and posing a potential hazard to flight safety.
[0003] To improve the visual quality of endoscopic images, existing technologies employ specific spatial filters, such as the Laplacian operator or gradient operator, to perform convolution operations on the image, highlighting the boundaries and texture details between different regions. By enhancing the high-frequency components of the image, image sharpening can make edges clearer, thereby visually improving image contrast and making structural contours more prominent.
[0004] However, image sharpening techniques primarily focus on enhancing the spatial frequency characteristics of images, lacking targeted processing of color information. In endoscope images of aero-engines, many early defects do not manifest as obvious edge or texture changes, but rather as subtle color differences. While sharpening enhances edges, it can easily over-amplify noise in the image and is not sensitive to weak color changes within a single color region. It may even interfere with the observation of color differences by enhancing irrelevant texture details, making it difficult to meet the high-precision detection requirements for identifying defects or anomalies through color differences. Summary of the Invention
[0005] This application provides an endoscopic image enhancement method, system, medium, and product to solve the technical problem of how to meet the high-precision detection requirements of identifying defects or abnormalities through color differences.
[0006] In a first aspect, embodiments of this application provide an endoscopic image enhancement method, including:
[0007] Acquire the initial RGB image of the endoscope to be processed, and decompose the initial RGB image of the endoscope into three independent grayscale channels: R, G, and B.
[0008] An initial grayscale mapping function is constructed for each grayscale channel, and each initial grayscale mapping function includes 256 optimization variables;
[0009] In each grayscale channel, all initial grayscale values are mapped to target grayscale values through the corresponding initial grayscale mapping function. The initial RGB image of the endoscope includes 256 initial grayscale values.
[0010] Based on the target grayscale value set of each pixel, the optimal mapping parameters corresponding to each grayscale channel are determined by a preset optimization objective function, so that the enhanced image color difference of the enhanced endoscope RGB image reaches a preset enhancement ratio compared with the initial image color difference of the initial RGB image of the endoscope.
[0011] Based on the optimal mapping parameters, the initial grayscale mapping function is updated to obtain the optimal grayscale mapping function corresponding to each grayscale channel;
[0012] In each grayscale channel, all the initial grayscale values are mapped to the optimal grayscale values using the optimal grayscale mapping function to obtain the mapped grayscale channel image;
[0013] All the mapped grayscale channel images are fused to obtain an endoscope-enhanced RGB image.
[0014] Optionally, all the optimization variables in each grayscale channel are greater than 0, and the sum of the 256 optimization variables in each grayscale channel is 255. The step of mapping all initial grayscale values to target grayscale values using the initial grayscale mapping function includes:
[0015] The initial grayscale mapping function is:
[0016] , , ;
[0017] in, The initial grayscale value in the R grayscale channel is the target grayscale value corresponding to g. The k-th optimization variable in the R grayscale channel; The initial grayscale value in the G grayscale channel is the target grayscale value corresponding to g. The k-th optimization variable in the G grayscale channel; The initial grayscale value in the B grayscale channel is the target grayscale value corresponding to g. The k-th optimization variable in the B grayscale channel.
[0018] Optionally, the optimal mapping parameters for each grayscale channel are determined based on the target grayscale value set for each pixel using a preset optimization objective function, including:
[0019] Based on the color vector of each pixel, the first Euclidean distance between all pixel pairs in the initial RGB image of the endoscope is calculated using the following formula:
[0020] ;
[0021] Wherein d(p) i p j ) represents the first Euclidean distance, p i p j p represents any two pixels in the initial RGB image of the endoscope. i The color vector is (R i G i B i ), the p j The color vector is (R j G j B j );
[0022] Based on the first Euclidean distance of all the pixel pairs, the initial image color difference of the initial RGB image of the endoscope is calculated using the following formula:
[0023] ;
[0024] Where D0 is the color difference of the initial image, and N is the total number of pixels in the initial RGB image of the endoscope;
[0025] Based on the target grayscale value set of each pixel, calculate the second Euclidean distance between all pairs of pixels;
[0026] The color difference of the enhanced image is calculated based on all the second Euclidean distances;
[0027] Based on all the optimization variables, with the preset enhancement ratio of the enhanced image color difference to the initial image color difference as the optimization objective, the preset optimization objective function is constructed and solved to obtain the optimal mapping parameters corresponding to each grayscale channel.
[0028] Optionally, based on all the optimization variables, and with the preset enhancement ratio of the enhanced image color difference to the initial image color difference as the optimization objective, the preset optimization objective function is constructed and solved to obtain the optimal mapping parameters corresponding to each grayscale channel, including:
[0029] Calculate the product of the initial image color difference and the preset enhancement ratio;
[0030] The preset optimization objective function is: min(X)|D x -m×D0|;
[0031] in, X is the optimal mapping parameter, and D is the optimal mapping parameter. X The enhancement of image color difference is defined as m, where m is the preset enhancement ratio.
[0032] When the first absolute difference between the enhanced image color difference and the product satisfies the preset optimization objective function, the optimal mapping parameters are obtained. The optimal mapping parameters include 256 optimal mapping variables corresponding to each grayscale channel.
[0033] Optionally, before determining the optimal mapping parameters for each grayscale channel using a preset optimization objective function, the method further includes:
[0034] Spatial downsampling is performed on the initial RGB image of the endoscope and the enhanced RGB image of the endoscope to obtain the initial RGB sub-image of the endoscope and the enhanced RGB sub-image of the endoscope;
[0035] The color difference of the initial image is calculated based on the initial RGB sub-image of the endoscope, and the color difference of the enhanced image is calculated based on the enhanced RGB sub-image of the endoscope.
[0036] Optionally, the method for calculating the initial image color difference of the initial RGB image of the endoscope further includes:
[0037] Calculate the color distribution variance of the initial RGB image of the endoscope, and determine the main background color center based on the color distribution variance;
[0038] A background deviation is calculated for each pixel based on the center of the main background color.
[0039] Based on all the aforementioned background deviations, the initial image color difference is calculated using the following formula:
[0040] ;
[0041] Among them, w ij For pixel pairs (p i p j The color difference weight is positively correlated with the second absolute difference of the background deviation of the corresponding pixel pair.
[0042] Optionally, after obtaining the endoscopic-enhanced RGB image, the method further includes:
[0043] Calculate the color difference value between each pixel in the enhanced RGB image of the endoscope and the corresponding pixel in the initial RGB image of the endoscope;
[0044] When the color difference value of the target pixel is greater than a preset difference threshold, the target pixel is visually highlighted in the endoscopic enhanced RGB image, where the target pixel is any of the pixels.
[0045] In a second aspect, embodiments of this application provide an endoscopic image enhancement system, which includes: one or more processors and a memory; the memory is coupled to one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the endoscopic image enhancement system to perform the method as described in the first aspect and any possible implementation thereof.
[0046] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on an endoscopic image enhancement system, cause the endoscopic image enhancement system to perform the method described in the first aspect and any possible implementation thereof.
[0047] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on an endoscopic image enhancement system, cause the endoscopic image enhancement system to perform the method described in the first aspect and any possible implementation thereof.
[0048] In summary, one or more technical solutions provided in this application have at least the following technical effects or advantages:
[0049] 1. By decomposing the initial RGB image of the endoscope to be processed into three independent grayscale channels (R, G, and B), and constructing an initial grayscale mapping function containing 256 optimization variables for each grayscale channel, the optimal mapping parameters are determined based on a preset optimization objective function. Finally, the enhanced image is obtained after fusion processing. Addressing the characteristics of monochromatic and low-contrast industrial endoscope images, this method achieves precise enhancement of subtle color differences through independent channel optimization. Compared to traditional global enhancement methods, it avoids image color distortion and background noise amplification, effectively improving the visual recognition of internal defects in aircraft engines (such as initial corrosion and microcracks), significantly reducing the false negative rate, and meeting the high-precision detection requirements for identifying defects or anomalies through color differences.
[0050] 2. By defining a mapping function structure based on the cumulative sum of optimization variables, and taking the enhancement of the image color difference to reach a preset multiple of the original image color difference as the optimization objective, a solvable optimization problem is constructed. This transforms the image enhancement problem into a constrained optimization problem with a clear mathematical objective, achieving controllable and quantitative enhancement of color contrast. Users can flexibly control the enhancement intensity by adjusting the enhancement ratio parameter m to adapt to different detection scenarios and image quality requirements. At the same time, Euclidean distance is introduced as a color difference metric to ensure that the enhancement process conforms to the characteristics of human visual perception, making the enhancement results more practical and interpretable.
[0051] 3. By introducing a downsampling strategy to reduce computational complexity, calculating color differences based on color distribution features, and using auxiliary methods such as visual labeling of over-enhanced areas, the algorithm's practicality and robustness are significantly improved while ensuring enhancement effects. Downsampling processing enables the method to meet the real-time processing needs of industrial sites; the color distribution-based weighting mechanism enhances the algorithm's adaptability to background areas; and the over-enhanced labeling function provides quality control tools for inspectors, preventing misjudgments caused by local over-enhanced areas. Attached Figure Description
[0052] Figure 1 This is a schematic flowchart of the endoscopic image enhancement method provided in the embodiments of this application;
[0053] Figure 2 This is a flowchart illustrating the process of determining the optimal mapping parameters provided in an embodiment of this application;
[0054] Figure 3 This is an initial-enhanced endoscopic image obtained by implementing the endoscopic image enhancement method of this application, as provided in the embodiments of this application.
[0055] Figure 4 This is a schematic diagram of the structure of an endoscopic image enhancement system provided in an embodiment of this application.
[0056] Explanation of reference numerals in the attached figures: 401, Central Processing Unit; 402, Read-Only Memory; 403, Random Access Memory; 404, Bus; 405, Input / Output Interface; 406, Input Section; 407, Output Section; 408, Storage Section; 409, Communication Section; 410, Driver; 411, Removable Media. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0058] In the description of the embodiments of this application, words such as "illustrative," "for example," or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "illustrative," "for example," or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of words such as "illustrative," "for example," or "for example" is intended to present the relevant concepts in a specific manner.
[0059] In the description of the embodiments of this application, the terms "first, second, third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first, second, third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0060] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0061] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0062] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.
[0063] This application provides an endoscopic image enhancement method, system, medium, and product that can meet the high-precision detection requirements for identifying defects or abnormalities through color differences.
[0064] Figure 1 This is a schematic flowchart of the endoscopic image enhancement method provided in the embodiments of this application.
[0065] This invention discloses an endoscopic image enhancement method, such as... Figure 1 As shown, the steps include the following.
[0066] S101. Obtain the initial RGB image of the endoscope to be processed, and decompose the initial RGB image of the endoscope into three independent grayscale channels: R, G, and B.
[0067] Specifically, an unprocessed raw digital image of the area to be inspected inside an aircraft engine, namely the initial RGB image of the endoscope, needs to be read from the image acquisition interface of the industrial endoscope system or from a specified storage medium. This image is in standard RGB color image format, where the color information of each pixel is determined by the intensity values of the three color channels: red (R), green (G), and blue (B). Then, channel decomposition processing is performed on this initial RGB image of the endoscope. That is, through memory operations or image processing library functions, the R, G, and B component values of each pixel in the color image are extracted separately and recombined to form three single-channel grayscale images of the same size as the original image but containing only the information of a single color component. Finally, three independent grayscale images representing the intensity distribution of the R, G, and B components are output, laying the data structure foundation for subsequent channel-specific processing.
[0068] In this context, the initial RGB image of the endoscope refers to the raw digital image acquired and output by the industrial endoscope system, encoded using the standard RGB color model. Each pixel contains three 8-bit (0-255) intensity components: red (R), green (G), and blue (B), used to represent the color information of the surface of the object inside the engine. The grayscale channel, in this context, specifically refers to a two-dimensional matrix formed by extracting the intensity values of all pixels of a particular color component (such as the red component R) from the RGB color image. Each element in this matrix represents the intensity of the corresponding pixel on that color component, creating a grayscale image that only reflects the brightness variations of that color component.
[0069] S102. Construct an initial grayscale mapping function for each grayscale channel. Each initial grayscale mapping function includes 256 optimization variables.
[0070] Specifically, for the three grayscale channels of the input RGB image—red (R), green (G), and blue (B)—each is processed independently. For each channel (e.g., the red channel), a data structure is created. This structure is essentially a lookup table, defining which new target grayscale value should be mapped to for every possible initial grayscale value from 0 to 255. Unlike using fixed mathematical formulas, this step parameterizes all 256 mapping relationships. That is, for the red channel, its initial grayscale mapping function is completely defined by 256 independent, adjustable parameters—the optimization variables. Variable 1 determines the output of initial grayscale value 0, variable 2 determines the output of initial grayscale value 1, and so on, until variable 256 determines the output of initial grayscale value 255. Similarly, the green and blue channels also construct their own mapping functions defined by another 256 optimization variables. Therefore, the entire transformation framework contains a total of 3 independent mapping functions and a total of 3 × 256 = 768 optimization variables. This construction process involves creating and initializing these lookup table structures in memory, and setting their entries (or elements) as variables to be determined. This provides an adjustable and improveable target for subsequent optimization algorithms (such as genetic algorithms, gradient descent, etc.), thereby enabling the search for the best image enhancement effect with a very high degree of freedom.
[0071] The initial grayscale mapping function refers to a mathematical mapping relationship. Its input domain is integer grayscale values from 0 to 255, and its output domain is also integer grayscale values from 0 to 255. The specific form of this function (i.e., the correspondence between input and output) is determined by a set of parameters to be optimized. Before optimization, the specific mapping relationship is undetermined. Optimization variables refer to those parameters whose values are not yet determined and need to be solved through subsequent optimization processes. Each optimization variable corresponds to a basic parameter in the definition of the mapping function, and its value directly affects the mapping result of one or more input grayscale values.
[0072] S103. In each grayscale channel, all initial grayscale values are mapped to target grayscale values through the corresponding initial grayscale mapping function. The initial RGB image of the endoscope includes 256 initial grayscale values.
[0073] Specifically, the process iterates through each pixel in each channel, reads its initial grayscale value, and uses it as input to the corresponding mapping function for that channel. The calculated output value—the target grayscale value—is then written to the corresponding pixel in the new image. This mapping operation defines the conversion relationships for all 256 possible grayscale levels (from 0 to 255) in that channel, ensuring that every pixel value in the image can be accurately converted. Because the R, G, and B channels are processed independently, they can share the same mapping function (to achieve overall brightness and contrast adjustment) or use different mapping functions (to achieve color balance and correction). After completing the mapping of all three channels, the generated new R, G, and B channels are recombined to finally obtain a new RGB image after grayscale mapping adjustment.
[0074] The initial grayscale value represents the original brightness or intensity value of each pixel in the grayscale channel of the image before any processing. In an 8-bit image, its value ranges from 0 (darkest) to 255 (brightest). The target grayscale value refers to the new pixel brightness or intensity value obtained after the initial grayscale value is transformed by the initial grayscale mapping function, which will constitute the pixels of the final output image.
[0075] Based on the above embodiments, as an optional embodiment, all optimization variables in each grayscale channel are greater than 0, and the sum of the 256 optimization variables in each grayscale channel is 255. Figure 1 The initial grayscale mapping function proposed in step S103 shown can be implemented by formula (1), which will be explained in detail below.
[0076] , , (1)
[0077] in, Let g be the target gray value corresponding to the initial gray value in the R gray channel. Let k be the k-th optimization variable in the R grayscale channel; Let g be the target gray value corresponding to the initial gray value in the G gray channel. Let be the k-th optimization variable in the G grayscale channel; Let g be the target gray value corresponding to the initial gray value in the B gray channel. Let be the k-th optimization variable in the B grayscale channel.
[0078] Specifically, referring to formula (1), for each of the three grayscale channels R, G, and B, the target grayscale value needs to be calculated according to the formula defined in this claim. Taking the R channel as an example, for any given initial grayscale value g (g is an integer from 0 to 255), its corresponding target grayscale value in the R channel is... The calculation formula is This is equivalent to optimizing the 256 variables corresponding to the R channel ( , , , ...... The values of the G and B channels are summed up, and the resulting sum is the target grayscale value. For the G and B channels, their corresponding optimization variables are used respectively. and Each target grayscale value is obtained by calculating according to the same accumulation rule. and .
[0079] S104. Based on the target grayscale value set of each pixel, determine the optimal mapping parameters corresponding to each grayscale channel through a preset optimization objective function, so that the enhanced image color difference of the enhanced endoscope RGB image reaches the preset enhancement ratio to the initial image color difference of the initial endoscope RGB image.
[0080] Specifically, after mapping all initial grayscale values in the three grayscale channels to target grayscale values (i.e., obtaining the target grayscale value of each pixel in each channel), it is necessary to evaluate the degree of change in the overall visual effect (especially color difference) compared to the original image if an enhanced image is generated according to the current mapping relationship, based on the target grayscale value set (i.e., the complete dataset consisting of the target grayscale values obtained after mapping all pixels in the R, G, and B channels). A preset optimization objective function is invoked, which takes the current 768 optimization variables (i.e., the parameters defining the mapping function of the three channels) as input, and its function value reflects the difference between the enhanced image generated based on these parameters and the original image in a certain quantization. The difference between the degree of difference in indicators (such as color, brightness, contrast, etc.) and the expected target is to optimize the objective function. The purpose of optimizing the objective function is to iteratively adjust the values of these 768 optimization variables so that the ratio of the final calculated enhanced image color difference to the initial image color difference infinitely approaches or equals a pre-set enhancement ratio m and m>1. When the optimization process converges, that is, when a set of optimization variable values that minimizes the preset optimization objective function value (or satisfies other convergence criteria) is found, this set of values is determined as the optimal mapping parameters. This process may involve complex iterative calculations, requiring repeated execution of the loop of updating variables → calculating mapping → evaluating color difference → calculating objective function value → judging whether convergence has occurred, until the optimal solution is found.
[0081] The target grayscale value set for each pixel refers to the dataset corresponding to each pixel in the initial RGB image of the endoscope, obtained from the previous mapping operation, consisting of the new grayscale values in the R, G, and B channels. The preset optimization objective function is a predefined mathematical function whose input is all optimization variables and whose output is a parameter used to measure the deviation between the image enhancement effect corresponding to the current optimization variable and the desired target. The goal of the optimization process is to find the variable values that minimize the function's output (or satisfy other conditions). The optimal mapping parameters are the specific values of the set of 768 optimization variables that, after optimization, make the preset optimization objective function reach its optimal (usually minimum) value. This set of parameters defines the grayscale mapping function that will ultimately be applied to the three channels of image enhancement. Enhanced image color difference is a quantitative indicator used to measure the overall statistical value (such as the average) of the difference in color vectors (composed of R, G, and B values) between all pixels in the hypothetical enhanced RGB image generated based on the current mapping parameters. The initial image color difference is the same quantitative indicator, but applied to the original initial RGB image of the endoscope. The preset enhancement ratio is a real number m greater than 1, which explicitly sets the desired enhancement target: that is, it is hoped that the color difference of the enhanced image will be m times the color difference of the original image.
[0082] Figure 2 This is a schematic diagram of the process for determining the optimal mapping parameters provided in an embodiment of this application.
[0083] Based on the above embodiments, as an optional embodiment, see [link to embodiment]. Figure 2 ,against Figure 1 The illustrated step S104 can be achieved through... Figure 2 The steps S201-S205 are implemented, and will be explained in detail below.
[0084] S201 calculates the first Euclidean distance between all pixel pairs in the initial RGB image of the endoscope based on the color vector of each pixel.
[0085] (2)
[0086] Wherein d(p) i p j ) represents the first Euclidean distance, p i p j Let p be any two pixels in the initial RGB image of the endoscope. i The color vector is (R i G i B i ), p j The color vector is (R j G jB j ).
[0087] Specifically, referring to formula (2), the color information of each pixel in the initial RGB image of the endoscope is obtained. The color information of each pixel is a three-dimensional vector composed of its component values in the red (R), green (G), and blue (B) color channels, i.e., a color vector. Then, it is necessary to enumerate all possible pairwise pixel combinations in the image, i.e., pixel pairs. For each such pixel pair (e.g., (p... i p j According to formula (2), the first Euclidean distance between the color vectors of the two pixels will be calculated. First, the difference between the components in each color channel will be calculated, then its square will be calculated, then the square differences of the three channels will be summed, and finally the square root of the summation result will be performed. The scalar result obtained is the first Euclidean distance d(p) between the two pixels. i p j ).
[0088] Here, the color vector refers to the representation of the color information of a pixel in the initial RGB image of the endoscope as a mathematical vector. This vector consists of three ordered components, corresponding to the component values of the pixel in the red (R) channel, green (G) channel, and blue (B) channel, respectively. For example, (R... i G i B i A pixel pair refers to an unordered combination of two different pixels selected arbitrarily from all N pixels contained in the initial RGB image of the endoscope. The first Euclidean distance is a scalar value, specifically a metric calculated according to formula (2) to measure the straight-line distance between the color vectors of two pixels in the three-dimensional RGB color space. The larger the value, the greater the color difference between the two pixels.
[0089] S202. Based on the first Euclidean distance of all pixel pairs, calculate the initial image color difference of the initial RGB image of the endoscope.
[0090] (3)
[0091] Where D0 is the initial image color difference, and N is the total number of pixels in the initial RGB image of the endoscope.
[0092] Specifically, referring to formula (3), in step S201, the first Euclidean distance value between each pair of non-repeating pixels in the image has been calculated and stored, forming a set containing N(N-1) / 2 distance values, where N is the total number of pixels in the image. Based on formula (3), these distance values are summarized and statistically analyzed to calculate a single scalar value representing the overall color difference level of the entire image, namely the initial image color difference D0. All the first Euclidean distances obtained in the previous step are summed to obtain the total. Then, divide this sum by a normalization factor N(N-1). This factor essentially corresponds to twice the total number of non-repeating pixel pairs in the image, but in this formula, N(N-1) is directly used as the denominator. The result of this division operation is the initial image color difference D0, which is an average pixel-to-pixel color distance, representing the dispersion of color distribution or overall contrast in the original image. In practical applications, to avoid excessive computation, histograms or downsampling are preferred to process the entire image. No specific restrictions are imposed here.
[0093] Through the above embodiments, massive pixel-level local color difference information is successfully aggregated into a single, stable numerical index D0 that can represent the global color contrast characteristics of the image. This index is the cornerstone of constructing the entire optimization objective function, providing a clear reference benchmark for the preset enhancement ratio m. At the same time, using the average distance of all pixel pairs as a metric, compared with other possible methods (such as only considering the maximum and minimum differences), it can more comprehensively and stably reflect the overall color distribution characteristics of the image, which helps to obtain a more natural and uniform enhancement effect.
[0094] Based on the above embodiments, as an optional embodiment, see [link to embodiment]. Figure 2 ,against Figure 2 The step S202 shown can also be implemented through steps S2021-S2023, which will be explained in detail below.
[0095] S2021. Calculate the color distribution variance of the initial RGB image of the endoscope, and determine the main background color center based on the color distribution variance.
[0096] Specifically, the process iterates through all pixels in the image, obtaining the color vector (R, G, B) for each pixel. Based on the distribution of these color vectors in the RGB 3D space, the mean of all pixel color vectors in the entire image is calculated, i.e., the average color vector. The square of the Euclidean distance (or other distance metric) between each pixel color vector and this average color vector is calculated. The average of these squared distances is then obtained to obtain the color distribution variance. This variance quantifies the overall degree to which the image colors deviate from their average color. Then, the main background color center needs to be determined based on the color distribution variance. For example, if the color distribution variance is very small (below a certain threshold), it indicates that the image colors are very concentrated, and the average color vector of the entire image itself may be the main background color center. If the variance is large, it indicates that there are multiple color regions in the image, and a clustering algorithm (such as K-means) may be used. The number of clusters or the search range is set with reference to the color distribution variance or other derivatives. The center of the cluster containing the most pixels is found from the clustering results and determined as the main background color center. Finally, a vector representing the most important or concentrated area of color in the image is output, i.e., the main background color center.
[0097] Color distribution variance is a statistical measure used to quantify the dispersion or range of variation of all pixel color values (in RGB space or other suitable spaces) in an image relative to its average color. A larger variance indicates a more dispersed color distribution. The main background color center refers to a color vector representing the average or central color of the dominant color region or the region with the highest concentration of pixels in the initial RGB image of the endoscope. It is typically obtained through statistical analysis or cluster analysis.
[0098] S2022: Calculate a background deviation for each pixel based on the center of the main background color.
[0099] Specifically, the process iterates through each pixel in the initial RGB image of the endoscope. For the currently processed pixel, its color vector is read, and the distance between that pixel's color vector and the determined center vector of the dominant background color is calculated. This calculated distance value is defined as the background deviation of that pixel relative to the dominant background. This distance metric can be calculated using Euclidean distance. Finally, a corresponding background deviation value is calculated and recorded for each pixel in the image, forming a deviation map or set of deviation values that corresponds one-to-one with the pixel position. This background deviation metric quantifies the degree of difference between each pixel and the dominant background color of the image.
[0100] The background deviation is a scalar value used to measure the distance or difference between the color vector of a single pixel and the center vector of the main background color in the color space; the larger the value, the greater the difference between the color of the pixel and the center color of the background.
[0101] S2023. Based on all background deviations, calculate the initial image color difference using the following formula:
[0102] (4)
[0103] Among them, w ij For pixel pairs (p i p j The corresponding color difference weight is positively correlated with the second absolute difference of the background deviation of the corresponding pixel pair.
[0104] Specifically, referring to formula (4), the method for calculating the global average distance in step S202 is improved into a weighted average method to more accurately reflect color differences valuable for defect detection, instead of directly calculating these d(p) values. i p j Instead of performing a simple average, we need to perform a simple average for each pair of pixels (p). i p j Calculate a weighting coefficient w ij The determination of this weighting coefficient is positively correlated with the absolute value of the difference between the background deviations of the two pixels, i.e., the second absolute difference. The greater the difference in background deviation values between the two pixels (i.e., one is closer to the background and the other is further away from it), the greater the color difference distance d(p) between them. i p j The weight w in calculating the overall D0 ij The larger the value, the more it is calculated for each pair of pixels according to the preset mapping rules. ij Then, the initial image color difference D0 after weighted average is obtained by calculating according to formula (4).
[0105] Among them, the color difference weight w ij It is for each pair of specific pixels (p) i p j The scalar coefficients assigned are used to adjust the distance d(p) between pixel pairs when calculating the overall color difference. i p j The proportion contributed by ) . The second absolute difference refers to the proportion of pixel pairs (p i p j The absolute value of the difference between the background deviation values of two pixels is used to determine w. ij Size.
[0106] Through the above embodiments, an initial image color difference that better reflects the significant color contrast in an image is calculated, enhancing the guidance of the optimization objective function and the targeting of defect enhancement. In industrial endoscopic inspection, the most valuable color differences often appear between defects (high background deviation) and uniform backgrounds (low background deviation), or between different types of defects. When calculating global color differences, the system automatically focuses on these pixel pairs with high contrast value. This effectively highlights defects against complex backgrounds, significantly improving the accuracy and reliability of detection.
[0107] S203. Based on the target grayscale value set of each pixel, calculate the second Euclidean distance between all pixel pairs.
[0108] For each selected pair of pixels, such as (p i p j The system will read the target grayscale value set for each pixel pair, i.e., p i The target grayscale value set is ( , , ), p j The target grayscale value set is ( , , Then calculate the second Euclidean distance between them. This calculation process is consistent with the form of formula (2) in step S202, except that p in formula (2) is changed. i The color vector is (R i G i B i ), p j The color vector is (R j G j B j Replace ) with p i The target grayscale value set is ( , , ), p j The target grayscale value set is ( , , For each pair of pixels in the image, a scalar value, namely the second Euclidean distance, is calculated. This results in a large dataset containing a measure of the color difference between all pairs of pixels. This dataset will be used to evaluate the overall contrast or detail of the image. In practical applications, to avoid excessive computation, histograms or downsampling are preferred to process the entire image. Alternatively, the second Euclidean distance can be calculated directly for the pixel pairs that have already undergone histogram or downsampling processing in step S202. No specific restrictions are imposed here.
[0109] Here, the target grayscale value set refers to the combination of target grayscale values presented by each pixel after the image has been processed by the aforementioned grayscale mapping function, i.e. ( , , (), , , Let p be the i-th pixel. i The target grayscale value set. The second Euclidean distance is a measure of the difference between two points in a multidimensional space, and its calculation form is consistent with that of formula (2).
[0110] S204. Calculate the color difference of the enhanced image based on all second Euclidean distances.
[0111] Specifically, the calculation method for enhancing image color difference is formally consistent with the formula (3) for calculating the initial image color difference D0 in step S202, except that the distance d(p) in formula (3) is changed. i p j Replace the first Euclidean distance with the second Euclidean distance calculated in step S203, perform summation and averaging operations, and finally obtain a scalar value, denoted as D. X This represents the level of enhancement in overall image color difference under the current mapping parameters X. This D X It will be used as a key variable in the optimization objective function.
[0112] S205. Based on all optimization variables, with the optimization objective of enhancing the color difference of the image to reach the preset enhancement ratio of the initial color difference of the image, construct and solve the preset optimization objective function to obtain the optimal mapping parameters corresponding to each grayscale channel.
[0113] Specifically, the system constructs a preset optimization objective function. The core purpose of this function is to measure the difference between the color difference of the current image and the target difference. This function takes a total of 768 optimization variables previously set for the R, G, and B channels as input. In each iteration, the optimization algorithm (such as genetic algorithm, particle swarm optimization, etc.) generates a new set of optimization variable values. These values are used to construct three new grayscale mapping functions to process the initial image, resulting in a new temporary image. Subsequently, the sum of color differences in this temporary image is calculated. The objective function can then be defined as min(X)|D X -mD0|or min(X)(D X -mD0) 2Finally, by continuously adjusting these 768 optimization variables and repeatedly performing the "mapping-calculation-evaluation" cycle, a specific set of variable values is found that makes DX as close as possible to the preset enhancement ratio D0, thereby minimizing the value of the objective function. When the algorithm converges or reaches the preset stopping condition, these 768 variable values are the final optimal mapping parameters.
[0114] Through the above embodiments, precise quantitative control of the enhancement effect is achieved. Users can intuitively and quantitatively specify the desired enhancement intensity through parameter m, which is impossible with traditional methods. Secondly, the adaptability and optimality of the enhancement process are guaranteed: the final mapping function is not fixed, but is tailored for each specific input image by solving an optimization problem, aiming to achieve the preset m-fold enhancement target in the optimal way. Finally, by incorporating the structural constraints of the mapping function (such as monotonicity and range) into the optimization problem, the physical rationality and visual naturalness of the enhancement result are ensured, and distortions such as over-enhancement, gray-level merging, or inversion are avoided.
[0115] Based on the above embodiments, as an optional embodiment, for Figure 2 The step S205 shown can be implemented through steps S2051-S2053, which will be explained in detail below.
[0116] S2051. Calculate the product of the initial image color difference and the preset enhancement ratio.
[0117] Specifically, two known values are read from memory: the initial image color difference D0 and a preset enhancement ratio m (a real number greater than 1) set by the user or determined by system configuration. The product of these two values is then calculated. This product is a new scalar value representing the target or ideal value of the enhanced image color difference that the optimization process aims to achieve. For example, if D0 is 10.0 and m is 2.0, the calculated product is 20.0. This means that the ultimate goal of this image enhancement is to find a set of mapping parameters that makes the color difference metric of the enhanced image as close as possible to 20.0. This product value serves as the core benchmark for defining the subsequent optimization objective function.
[0118] S2052, The preset optimization objective function is shown in formula (5):
[0119] min(X)|D x -m×D0|(5)
[0120] in, X is the optimal mapping parameter, D X To enhance the color differences in the image, m is the preset enhancement ratio.
[0121] Specifically, min(X) represents the operation of minimizing the optimization variable X. X Enhancing image color difference is not a fixed value, but a function of optimizing variable X. Therefore, the complete meaning of this objective function is: to find a set of optimizing variables X (i.e., a total of 768 optimizing variables) such that the function value |D x -m×D0| reaches its minimum. | | indicates calculating the absolute value of the difference between the two values within the parentheses, meaning the optimization objective is defined as minimizing the color difference D in the enhanced image. X The absolute deviation from the preset target value m×D0 is considered to have been successfully achieved when this absolute deviation is minimized to zero or within a sufficiently small tolerance range. This objective function, along with the constraints derived from formulas (2) and (3) themselves or elsewhere (such as x), is considered to have been successfully achieved. k ≥0, ∑x k =255 etc., x k Let each grayscale channel be an optimization variable, and the sum of all optimization variables for each grayscale channel is 255. Together, they constitute a complete constrained optimization problem, which awaits a solution.
[0122] Here, min(X) represents the minimization operation on variable X, with the goal of finding the value of X that minimizes the subsequent function expression.
[0123] S2053. When the first absolute difference between the enhanced image color difference and the product satisfies the preset optimization objective function, the optimal mapping parameters are obtained. The optimal mapping parameters include 256 optimal mapping variables corresponding to each grayscale channel.
[0124] Specifically, in the process of iteratively solving the objective function defined by formula (5) using the numerical optimization algorithm, the first absolute difference is calculated at each iteration or checkpoint. This first absolute difference is the absolute difference between the enhanced image color difference calculated in the current iteration and the target value m×D0. This first absolute difference is the object to be minimized by the preset optimization objective function. When the first absolute difference is less than or equal to a preset, very small positive number ε (i.e., convergence tolerance), for example, ε=0.001 or 0.0001×(m×D0), no specific restrictions are imposed here. Then it is considered that the objective function has been sufficiently minimized, and the current optimization variable X has made D X When the value is sufficiently close to m×D0, the optimization algorithm terminates its iteration. When this condition is met, the current set of optimization variables X is determined as the optimal mapping parameters. This set of parameters is a data structure containing 768 specific values, which explicitly correspond to the three grayscale channels R, G, and B. These 768 optimal mapping variables are stored or output, and the three optimal grayscale mapping functions are fully defined and can be used at any time for the final enhancement of the original image.
[0125] Among them, the optimal mapping variable is a clear description of the specific composition of the optimal mapping parameter X, indicating that X precisely contains 256 independent optimal variable values for each of the three channels R, G, and B.
[0126] Based on the above embodiments, as an optional embodiment, see [link to embodiment]. Figure 2 ,exist Figure 2 Before step S201 shown, it may also include Figure 2 Steps S206-S207 are implemented, and will be explained in detail below.
[0127] S206. Spatial downsampling is performed on the initial RGB image and the enhanced RGB image of the endoscope to obtain the initial RGB sub-image and the enhanced RGB sub-image of the endoscope.
[0128] Specifically, two stored image data sets are acquired: one is the original, full-resolution initial RGB image of the endoscope; the other is an enhanced, full-resolution RGB image of the endoscope, calculated and reconstructed using a mapping function based on the optimization variable X of the current iteration (this image is hypothetical in the optimization iteration). To accelerate the subsequent calculation of color differences, spatial downsampling is performed on both images to reduce their spatial resolution (i.e., reduce the total number of pixels) while preserving as much macroscopic visual information or statistical features as possible. These images are processed according to a predetermined downsampling algorithm and ratio (e.g., reducing the image width and height to 1 / 4 of their original size, reducing the overall number of pixels to 1 / 16, or directly pre-setting the pixel size). Downsampling can be performed using nearest-neighbor downsampling or bilinear / bicubic downsampling methods. After downsampling, two new, smaller images are obtained: one is a low-resolution version of the original image, i.e., the initial RGB sub-image of the endoscope; the other is a low-resolution version of the enhanced image, i.e., the enhanced RGB sub-image of the endoscope. These two sub-images are visually similar to the original image, but contain a significantly reduced number of pixels. Subsequent optimization iterations require calculating the color difference D0 of the initial image and the color difference D of the enhanced image. X In this case, the full-resolution image will no longer be used; instead, the two downsampled sub-images will be used as the basis for computation. This means that the total number of pixels N' enumerated when calculating the distance between pixel pairs will be much smaller than the original total number of pixels N, thus greatly reducing the amount of computation.
[0129] Spatial downsampling is an image processing operation that refers to reducing the pixel spatial resolution of a digital image using specific algorithms (such as interval sampling, average pooling, bilinear interpolation, etc.) to generate a smaller image with similar content. The initial RGB sub-image of the endoscope refers to the RGB image with lower spatial resolution obtained by spatial downsampling the original, full-resolution initial RGB image of the endoscope; its pixel size (width × height) is smaller than the original image. The enhanced RGB sub-image of the endoscope refers to the RGB image with lower spatial resolution obtained by spatial downsampling a hypothetical, full-resolution enhanced RGB image generated based on the current optimization variable X.
[0130] For example, assuming the initial RGB image of the endoscope has a resolution of 1920×1080 (approximately 2.07 million pixels), simple interlaced sampling (i.e., taking one point every 3 pixels) is used to downsample the image to a 640×360 (approximately 230,000 pixels) sub-image. For the enhanced image (a hypothetical image, also 1920×1080), the exact same downsampling operation is performed, also resulting in a 640×360 sub-image. Thus, when subsequently calculating color differences, the total number of pixels to be processed is reduced from 2.07 million to 230,000, and the number of pixel pairs to be calculated is reduced from approximately 2.14 × 10⁻⁶. 12 Reduced to approximately 2.64 × 10 10 Yes, the computational cost has been reduced by approximately two orders of magnitude, significantly speeding up each optimization iteration.
[0131] Through the above embodiments, the computational efficiency of the entire optimization process is greatly improved without losing almost the core logic of the algorithm (optimization based on color differences). The complexity of calculating the color differences of all pixels is O(N²). For megapixel-level images, direct calculation is often infeasible in terms of computing resources and time. By introducing downsampling, the calculation is transferred to a much smaller sub-image with similar statistical characteristics (because downsampling preserves the macroscopic color distribution), making the originally time-consuming iterative optimization fast and feasible, meeting the actual requirements of industrial inspection sites for processing speed or embedded devices for computing resources.
[0132] S207. Calculate the color difference of the initial image based on the initial RGB sub-image of the endoscope, and calculate the color difference of the enhanced image based on the enhanced RGB sub-image of the endoscope.
[0133] Specifically, the color difference calculation process originally applied to full-resolution images is completely migrated to the initial RGB sub-image and enhanced RGB sub-image of the endoscope obtained by downsampling in step S206. Using the initial RGB sub-image of the endoscope as input, the operation is performed entirely according to the methods and formulas defined in steps S202 or S2021-S2023. All non-repeating pixel pairs in the sub-image are enumerated, and the Euclidean distance between the color vectors of each pair of pixels (which can be called the first Euclidean distance of the sub-image) is calculated. Then, all such distance values are averaged (or weighted average, depending on the specific claims cited), finally yielding a scalar value. This value is used as an approximation of the initial image color difference D0', representing the color contrast level of the original full-resolution image. Since the sub-image is a macroscopic approximation of the original image, this D0' can approximate the original image's D0. Secondly, in the optimization iteration, in order to evaluate the current mapping parameter X, it is necessary to calculate the enhanced image color difference. At this time, the enhanced endoscopic RGB sub-image is used as input. Similarly, following the method defined in steps S203-S204, all pixel pairs in the sub-image are enumerated. Based on the target grayscale value of each pixel in the sub-image after mapping (these values are determined before or after the sub-image is generated), the Euclidean distance between each pair of pixels (called the second Euclidean distance of the sub-image) is calculated. Then, these distance values are averaged to obtain the enhanced image color difference D under the current X. X The approximate value of ' will be used repeatedly throughout the optimization process to calculate D0' and D in each iteration. X ', and based on these approximations, construct and optimize the objective function min(X)|D X '-m×D0'|, thereby finding the optimal mapping parameters.
[0134] S105. Based on the optimal mapping parameters, update the initial grayscale mapping function to obtain the optimal grayscale mapping function for each grayscale channel.
[0135] Specifically, the optimal mapping parameters stored in the previous steps are retrieved from memory, which are a set of 768 specific values. These values represent the precise values of the 256 optimal mapping variables corresponding to each of the three grayscale channels: red, green, and blue. These specific parameter values are then used to fill or assign values to the framework of the initial grayscale mapping function, which was originally defined only by variable symbols. For the red channel, the 256 optimal variable values corresponding to the red channel are extracted from the optimal mapping parameters, and these specific values replace the symbols representing unknown parameters used when defining the initial grayscale mapping function for the red channel. After the replacement, the grayscale mapping function for the red channel is no longer an abstract function "containing 256 optimized variables," but a specific function determined by 256 specific constants that can explicitly calculate the output value corresponding to any input grayscale value g. The same operation is performed on the green and blue channels: their respective initial grayscale mapping functions are updated with their optimal variable values. Finally, three deterministic and optimal grayscale mapping functions are obtained, corresponding to the R, G, and B channels, respectively. These functions are the tools for subsequent final and deterministic enhancement of the original image.
[0136] The optimal mapping parameters refer to a set of 768 specific values obtained by solving the optimization problem, which is a set of 256 optimal mapping variable values for each grayscale channel. The optimal grayscale mapping function refers to the updated grayscale mapping function with a clear mathematical expression, corresponding to the R, G, and B grayscale channels respectively. It represents the specific transformation rule found through optimization that is most suitable for achieving the preset enhancement goal.
[0137] Through the above embodiments, the globally optimal transformation strategy found in the optimization process is precisely and consistently applied to every pixel and every color component of the original image. This ensures that the adjustment of each pixel in each color channel is part of achieving the globally optimal goal of reaching a preset ratio of m for the overall color difference. This guarantees the integrity and repeatability of the enhancement process.
[0138] S107. Fuse all mapped grayscale channel images to obtain an endoscope-enhanced RGB image.
[0139] Specifically, three independent single-channel images, processed by the optimal grayscale mapping function, are acquired: the mapped red channel image, the mapped green channel image, and the mapped blue channel image. These three images are identical in spatial dimensions, and each pixel position corresponds one-to-one, representing the intensity information of the enhanced image in the red, green, and blue color components, respectively. For each pixel position (e.g., coordinates (x, y)) in the output image (the generated "endoscopic enhanced RGB image"), the pixel values at the same position in the three input images are simultaneously read: the pixel value at that position is read from the mapped red channel image, denoted as R(x, y); the pixel value at that position is read from the mapped green channel image, denoted as G(x, y); and the pixel value at that position is read from the mapped blue channel image, denoted as B(x, y). Then, these three values are treated as three components of a color vector and written together to the same position (x, y) in the output image, constituting the final color of that pixel in the enhanced RGB image. This process is performed sequentially or in parallel for each pixel position in the image until all pixels have been assigned values. The final result is a new RGB color image of the same size as the original image, namely the endoscopic enhanced RGB image. Each pixel color of this image is composed of optimized and mapped R, G, and B components. Therefore, its overall visual effect is significantly and controllably improved in color contrast compared to the original image, based on a preset target m.
[0140] Among them, the endoscopic enhanced RGB image refers to a standard RGB format color image finally generated through the above fusion operation. Its color information is composed of optimized and enhanced R, G, and B components, and has enhanced color contrast relative to the input image.
[0141] For example, assume that the three single-channel images after mapping are all 640x480 pixels in size. During fusion, when processing the pixel at position (100, 200), the value of (100, 200) is read from the mapped red channel image: R(100, 200) = 185; the value of (100, 200) is read from the mapped green channel image: G(100, 200) = 195; and the value of (100, 200) is read from the mapped blue channel image: B(100, 200) = 180. Then, at position (100, 200) in the output endoscopic enhanced RGB image, the pixel color is set to (R, G, B) = (185, 195, 180). This "read-combine-write" operation is repeated for all 640*480 = 307200 pixel positions in the image, ultimately generating the complete enhanced RGB image. See also... Figure 3 , Figure 3This is an initial-enhanced endoscopic image obtained by implementing the endoscopic image enhancement method of this application, as provided in the embodiments of this application. Figure 3 The left half of the image is the initial RGB image of the endoscope. Figure 3 The right half of the image shows the final endoscopic enhanced RGB image, which is crucial for applications such as aircraft engine endoscopic inspection. It directly translates the advantages of the algorithm into defect features that are easier for inspectors to identify, or provides higher quality input for subsequent automatic defect identification algorithms, thereby effectively improving the accuracy, reliability and efficiency of the inspection.
[0142] Based on the above embodiments, as an optional embodiment, in Figure 1 After step S107 shown, steps S301-S302 may also be included, which will be explained in detail below.
[0143] S301. Calculate the color difference between each pixel in the enhanced RGB image of the endoscope and the corresponding pixel in the initial RGB image of the endoscope.
[0144] Specifically, two images with perfectly aligned spatial dimensions and pixel arrangement are acquired: one is the final output endoscopic enhanced RGB image, and the other is the original endoscopic initial RGB image. These two images need to be compared pixel-by-pixel to quantify the degree of color change caused by the enhancement operation to each pixel. To do this, every pixel position in the image is traversed (e.g., using row and column numbers as indices). For the currently traversed position (x, y), the color information of the pixel at that position is read from both images: its color vector is read from the endoscopic enhanced RGB image, denoted as (R0, G0, B0), and the corresponding color vector is read from the endoscopic initial RGB image, denoted as (R1, G1, B1). Then, the difference between the two color vectors is calculated using a predetermined mathematical method for measuring the difference, such as Euclidean distance. This process is performed on every pixel in the image, thereby calculating and recording a corresponding color difference value for each pixel position. Finally, a color difference map or a set of difference values is generated, with the same size as the original image but where each pixel value represents the intensity of the color change at that point.
[0145] The color difference value is a scalar value used to quantify the difference between the enhanced pixel color vector and the original pixel color vector at the same spatial location; the larger the value, the more significant the color change at that point due to the enhancement process.
[0146] The above embodiments enable refined, pixel-level post-evaluation of the enhancement effect, providing interpretability and quality control capabilities for the enhancement process. By calculating the color difference value of each pixel, the intensity of the effect of the enhancement operation on different regions of the image can be quantitatively revealed.
[0147] S302. When the color difference value of the target pixel is greater than the preset difference threshold, the target pixel is visually highlighted in the endoscopic enhanced RGB image. The target pixel is any pixel.
[0148] Specifically, the set of color difference values corresponding to each pixel in the image obtained in step S301, along with a pre-set preset difference threshold, is retrieved from the memory or database. This threshold is a scalar value used to distinguish between acceptable color changes and potentially excessive color changes. Each pixel in the endoscopic enhanced RGB image (each pixel can be considered a potential target pixel) is traversed. For the currently traversed pixel, its corresponding color difference value is read and compared with the preset difference threshold. If the color difference value is greater than the preset difference threshold, the pixel is determined to have undergone a relatively drastic color change that may require manual attention or further review, and is therefore marked as a target requiring processing. Once identified as needing identification, the location of the pixel is visually highlighted on the endoscopic enhanced RGB image. This identification operation is a direct image modification or overlay, designed to make the pixel visually distinct from the surrounding area, allowing inspectors to quickly locate it. There are several ways to implement this labeling, such as directly replacing the pixel's color with a high-contrast, eye-catching color (e.g., pure red, bright yellow), drawing a marker of a specific shape (e.g., a crosshair, a rectangle) within a small area centered on the pixel, or temporarily changing the pixel's brightness, saturation, or other attributes to make it blink or highlight. No specific restrictions are imposed here. This labeling operation is performed on all pixels in the image that meet the condition that the color difference value is greater than a preset difference threshold. The final output is still an endoscopic enhanced RGB image, but this image has been overlaid with visual markers to indicate areas that may have excessive enhancement or significant changes.
[0149] Here, the target pixel refers to the specific pixel in the endoscopically enhanced RGB image that is currently being traversed and processed; it is any representative of all pixels in the image. The preset difference threshold is a pre-defined scalar threshold used to determine whether the color change is excessive; if the color difference value of a pixel exceeds this threshold, the enhancement of that pixel is considered potentially excessive or requires special attention. Visual salience is an image processing operation designed to alter the visual appearance of a target pixel or its surrounding area, making it more easily noticed by the observer's eye in the enhanced image.
[0150] The above embodiments add an important layer of quality control and auxiliary analysis to the final enhanced image, enabling visualization of the credibility of the enhancement results and highlighting of risk areas. In scenarios such as industrial inspection where the reliability of results is extremely important, blindly trusting all outputs of the enhancement algorithm may be risky, as the algorithm may produce unexpected excessive distortion in local areas. By introducing threshold judgment and visual marking, it is possible to automatically filter and highlight pixel areas with abnormally drastic color changes, providing inspectors with dual protection: First, it serves as an "enhancement effect anomaly report," reminding inspectors to pay attention to these marked areas and determine whether it is algorithmic distortion or a genuine significant defect being strongly enhanced, thus allowing for a more accurate final judgment based on professional experience and avoiding misjudgments caused by over-enhancement. Second, it enhances the transparency and interactivity of the entire method. Users or system maintainers can control the sensitivity of the markings by adjusting the preset difference threshold to adapt to different image content or inspection standards.
[0151] The endoscopic image enhancement system in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a schematic diagram of the structure of an endoscopic image enhancement system provided in an embodiment of this application.
[0152] It should be noted that, Figure 4 The structure of the endoscopic image enhancement system shown is merely an example and should not impose any limitation on the functionality and scope of application of the embodiments of the present invention.
[0153] like Figure 4 As shown, the endoscopic image enhancement system includes a central processing unit 401, which can perform various appropriate actions and processes according to a program stored in read-only memory 402 or a program loaded from storage section 408 into random access memory 403, such as performing the methods described in the above embodiments. The random access memory 403 also stores various programs and data required for system operation. The central processing unit 401, read-only memory 402, and random access memory 403 are interconnected via bus 404. Input / output interface 405 is also connected to bus 404.
[0154] The following components are connected to the input / output interface 405: an input section 406 including audio input devices, push-button switches, etc.; an output section 407 including a liquid crystal display (LCD) and audio output devices, indicator lights, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the input / output interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 410 as needed so that computer programs read from it can be installed into the storage section 408 as needed.
[0155] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by central processing unit 401, it performs the various functions defined in the present invention. It should be noted that specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.
[0157] Specifically, the endoscopic image enhancement system of this embodiment includes a processor and a memory. The memory stores a computer program, and when the computer program is executed by the processor, it implements the endoscopic image enhancement method provided in the above embodiment.
[0158] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the endoscopic image enhancement system described in the above embodiments; or it may exist independently and not assembled into the endoscopic image enhancement system. The storage medium carries one or more computer programs that, when executed by a processor of the endoscopic image enhancement system, cause the endoscopic image enhancement system to implement the endoscopic image enhancement method provided in the above embodiments.
[0159] The above description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure. The specification and embodiments are considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
Claims
1. An endoscopic image enhancement method, characterized in that, include: Acquire the initial RGB image of the endoscope to be processed, and decompose the initial RGB image of the endoscope into three independent grayscale channels: R, G, and B. An initial grayscale mapping function is constructed for each grayscale channel, and each initial grayscale mapping function includes 256 optimization variables; In each grayscale channel, all initial grayscale values are mapped to target grayscale values through the corresponding initial grayscale mapping function. The initial RGB image of the endoscope includes 256 initial grayscale values. Based on the target grayscale value set of each pixel, the optimal mapping parameters corresponding to each grayscale channel are determined by a preset optimization objective function, so that the enhanced image color difference of the enhanced endoscope RGB image reaches a preset enhancement ratio compared with the initial image color difference of the initial RGB image of the endoscope. Based on the optimal mapping parameters, the initial grayscale mapping function is updated to obtain the optimal grayscale mapping function corresponding to each grayscale channel; In each grayscale channel, all the initial grayscale values are mapped to the optimal grayscale values using the optimal grayscale mapping function to obtain the mapped grayscale channel image; All the mapped grayscale channel images are fused to obtain an endoscope-enhanced RGB image; In each grayscale channel, all optimized variables are greater than 0, and the sum of the 256 optimized variables in each grayscale channel is 255. The initial grayscale mapping function is: , , ; in, The initial grayscale value in the R grayscale channel is the target grayscale value corresponding to g. The k-th optimization variable in the R grayscale channel; The initial grayscale value in the G grayscale channel is the target grayscale value corresponding to g. The k-th optimization variable in the G grayscale channel; The initial grayscale value in the B grayscale channel is the target grayscale value corresponding to g. This refers to the k-th optimization variable in the B grayscale channel; The method for determining the optimal mapping parameters for each grayscale channel based on the target grayscale value set for each pixel using a preset optimization objective function includes: Based on the color vector of each pixel, the first Euclidean distance between all pixel pairs in the initial RGB image of the endoscope is calculated using the following formula: ; Wherein d(p) i p j ) represents the first Euclidean distance, p i p j p represents any two pixels in the initial RGB image of the endoscope. i The color vector is (R i G i B i ), the p j The color vector is (R j G j B j ); Based on the first Euclidean distance of all the pixel pairs, the initial image color difference of the initial RGB image of the endoscope is calculated using the following formula: ; Where D0 is the color difference of the initial image, and N is the total number of pixels in the initial RGB image of the endoscope; Based on the target grayscale value set of each pixel, calculate the second Euclidean distance between all pairs of pixels; The color difference of the enhanced image is calculated based on all the second Euclidean distances; Based on all the optimization variables, with the preset enhancement ratio of the enhanced image color difference to the initial image color difference as the optimization objective, the preset optimization objective function is constructed and solved to obtain the optimal mapping parameters corresponding to each grayscale channel.
2. The method according to claim 1, characterized in that, Based on all the optimization variables, and with the preset enhancement ratio of the enhanced image color difference to the initial image color difference as the optimization objective, the preset optimization objective function is constructed and solved to obtain the optimal mapping parameters corresponding to each grayscale channel, including: Calculate the product of the initial image color difference and the preset enhancement ratio; The preset optimization objective function is: min(X)|D x -m×D0|; in, X is the optimal mapping parameter, and D x The enhancement of image color difference is defined as m, where m is the preset enhancement ratio. For the k-th optimal mapping variable in the R grayscale channel, For the k-th optimal mapping variable in the G grayscale channel, This represents the k-th optimal mapping variable in the B grayscale channel. When the first absolute difference between the enhanced image color difference and the product satisfies the preset optimization objective function, the optimal mapping parameters are obtained. The optimal mapping parameters include 256 optimal mapping variables corresponding to each grayscale channel.
3. The method according to claim 1, characterized in that, Before determining the optimal mapping parameters for each grayscale channel using a preset optimization objective function, the method further includes: Spatial downsampling is performed on the initial RGB image of the endoscope and the enhanced RGB image of the endoscope to obtain the initial RGB sub-image of the endoscope and the enhanced RGB sub-image of the endoscope; The color difference of the initial image is calculated based on the initial RGB sub-image of the endoscope, and the color difference of the enhanced image is calculated based on the enhanced RGB sub-image of the endoscope.
4. The method according to claim 1, characterized in that, The method for calculating the initial image color difference of the initial RGB image of the endoscope further includes: Calculate the color distribution variance of the initial RGB image of the endoscope, and determine the main background color center based on the color distribution variance; A background deviation is calculated for each pixel based on the center of the main background color. Based on all the aforementioned background deviations, the initial image color difference is calculated using the following formula: ; Among them, w ij For pixel pairs (p i p j The color difference weight is positively correlated with the second absolute difference of the background deviation of the corresponding pixel pair.
5. The method according to claim 1, characterized in that, After obtaining the endoscopic-enhanced RGB image, the method further includes: Calculate the color difference value between each pixel in the enhanced RGB image of the endoscope and the corresponding pixel in the initial RGB image of the endoscope; When the color difference value of the target pixel is greater than a preset difference threshold, the target pixel is visually highlighted in the endoscopic enhanced RGB image, where the target pixel is any of the pixels.
6. An endoscopic image enhancement system, characterized in that, The endoscopic image enhancement system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the endoscopic image enhancement system to perform the method as described in any one of claims 1-5.
7. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on the endoscopic image enhancement system, the endoscopic image enhancement system performs the method as described in any one of claims 1-5.
8. A computer program product, characterized in that, When the computer program product is run on the endoscopic image enhancement system, the endoscopic image enhancement system performs the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Endoscope image signal processing device, method, and program
CN108882835A
Image processing method and device, electronic equipment and storage medium
CN117593229A
