Image processing method and device, equipment, medium and program product
By performing linear transformation and gamma transformation on the images of ultra-high resolution imaging devices and adjusting the gamma transformation parameters of the image block, the problem of low image brightness is solved, and the contrast and details are improved, with higher flexibility and real-time.
Patent Information
- Application Number
- CN202510268753.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-06-24
AI Technical Summary
Ultra-high resolution imaging devices have small photosensitive area and limited photocharge storage capabilities, resulting in limited image dynamic range, low sensitivity at low illumination, and low overall image brightness.
By performing linear transformation and gamma transformation on the original grayscale image, the first gamma transformation parameters and the second gamma transformation parameters are calculated respectively, and the gamma transformation parameters are adjusted according to the contrast of the image blocks, and non-linear transformation is realized to adjust the image brightness.
It effectively improves the contrast and detailed information of the image, improves the visual effect of the image, realizes the brightness adjustment of single-frame images, has higher flexibility and real-timeness, reduces memory usage, and improves image processing efficiency.
Smart Images

Figure CN120201134A_ABST
Abstract
Description
Technical Field
[0001] At least one embodiment of the present disclosure relates to the field of image processing, and more particularly to an image processing method, apparatus, device, medium, and program product. Background Art
[0002] Due to the small pixel photosensitive area and limited photo-charge storage capacity of ultra-high resolution imaging devices (such as vertical charge transfer imaging devices, etc.), there are problems such as limited dynamic range and too low sensitivity under low illumination, resulting in a relatively low overall brightness of the image. To solve this problem, it is necessary to adjust the brightness of the output image to enhance the image contrast and enrich the image detail information.
[0003] During the acquisition process of ultra-high resolution images, it is necessary to set appropriate exposure times and lens light intakes according to different ambient light intensities. In addition, achieving automatic brightness adjustment during the image acquisition process is crucial for improving image quality. Summary of the Invention
[0004] In view of the above problems, the present disclosure provides an image processing method, apparatus, device, medium, and program product.
[0005] According to a first aspect of the present disclosure, there is provided an image processing method, the method comprising: performing a linear transformation on the original grayscale image to obtain an initial grayscale image; calculating a gamma transformation parameter for the initial grayscale image to obtain a first gamma transformation parameter; dividing the initial grayscale image into equal regions according to the size information of the initial grayscale image to obtain a plurality of image blocks; for each image block, when the contrast of the image block is greater than or equal to a threshold, determining the first gamma transformation parameter as the gamma transformation parameter of the image block; when the contrast of the image block is less than the threshold, based on the first gamma transformation parameter, adjusting the gamma transformation parameter of the image block to obtain a second gamma transformation parameter; determining the second gamma transformation parameter as the gamma transformation parameter of the image block; and performing a non-linear transformation on the initial grayscale image based on the respective gamma transformation parameters of each image block to obtain a target grayscale image, so as to adjust the brightness of the original grayscale image.
[0006] According to an embodiment of the present disclosure, when the contrast of the image block is less than the threshold, based on the first gamma transformation parameter, adjusting the gamma transformation parameter of the image block to obtain a second gamma transformation parameter, includes: when the first gamma transformation parameter is less than 1, subtracting a preset value from the first gamma transformation parameter to obtain the second gamma transformation parameter; when the first gamma transformation parameter is greater than or equal to 1, adding the preset value to the first gamma transformation parameter to obtain the second gamma transformation parameter.
[0007] According to an embodiment of the present disclosure, the above-mentioned linear transformation of the above-mentioned original grayscale image to obtain an initial grayscale image includes: obtaining the grayscale value range of the above-mentioned original grayscale image; calculating the average grayscale value of the above-mentioned original grayscale image; multiplying the grayscale value range of the above-mentioned original grayscale image and the average grayscale value of the above-mentioned original grayscale image by preset linear transformation parameters respectively to obtain the grayscale value range of the above-mentioned initial grayscale image and the average grayscale value of the above-mentioned initial grayscale image.
[0008] According to an embodiment of the present disclosure, the above-mentioned calculation of the gamma transformation parameter for the above-mentioned initial grayscale image to obtain a first gamma transformation parameter includes: calculating the average grayscale value of the above-mentioned initial grayscale image; calculating the above-mentioned first gamma transformation parameter based on the average grayscale value of the above-mentioned initial grayscale image.
[0009] According to an embodiment of the present disclosure, the above-mentioned non-linear transformation of the above-mentioned initial grayscale image based on the gamma transformation parameter of each image block to obtain a target grayscale image includes: performing normalization processing on the above-mentioned initial grayscale image to obtain a normalized grayscale image; performing non-linear transformation on the above-mentioned normalized grayscale image based on the gamma transformation parameter of each image block to obtain a non-linearly transformed normalized grayscale image; performing inverse normalization processing on the above-mentioned non-linearly transformed normalized grayscale image to obtain the above-mentioned target grayscale image.
[0010] According to an embodiment of the present disclosure, the above-mentioned non-linear transformation of the above-mentioned normalized grayscale image based on the gamma transformation parameter of each image block to obtain a non-linearly transformed normalized grayscale image includes: performing equal-region division on the above-mentioned normalized grayscale image according to the size information of the above-mentioned normalized grayscale image to obtain a plurality of normalized image blocks; performing non-linear transformation on each normalized image block based on the gamma transformation parameter of each image block to obtain a plurality of non-linearly transformed normalized image blocks; splicing the above-mentioned plurality of non-linearly transformed normalized image blocks to obtain the above-mentioned non-linearly transformed normalized grayscale image.
[0011] The second aspect of the present disclosure provides an image processing apparatus, which includes: a linear transformation module for performing a linear transformation on the original grayscale image to obtain an initial grayscale image; a calculation module for calculating gamma transformation parameters for the initial grayscale image to obtain a first gamma transformation parameter; a region division module for equally dividing the initial grayscale image according to the size information of the initial grayscale image to obtain a plurality of image blocks; a first determination module for, for each image block, determining the first gamma transformation parameter as the gamma transformation parameter of the image block when the contrast of the image block is greater than or equal to a threshold; a second determination module for, for each image block, when the contrast of the image block is less than the threshold, adjusting the gamma transformation parameter of the image block based on the first gamma transformation parameter to obtain a second gamma transformation parameter; and determining the second gamma transformation parameter as the gamma transformation parameter of the image block; and a non-linear transformation module for performing a non-linear transformation on the initial grayscale image based on the respective gamma transformation parameters of each image block to obtain a target grayscale image, so as to adjust the brightness of the original grayscale image.
[0012] The third aspect of the present disclosure provides an electronic device, including: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0013] The fourth aspect of the present disclosure further provides a computer-readable storage medium, on which a computer program or instruction is stored, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.
[0014] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instruction, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.
[0015] According to the embodiments of the present disclosure, through linear transformation, the over-bright or over-dark situation of the original grayscale image can be stretched to the expected brightness range; through the fine gamma transformation of the image blocks, the contrast and details of the image can be enhanced, so that the target grayscale image can present richer detail information; through the dual correction mechanism, the adaptability of image brightness adjustment is ensured, and the visual effect is effectively improved. The image processing method of the embodiments of the present disclosure can directly adjust the brightness of a single-frame image without relying on the acquisition of multiple frames of images, and has higher flexibility and real-time performance; it can directly process the current frame, thereby effectively reducing memory occupancy and improving image processing efficiency; it can automatically extract the contrast information of the image for brightness adjustment, avoiding the cumbersome process of threshold selection and improving the image processing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, the above content and other objects, features, and advantages of the present disclosure will become clearer. In the drawings:
[0017] Figure 1 A schematic diagram of an application scenario of an image processing method according to an embodiment of the present disclosure is shown;
[0018] Figure 2 A flowchart of an image processing method according to an embodiment of the present disclosure is schematically shown;
[0019] Figure 3 A block diagram of the structure of an image processing apparatus according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 4 A schematic diagram of an image acquisition device of an image processing apparatus according to an embodiment of the present disclosure is shown; and
[0021] Figure 5 A block diagram of an electronic device suitable for implementing the image processing method according to an embodiment of the present disclosure is schematically shown. Detailed Embodiments
[0022] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the following detailed description, for the sake of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, obviously, one or more embodiments can also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present disclosure.
[0023] The terms used herein are merely for describing specific embodiments and are not intended to limit the present disclosure. The terms "including", "comprising", etc. used herein indicate the presence of the described features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0024] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0025] In the case of using expressions such as "at least one of A, B, and C", generally, it should be interpreted according to the meaning that those skilled in the art usually understand this expression (for example, "a system having at least one of A, B, and C" should include but not be limited to a system having only A, only B, only C, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).
[0026] High-density imaging devices, such as vertically charge transferring pixel sensors (VPS), have the characteristics of small pixel size and high integration, and can achieve high-resolution imaging. Therefore, they show broad application prospects in the fields of remote sensing, surveillance, etc. Currently, large-area optoelectronic sensors are developing rapidly, and their prospects have been widely recognized by industry enterprises and scientific research institutions.
[0027] During the image acquisition process, due to differences in the use environment, such as insufficient light or too short exposure time, the overall brightness of the image is low and the brightness distribution is uneven. In addition, the photosensitive area of a single pixel of the vertically charge transferring imaging device is small, and the ability to store optical charges is limited, resulting in a limited dynamic range and too low sensitivity under low illumination. These problems further exacerbate the insufficient image brightness and detail loss, seriously affecting the recognition and use effects of the image. Therefore, during the image acquisition process, achieving adaptive brightness adjustment is crucial for quickly processing images and obtaining high-quality imaging effects.
[0028] Currently, in order to enhance image contrast and details, and to achieve automatic brightness adjustment of ultra-high-resolution images and accelerate image output, there are mainly two technologies: one is to enhance image brightness through multi-frame comparison; the other is to adjust image brightness through multi-threshold comparison.
[0029] The process of the brightness adjustment algorithm based on multi-frame image comparison in the related technology is as follows.
[0030] Obtain the current frame brightness of the target image and the target brightness to be achieved; calculate the positive brightness offset parameter or negative brightness offset parameter, and calculate the correction value; calculate the next frame control parameter according to the correction value and the current frame control parameter; decompose the next frame control parameter to form the next frame exposure time, light source brightness, and exposure gain; perform the next frame image acquisition control according to the next frame exposure time, brightness, and exposure gain. This algorithm calculates by converting the parameters involved in image brightness control to the logarithmic domain. At the same time, when the brightness converges from the positive and negative directions, different logarithmic differences are used as brightness control, effectively improving the smoothness during image brightness adjustment. Thus, the multi-frame image comparison algorithm can be specifically expressed as the following process.
[0031] The brightness of the current frame is less than the target brightness, and the positive brightness offset parameter is calculated by the following formula (1):
[0032] (1);
[0033] Wherein, is the positive brightness offset parameter, is the target brightness, is the brightness of the current frame image. The positive brightness offset parameter is greater than the positive control threshold, and the correction value is calculated according to the positive brightness offset parameter.
[0034] When the brightness of the current frame is greater than the target brightness, the negative brightness offset parameter is calculated by the following formula (2):
[0035] (2);
[0036] Wherein, is the negative brightness offset parameter, is the maximum brightness of the target image. The negative brightness offset parameter is greater than the negative control threshold, and the correction value is calculated according to the negative brightness offset parameter; the next frame control parameter is calculated according to the correction value and the current frame control parameter; the next frame control parameter forms the exposure time, light source brightness and exposure gain of the next frame; the next frame image acquisition control is performed according to the exposure time, light source brightness and exposure gain of the next frame.
[0037] The next frame control parameter is calculated according to the correction value and the current frame control parameter:
[0038] (3);
[0039] Wherein, is the current frame control parameter, is the current exposure time, is the current light source brightness, and Gain is the exposure gain.
[0040] The brightness adjustment algorithm based on multiple thresholds in the related art is as follows.
[0041] By statistically calculating the gray value of each pixel point in the image to be processed, the maximum gray value and the average gray value are calculated. Then, based on the brightness difference between the maximum gray value and the average gray value, target gray mapping parameters including a dark area coefficient, a bright area coefficient, and a basic brightness threshold are obtained. Finally, the target gray mapping parameters, the average gray value, and the maximum gray value are used to adjust the brightness of the image to be processed. Among them, the dark area coefficient can perform gray mapping on the dark area in the image to be processed, and the bright area coefficient can perform gray mapping on the bright area in the image to be processed. Thus, the multi-frame image comparison algorithm can be specifically expressed as the following process.
[0042] First, map each pixel point of the image to be processed:
[0043] (4);
[0044] Among them, represents the gray value of the target pixel point, represents the mapping result of the gray value of the target pixel point, represents the dark area coefficient, represents the maximum gray value, represents the average gray value, and the target pixel point is any pixel point in the image to be processed.
[0045] Map the average gray value:
[0046] (5);
[0047] Among them, represents the mapping result of the average gray value, represents the dark area coefficient, represents the bright area coefficient, represents the basic brightness threshold, The value range of is [1,
[0048] Adjust the brightness of each pixel point in the image to be processed:
[0049] (6);
[0050] Among them, represents the brightness adjustment result of the target pixel point, represents the mapping result of the gray value of the target pixel point, represents the mapping result of the average gray value, represents the maximum gray value.
[0051] Obtain the target brightness scene according to the brightness difference, the maximum gray value, and the preset scene brightness threshold. The target brightness scene is the brightness scene to which the image to be processed currently belongs; the brightness scene is a weak exposure scene, a strong exposure scene, a normal scene, or an under-exposure scene; obtain the target gray mapping parameter according to the target brightness scene.
[0052] If the brightness difference is less than the first brightness threshold and the maximum gray value is not greater than the third brightness threshold, then obtain the target brightness scene as the weak exposure scene.
[0053] If the brightness difference is less than the first brightness threshold and the maximum gray value is greater than the third brightness threshold, then obtain the target brightness scene as the strong exposure scene.
[0054] If the brightness difference is not less than the first brightness threshold and not greater than the second brightness threshold, then the target brightness scene is obtained as a normal scene.
[0055] If the brightness difference is greater than the second brightness threshold, then the target brightness scene is obtained as an underexposed scene.
[0056] The magnitudes of the first dark region coefficient, the second dark region coefficient, the third dark region coefficient, and the fourth dark region coefficient decrease in sequence, and their value ranges are all [1, 3].
[0057] The magnitudes of the first bright region coefficient, the second bright region coefficient, the third bright region coefficient, and the fourth bright region coefficient increase in sequence, and their value ranges are all (0, 2].
[0058] Limited by its own imaging mechanism, the ultra-high-resolution image preprocessing technology in related technologies has the following deficiencies: When the preprocessing technology processes ultra-high-resolution images, due to the large amount of image data, a large amount of computing resources and memory space are required when selecting multiple comparison thresholds for processing, and the computing cost is extremely high; the preprocessing technology needs to use multiple frames of images for comparison and cannot achieve the brightness adjustment of a single frame of image.
[0059] To achieve the design purpose of adaptive brightness adjustment of an ultra-high-resolution image acquisition system, the present disclosure proposes a two-stage fast image brightness adjustment algorithm.
[0060] Figure 1 Schematically shows an application scenario diagram of an image processing method according to an embodiment of the present disclosure.
[0061] As Figure 1 shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0062] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0063] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0064] The server 105 may be a server that provides various services, such as a background management server (only for example) that supports the websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process data such as user requests received, and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0065] It should be noted that the image processing method provided by the embodiments of the present disclosure can generally be executed by the server 105. Correspondingly, the image processing device provided by the embodiments of the present disclosure can generally be set in the server 105. The image processing method provided by the embodiments of the present disclosure can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Correspondingly, the image processing device provided by the embodiments of the present disclosure can also be set in a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105.
[0066] It should be understood that Figure 1 the numbers of terminal devices, networks, and servers in
[0067] Figure 2 are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers.
[0067] Figure 2 Schematically shows a flowchart of an image processing method according to an embodiment of the present disclosure.
[0068] As Figure 2 shown, the image processing method of this embodiment includes operation S210 to operation S260.
[0069] In operation S210, a linear transformation is performed on the original grayscale image to obtain an initial grayscale image.
[0070] In image processing, grayscale and brightness are closely related but different concepts. Grayscale can represent the light and dark degree of pixels in an image, and the grayscale value reflects the light intensity of each pixel in the image. Brightness is the subjective perception of the intensity of light by the human eye, and the perception of brightness is non-linear. The relationship between brightness and grayscale value can be described by gamma correction. Before gamma correction, it can be considered that the relationship between grayscale value and brightness is linear.
[0071] According to an embodiment of the present disclosure, through linear transformation, such as linear stretching, the bright part of the original grayscale image can be made brighter and the dark part can be made darker, thereby improving the contrast and visual effect of the image.
[0072] In operation S220, the gamma transformation parameter of the initial grayscale image is calculated to obtain the first gamma transformation parameter.
[0073] In operation S230, according to the size information of the initial grayscale image, the initial grayscale image is divided into equal regions to obtain a plurality of image blocks.
[0074] In operation S240, for each image block, when the contrast of the image block is greater than or equal to the threshold, the first gamma transformation parameter is determined as the gamma transformation parameter of the image block.
[0075] In operation S250, for each image block, when the contrast of the image block is less than the threshold, based on the first gamma transformation parameter, the gamma transformation parameter of the image block is adjusted to obtain the second gamma transformation parameter; the second gamma transformation parameter is determined as the gamma transformation parameter of the image block.
[0076] According to an embodiment of the present disclosure, by finely adjusting the gamma transformation parameter of each image block, the brightness and contrast of the image can be changed. The adjustment of the gamma transformation parameter for non-linear gamma correction can make the detail contrast of the image stronger. For the brightness states of different image blocks, the gamma transformation parameters suitable for different contrasts of the image blocks are automatically adjusted.
[0077] In operation S260, based on the respective gamma transformation parameters of each image block, a non-linear transformation is performed on the initial grayscale image to obtain a target grayscale image to adjust the brightness of the original grayscale image.
[0078] According to an embodiment of the present disclosure, based on the first gamma transformation parameter, automatic adjustment can be made to make the detail contrast of the target grayscale image higher.
[0079] According to an embodiment of the present disclosure, the over-bright or over-dark situation of the original grayscale image can be stretched to the expected brightness range by linear transformation for the ultra-high resolution image; the contrast and details of the image can be enhanced by gamma transformation, so that the target grayscale image can present richer detail information; the adaptability of image brightness adjustment is ensured through a dual correction mechanism, effectively improving the visual effect. The image processing method of the embodiment of the present disclosure can directly adjust the brightness of a single-frame image without relying on the acquisition of multiple-frame images, having higher flexibility and real-time performance; it can directly process the current frame, thereby effectively reducing memory occupancy and improving image processing efficiency; it can automatically extract the contrast information of the image for brightness adjustment, avoiding the cumbersome process of threshold selection and improving the image processing speed.
[0080] According to an embodiment of the present disclosure, a linear transformation is performed on an original grayscale image to obtain an initial grayscale image, including: obtaining the grayscale value range of the original grayscale image; calculating the average grayscale value of the original grayscale image; multiplying the grayscale value range of the original grayscale image and the average grayscale value of the original grayscale image by preset linear transformation parameters respectively to obtain the grayscale value range of the initial grayscale image and the average grayscale value of the initial grayscale image.
[0081] Obtain the grayscale values of all pixels in the original grayscale image , the grayscale value range of the original grayscale image , the average grayscale value of the original grayscale image . The grayscale values of all pixels in the initial grayscale image are represented by , the grayscale value range of the initial grayscale image is represented by , and the average grayscale value of the initial grayscale image is represented by . The grayscale values of all pixels in the target grayscale image are represented by , the grayscale value range of the target grayscale image is represented by , and the average grayscale value of the target grayscale image is represented by . The grayscale value range is the maximum grayscale value and the minimum grayscale value of the pixels in the grayscale image. The average grayscale value is the average value of all pixels.
[0082] For the adaptive brightness adjustment of ultra-high resolution images, first map the data values of the original grayscale image to the pixel range of the target grayscale image. For the grayscale value range of the original grayscale image, perform a linear mapping on the grayscale value of each pixel point:
[0083] (7);
[0084] (8);
[0085] Wherein, is the linear mapping multiple.
[0086] According to an embodiment of the present disclosure, calculate the average grayscale value of the initial grayscale image:
[0087] (9).
[0088] According to an embodiment of the present disclosure, calculate the first gamma transformation parameter based on the average grayscale value of the initial grayscale image.
[0089] The derivation of the adaptive gamma transformation mapping formula is as follows.
[0090] The expression of gamma transformation can be expressed as:
[0091] (10);
[0092] Among them, is the gray value to be pre - gamma - transformed, is the gamma - transformation parameter, representing the transformation coefficient of the gamma - transformation mapping formula, is the target gray value after gamma - transforming the gray value to be pre - gamma - transformed. Substituting the average gray value of the initial gray - level image after linear mapping into formula (10), the average gray value after gamma - transformation without adjustment can be obtained.
[0093] (11);
[0094] Among them, is the average gray value after gamma - transformation without adjustment.
[0095] Taking the logarithm of both sides of formula (11), we get the expression of the
[0096] value:
[0097] Continuing to derive formula (12), we get:
[0098] (13).
[0099] In formulas (10), (11), (12) and (13), i.e., the gamma - transformation parameter, among which, is the value after gamma - transformation, is any value between [0, 1]. The smaller the value, the darker the image display effect; the larger the value, the brighter the image display. Considering various factors, when is selected as 0.5, the gray value of the image is moderate and the detail contrast is relatively obvious. At this time, is transformed into the constant - 0.3, and formula (13) can be simplified and optimized. According to formula (13), the first gamma - transformation parameter can be obtained:
[0100] (14).
[0101] Regarding the characteristic of a large number of pixels in the ultra - high - resolution image, using a single value can only partially improve the contrast of the picture. By performing region segmentation on the initial gray - level image, multiple image blocks are obtained, and for the regions with too low contrast in the initial gray - level image, local adjustment values are used to enhance the contrast of them specifically.
[0102] For the problem of too low local contrast, first calculate the local contrast for each divided image block:
[0103] (15);
[0104] Among them, represents the standard deviation of the image block, represents the average gray value of the image block, represents the gray value of the image block, represents the total number of pixels of the image block. When the standard deviation of the image block is small, it indicates that the contrast of the image block is too low, and the contrast needs to be improved by adjusting the gamma transformation parameter.
[0105] According to an embodiment of the present disclosure, for each image block, when the contrast of the image block is greater than or equal to the threshold, determine the first gamma transformation parameter as the gamma transformation parameter of the image block .
[0106] According to an embodiment of the present disclosure, for each image block, in the case where the contrast of the image block is less than the threshold, based on the first gamma transformation parameter , adjust the gamma transformation parameter of the image block to obtain the second gamma transformation parameter , including: when the first gamma transformation parameter is less than 1, subtract the preset value from the first gamma transformation parameter to obtain the second gamma transformation parameter ; when the first gamma transformation parameter is greater than or equal to 1, add the preset value to the first gamma transformation parameter to obtain the second gamma transformation parameter .
[0107] In an example, for each image block, when the contrast of the image block is small, for example, in the case of, adjust the gamma transformation parameter of the image block to obtain the second gamma transformation parameter:
[0108] (16);
[0109] Among them, represents the preset value, which is a preset parameter value. When , the value of should be further reduced to enhance the contrast of the image. When , it is necessary to increase value, thereby enhancing the contrast of the image. Determine the second gamma transformation parameter for the image block as the gamma transformation parameter of the image block
[0110] According to an embodiment of the present disclosure, based on the respective gamma transformation parameters of each image block, a non-linear transformation is performed on the initial grayscale image to obtain a target grayscale image, including: performing a normalization process on the initial grayscale image to obtain a normalized grayscale image; based on the respective gamma transformation parameters of each image block, performing a non-linear transformation on the normalized grayscale image to obtain a non-linearly transformed normalized grayscale image; and performing an inverse normalization process on the non-linearly transformed normalized grayscale image to obtain the target grayscale image
[0111] Perform a normalization process on the grayscale values of the initial grayscale image and further optimize the contrast effect of the image through non-linear transformation
[0112] (17);
[0113] wherein represents the grayscale value of the normalized grayscale image
[0114] According to an embodiment of the present disclosure, according to the size information of the normalized grayscale image, the normalized grayscale image is equally divided into regions to obtain a plurality of normalized image blocks; based on the respective gamma transformation parameters of each image block, a non-linear transformation is performed on each normalized image block to obtain a plurality of non-linearly transformed normalized image blocks; and the plurality of non-linearly transformed normalized image blocks are stitched together to obtain the non-linearly transformed normalized grayscale image
[0115] For each normalized image block, when the contrast of the normalized image block is greater than or equal to the threshold, the grayscale value of the non-linearly transformed normalized image block can be expressed as:
[0116] (18).
[0117] For each normalized image block, when the contrast of the normalized image block is less than the threshold, the grayscale value of the non-linearly transformed normalized image block can be expressed as:
[0118] (19).
[0119] Based on the respective gamma transformation parameters of each image block, perform a non-linear transformation on the gray values of the normalized gray image to obtain a normalized gray image after non-linear transformation, and then perform an inverse normalization process to obtain a target gray image. The gray value of the target gray image can be expressed as:
[0120] (20).
[0121] Based on the above image processing method, the present disclosure also provides an image processing apparatus. The following will be combined with Figure 3 to describe the apparatus in detail.
[0122] Figure 3 The structural block diagram of the image processing apparatus according to an embodiment of the present disclosure is schematically shown.
[0123] As Figure 3 shown, the image processing apparatus 300 of this embodiment includes a linear transformation module 310, a calculation module 320, a region division module 330, a first determination module 340, a second determination module 350, and a non-linear transformation module 360.
[0124] The linear transformation module 310 is configured to perform a linear transformation on the original gray image to obtain an initial gray image.
[0125] The calculation module 320 is configured to calculate gamma transformation parameters for the initial gray image to obtain a first gamma transformation parameter.
[0126] The region division module 330 is configured to equally divide the initial gray image according to the size information of the initial gray image to obtain a plurality of image blocks.
[0127] The first determination module 340 is configured to, for each image block, when the contrast of the image block is greater than or equal to a threshold, determine the first gamma transformation parameter as the gamma transformation parameter of the image block.
[0128] The second determination module 350 is configured to, for each image block, when the contrast of the image block is less than the threshold, adjust the gamma transformation parameter of the image block based on the first gamma transformation parameter to obtain a second gamma transformation parameter; and determine the second gamma transformation parameter as the gamma transformation parameter of the image block.
[0129] The non-linear transformation module 360 is configured to perform a non-linear transformation on the initial gray image based on the respective gamma transformation parameters of each image block to obtain a target gray image, so as to adjust the brightness of the original gray image.
[0130] According to an embodiment of the present disclosure, the second determination module 350 includes a first judgment sub-module and a second judgment sub-module.
[0131] The first judgment sub-module is configured to subtract a preset value from the first gamma transformation parameter to obtain a second gamma transformation parameter when the first gamma transformation parameter is less than 1.
[0132] The second judgment sub-module is configured to add a preset value to the first gamma transformation parameter to obtain a second gamma transformation parameter when the first gamma transformation parameter is greater than or equal to 1.
[0133] According to an embodiment of the present disclosure, the linear transformation module 310 includes an acquisition sub-module, a first calculation sub-module, and a first obtaining sub-module.
[0134] The acquisition sub-module is configured to acquire the gray value range of the original gray image.
[0135] The first calculation sub-module is configured to calculate the average gray value of the original gray image.
[0136] The first obtaining sub-module is configured to multiply the gray value range of the original gray image and the average gray value of the original gray image by preset linear transformation parameters respectively to obtain the gray value range of the initial gray image and the average gray value of the initial gray image.
[0137] According to an embodiment of the present disclosure, the calculation module 320 includes a second calculation sub-module and a third calculation sub-module.
[0138] The second calculation sub-module is configured to calculate the average gray value of the initial gray image.
[0139] The third calculation sub-module is configured to calculate the first gamma transformation parameter based on the average gray value of the initial gray image.
[0140] According to an embodiment of the present disclosure, the non-linear transformation module 360 includes a second obtaining sub-module, a third obtaining sub-module, and a fourth obtaining sub-module.
[0141] The second obtaining sub-module is configured to perform normalization processing on the initial gray image to obtain a normalized gray image.
[0142] The third obtaining sub-module is configured to perform non-linear transformation on the normalized gray image based on the gamma transformation parameter of each image block to obtain a non-linearly transformed normalized gray image.
[0143] The fourth obtaining sub-module is configured to perform inverse normalization processing on the non-linearly transformed normalized gray image to obtain a target gray image.
[0144] According to an embodiment of the present disclosure, the third obtaining sub-module includes a first obtaining unit, a second obtaining unit, and a third obtaining unit.
[0145] The first obtaining unit is configured to perform equal-region division on the normalized grayscale image according to the size information of the normalized grayscale image, so as to obtain a plurality of normalized image blocks.
[0146] The second obtaining unit is configured to perform non-linear transformation on each normalized image block based on the respective gamma transformation parameter of each image block, so as to obtain a plurality of normalized image blocks after non-linear transformation.
[0147] The third obtaining unit is configured to splice the plurality of normalized image blocks after non-linear transformation, so as to obtain a normalized grayscale image after non-linear transformation.
[0148] According to an embodiment of the present disclosure, any plurality of modules among the linear transformation module 310, the calculation module 320, the region division module 330, the first determination module 340, the second determination module 350, and the non-linear transformation module 360 may be combined and implemented in one module, or any one of them may be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules may be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the linear transformation module 310, the calculation module 320, the region division module 330, the first determination module 340, the second determination module 350, and the non-linear transformation module 360 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or may be implemented by any other reasonable way of integrating or packaging circuits and other hardware or firmware, or may be implemented in any one of the three implementation manners of software, hardware, and firmware or in an appropriate combination of any several of them. Alternatively, at least one of the linear transformation module 310, the calculation module 320, the region division module 330, the first determination module 340, the second determination module 350, and the non-linear transformation module 360 may be at least partially implemented as a computer program module, and when the computer program module runs, it may execute the corresponding functions.
[0149] Figure 4 Schematically shown is a schematic diagram of an image acquisition device of an image processing device according to an embodiment of the present disclosure.
[0150] As Figure 4 shown, the image acquisition device includes an ultra-high resolution optoelectronic sensor, an FPGA module, and a host computer.
[0151] In one example, the host computer includes a display device that communicates with the FPGA module through serial control and sends an image acquisition signal. The FPGA module controls the ultra-high-resolution optoelectronic sensor to acquire ultra-high-resolution images. The ultra-high-resolution optoelectronic sensor transmits the image data to the FPGA module through multiple pairs of MIPI image transmission lines. The image processing module of the FPGA module performs image processing on the received image data using the image processing method of the present disclosure embodiment, thereby realizing the optimization of image brightness and contrast.
[0152] In one example, the application of the image processing method of the image processing module of the FPGA module includes image gray-scale acquisition, DDR image caching, determination of image linear parameters, determination of image non-linear parameters, image linear mapping, and image non-linear mapping.
[0153] Gray-scale range acquisition module: used to obtain the maximum gray-scale value and the minimum gray-scale value of the original gray-scale image.
[0154] Gray-scale average value acquisition module: used to obtain the gray-scale average value of the original gray-scale image.
[0155] Image mapping parameter acquisition module: according to the gray-scale value range of the target gray-scale image, obtain the target linear mapping parameter, that is, the linear transformation parameter, and at the same time, according to the average gray-scale value of the initial gray-scale image, obtain the target non-linear mapping parameter, that is, the gamma transformation parameter.
[0156] Image block parallel processing module: used to perform block processing on the image, and for the parts with lower contrast in different image blocks, select more appropriate gamma transformation parameters for adjustment, thereby effectively improving the local contrast of the image.
[0157] Image brightness adjustment module: used to obtain the target linear mapping parameter of the target gray-scale image and the target non-linear mapping parameter of the target gray-scale image, and perform gray-scale adjustment on the bright area of the initial gray-scale image.
[0158] The processed image is output to the host computer through a gigabit network interface, and an image with a suitable brightness range is displayed through the host computer.
[0159] Compared with the multi-frame adjustment methods in the related art that can usually only perform brightness adjustment on the second frame and subsequent images, the image processing method of the present disclosure embodiments has the characteristic of strong applicability. The image processing method of the present disclosure embodiments can directly perform brightness adjustment on a single-frame image without relying on the acquisition of multi-frame images. When the scene changes, it can directly perform brightness adjustment on the current frame, with higher flexibility and real-time performance. Compared with the multi-frame brightness adjustment methods in the related art that usually rely on saving the parameters and detail information of the previous frame image to achieve the brightness adjustment of subsequent frames, the image processing method of the present disclosure embodiments has the characteristic of less memory occupation. The image processing method of the present disclosure embodiments can directly process the current frame without relying on the previous frame data, thereby effectively reducing the memory occupation and improving the processing efficiency. Compared with the multi-threshold image adjustment methods in the related art that require manually selecting and comparing multiple thresholds, resulting in a slower processing speed, the image processing method of the present disclosure embodiments has the characteristic of fast processing speed. The image processing method of the present disclosure embodiments can automatically extract the brightness information of the image and directly perform brightness adjustment based on this information, avoiding the cumbersome process of threshold selection, thereby significantly improving the processing speed.
[0160] Figure 5 FIG. schematically shows a block diagram of an electronic device suitable for implementing the image processing method according to an embodiment of the present disclosure.
[0161] As Figure 5 shown, the electronic device 500 according to an embodiment of the present disclosure includes a processor 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage section 508 into the random access memory (RAM) 503. The processor 501 can include, for example, a general microprocessor (such as a CPU), an instruction set processor, and / or a related chipset, and / or a dedicated microprocessor (such as an application specific integrated circuit (ASIC)), etc. The processor 501 can also include on-board memory for caching purposes. The processor 501 can include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiments of the present disclosure.
[0162] In the RAM 503, various programs and data required for the operation of the electronic device 500 are stored. The processor 501, ROM 502, and RAM 503 are connected to each other through a bus 504. The processor 501 performs various operations of the method flow according to the embodiments of the present disclosure by executing the programs in the ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than the ROM 502 and RAM 503. The processor 501 can also perform various operations of the method flow according to the embodiments of the present disclosure by executing the programs stored in the one or more memories.
[0163] According to an embodiment of the present disclosure, the electronic device 500 may further include an input / output (I / O) interface 505, and the input / output (I / O) interface 505 is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. The drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage portion 508 as needed.
[0164] The present disclosure also provides a computer-readable storage medium, which may be included in the device / device / system described in the above embodiments; or may exist separately without being assembled into the device / device / system. The above computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of the present disclosure is implemented.
[0165] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the above-described ROM 502 and / or RAM 503 and / or one or more memories other than ROM 502 and RAM 503.
[0166] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program includes program codes for executing the method shown in the flowchart. When the computer program product runs on a computer system, the program codes are used to cause the computer system to implement the image processing method provided by the embodiments of the present disclosure.
[0167] When the computer program is executed by the processor 501, the above functions defined in the system / apparatus of the embodiments of the present disclosure are executed. According to an embodiment of the present disclosure, the above-described system, apparatus, module, unit, etc. can be implemented by computer program modules.
[0168] In one embodiment, the computer program can rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program can also be transmitted and distributed in the form of signals on a network medium, and be downloaded and installed through the communication part 509, and / or be installed from the removable medium 511. The program code included in the computer program can be transmitted by any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0169] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or be installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system of the embodiments of the present disclosure are executed. According to an embodiment of the present disclosure, the above-described system, device, apparatus, module, unit, etc. can be implemented by computer program modules.
[0170] According to an embodiment of the present disclosure, the program code for executing the computer program provided in the embodiments of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include but are not limited to, such as Java, C++, python, the "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, by using an Internet service provider to connect through the Internet).
[0171] 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 disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur in an order different from that noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0172] Those skilled in the art will appreciate that the features described in the various embodiments of the present disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure can be combined and / or combined in various ways. All such combinations and / or combinations fall within the scope of the present disclosure.
[0173] The embodiments of the present disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments have been described separately above, this does not mean that the measures in the respective embodiments cannot be used advantageously in combination. Without departing from the scope of the present disclosure, those skilled in the art can make various substitutions and modifications, and all such substitutions and modifications should fall within the scope of the present disclosure.
Claims
1. An image processing method, characterized in that: The method comprises: Performing a linear transformation on the original grayscale image to obtain an initial grayscale image; Calculating gamma transformation parameters for the initial grayscale image to obtain first gamma transformation parameters; According to the size information of the initial grayscale image, the initial grayscale image is divided into equal areas to obtain a plurality of image blocks; For each image block, When the contrast of the image block is greater than or equal to a threshold, determining the first gamma transform parameter as the gamma transform parameter of the image block; When the contrast of the image block is less than the threshold, adjusting the gamma transform parameter of the image block based on the first gamma transform parameter to obtain a second gamma transform parameter; Determining the second gamma transform parameter as a gamma transform parameter of the image block; Based on the gamma transformation parameters of each image block, the initial grayscale image is nonlinearly transformed to obtain a target grayscale image, so as to adjust the brightness of the original grayscale image.
2. The method according to claim 1, characterized in that When the contrast of the image block is less than the threshold, adjusting the gamma transform parameter of the image block based on the first gamma transform parameter to obtain a second gamma transform parameter includes: When the first gamma transform parameter is less than 1, subtract a preset value from the first gamma transform parameter to obtain the second gamma transform parameter; When the first gamma transform parameter is greater than or equal to 1, the first gamma transform parameter is added to the preset value to obtain the second gamma transform parameter.
3. The method according to claim 1, characterized in that The linear transformation of the original grayscale image to obtain an initial grayscale image includes: Obtaining a grayscale value range of the original grayscale image; Calculating the average grayscale value of the original grayscale image; The grayscale value range of the original grayscale image and the average grayscale value of the original grayscale image are respectively multiplied by a preset linear transformation parameter to obtain the grayscale value range of the initial grayscale image and the average grayscale value of the initial grayscale image.
4. The method according to claim 3, characterized in that The calculating of the gamma transformation parameters of the initial grayscale image to obtain the first gamma transformation parameters includes: Calculating the average grayscale value of the initial grayscale image; The first gamma transformation parameter is calculated based on the average grayscale value of the initial grayscale image.
5. The method according to claim 1, characterized in that The step of performing a nonlinear transformation on the initial grayscale image based on the respective gamma transformation parameters of each image block to obtain a target grayscale image comprises: Normalizing the initial grayscale image to obtain a normalized grayscale image; Based on the gamma transformation parameters of each image block, the normalized grayscale image is subjected to nonlinear transformation to obtain a normalized grayscale image after nonlinear transformation; The normalized grayscale image after the nonlinear transformation is subjected to denormalization processing to obtain the target grayscale image.
6. The method according to claim 5, characterized in that The step of performing a nonlinear transformation on the normalized grayscale image based on the gamma transformation parameters of each image block to obtain a normalized grayscale image after the nonlinear transformation comprises: According to the size information of the normalized grayscale image, the normalized grayscale image is divided into equal areas to obtain a plurality of normalized image blocks; Based on the gamma transformation parameters of each image block, each normalized image block is subjected to nonlinear transformation to obtain a plurality of normalized image blocks after nonlinear transformation; The plurality of normalized image blocks after the nonlinear transformation are spliced to obtain a normalized grayscale image after the nonlinear transformation.
7. An image processing device, characterized in that: The device comprises: A linear transformation module, used for performing a linear transformation on the original grayscale image to obtain an initial grayscale image; A calculation module, used for calculating gamma transformation parameters of the initial grayscale image to obtain first gamma transformation parameters; A region division module, used for performing equal region division on the initial grayscale image according to size information of the initial grayscale image to obtain a plurality of image blocks; A first determining module, configured to determine, for each image block, when a contrast of the image block is greater than or equal to a threshold, the first gamma transform parameter as the gamma transform parameter of the image block; a second determination module, configured to, for each image block, adjust the gamma transform parameter of the image block based on the first gamma transform parameter to obtain a second gamma transform parameter when the contrast of the image block is less than the threshold; and determine the second gamma transform parameter as the gamma transform parameter of the image block; and The nonlinear transformation module is used to perform a nonlinear transformation on the initial grayscale image based on the gamma transformation parameters of each image block to obtain a target grayscale image so as to adjust the brightness of the original grayscale image.
8. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Method and system for detecting corrosion of train body equipment compartment of motor train unit based on deep learning
CN120807513A