Image processing method and device, endoscope, equipment and storage medium

CN119784659BActive Publication Date: 2026-08-11ZHUHAI SHIXIN MEDICAL TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0002]在低照度环境下,图像采集设备采集到的图像会存在较高的噪声、纹理信息模糊、对比度低和色彩还原有误等质量问题,从而影响图像后续处理质量

Benefits of technology

通过基于原始RGB图像的HSV图像,获得亮度图像,接着基于亮度图像来获得二值图像和亮度增强图像,然后根据二值图像来实现对亮度增强图像中暗区与亮区之间的边界线上的边界像素点的获取,可以提高暗区和亮区的边界识别精度,由于其中只需基于二值图像就可以实现边界像素点的定位,因此还可以减少数据处理量。接着,通过基于边界像素点来获得相应的待修正点集,而待修正点集包括边界像素点、以及分别位于边界像素点的暗区侧和亮区侧的像素点,且这些像素点都彼此相邻并处于同一直线上,可见待修正点集中的所有像素点,是最能代表暗区和亮区之间的亮度差异性的点。由此,继续基于待修正点集中所有像素点的亮度值,来对待修正点集中像素点的亮度值进行更新,以使亮度修正后的像素点的亮度具备更高的均匀性,进而得到相应的目标点集,可见最能代表暗区和亮区之间的亮度差异性的点的亮度已被平滑处理,不仅可以实现暗区和亮区之间的亮度能够平滑过渡,而且还可以实现暗区亮度的提升,使得基于目标点集进行V通道数据更新后的目标HSV图像也具备同样的技术效果,进而使得基于目标HSV图像转换得到的目标RGB图像中,不仅暗区具备良好的亮度提升效果,而且整体图像具备良好的图像色彩还原效果,图像质量得到有效的提升。此外,由于其中仅需根据HSV图像中V通道数据(即亮度图像)进行处理,无需对H通道和S通道的图像数据进行处理,且在图像处理未涉及处理量大的运算过程,因此本发明实施例提供的上述任一方案,还具备图像处理效率高,图像序列的播放速度达到视频播放要求(30帧/s,每帧图像处理耗时33ms以内),不会出现卡顿,以及临床使用效果佳等有益技术效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784659B_ABST
    Figure CN119784659B_ABST
Patent Text Reader

Abstract

This invention provides an image processing method, apparatus, endoscope, device, and storage medium. The method includes: obtaining a luminance image from an HSV image of an original RGB image; obtaining a binary image and a luminance-enhanced image from the luminance image; obtaining boundary pixels at the boundaries of bright and dark areas in the luminance-enhanced image from the binary image; obtaining a set of points to be corrected corresponding to each boundary pixel from the luminance-enhanced image; updating the luminance values ​​of the pixels in the set of points to be corrected based on the luminance values ​​of all pixels in the set of points to be corrected to obtain a target set of points corresponding to the set of points to be corrected; updating the luminance of pixels at corresponding positions in the luminance-enhanced image based on all target set of points to obtain a target luminance image; updating the V channel data in the HSV image based on the target luminance image to obtain a target HSV image; and obtaining a target RGB image based on the target HSV image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically, to an image processing method, apparatus, endoscope, device, and storage medium. Background Technology

[0002] In low-light environments, images acquired by image acquisition devices often suffer from quality issues such as high noise levels, blurred texture information, low contrast, and incorrect color reproduction, thus affecting the quality of subsequent image processing. For example, in clinical applications, to observe the tissue morphology and pathological conditions of internal organs and tissues, providing crucial information for clinical diagnosis, disease monitoring, and treatment plan determination, medical personnel use endoscopes to enter the human body and capture videos of internal organs and cavities. However, because the environment inside human cavities and organs is low-light, even if the endoscope tip provides illumination, the captured images will still contain low-light areas, leading to the aforementioned quality problems. This not only results in poor visual perception but also causes errors in image transmission, severely impacting the clinical effectiveness of endoscopy. Summary of the Invention

[0003] In view of this, in order to at least solve the quality problems of images in low-light environments in related technologies, the present invention aims to provide an image processing method, apparatus, endoscope, device and storage medium.

[0004] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: A first aspect of the present invention provides an image processing method, comprising: The luminance image is obtained from the HSV image of the original RGB image; A binary image is obtained from the negative image of the brightness image; Based on the brightness image, a brightness-enhanced image is obtained; Based on the binary image, the boundary pixels at the boundaries between the bright and dark areas in the brightness-enhanced image are obtained; For each boundary pixel, a set of points to be corrected corresponding to the boundary pixel is obtained from the brightness-enhanced image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; For each set of points to be corrected, the brightness values ​​of the pixels in the set of points to be corrected are updated according to the brightness values ​​of all pixels in the set of points to be corrected, so as to obtain the target set corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set is higher than the brightness uniformity of all pixels in the set of points to be corrected. Based on all target point sets, the brightness of the pixels at the corresponding positions in the brightness enhancement image is updated to obtain the target brightness image; Based on the target brightness image, update the V channel data in the HSV image to obtain the target HSV image; The target RGB image is obtained based on the target HSV image.

[0005] In an optional implementation, the step of obtaining a binary image from the negative image of the brightness image includes: The negative image is subjected to a power operation based on a set exponent to obtain the power-operated negative image. The brightness threshold is obtained based on the brightness values ​​of the original RGB image; In the negative image after the exponentiation, the brightness values ​​of pixels with brightness values ​​greater than or equal to the brightness threshold are updated to 255, and the brightness values ​​of pixels with brightness values ​​less than the brightness threshold are updated to 0, so as to obtain the corresponding binary image.

[0006] In an optional implementation, the set index ranges from (1, 2); and / or The step of obtaining the brightness threshold based on the brightness values ​​of the original RGB image includes: Based on the brightness values ​​of the original RGB image, a brightness reference value for the original RGB image is calculated; the brightness reference value is the average or median brightness value of the original RGB image. The brightness threshold is obtained by multiplying the brightness reference value and the set brightness coefficient; wherein the set brightness coefficient has a value range of [0.7, 1.1].

[0007] In an optional implementation, the value of the set index is 1.6, and / or the value of the set brightness coefficient is 0.9.

[0008] In an optional implementation, the step of obtaining a brightness-enhanced image based on the brightness image includes: The brightness transformation matrix is ​​calculated based on the set brightness enhancement matrix. The brightness image is subjected to a power operation based on the brightness transformation matrix to obtain a brightness-enhanced image.

[0009] In an optional implementation, the step of calculating the luminance transformation matrix based on the set luminance enhancement matrix includes: The first intermediate coefficient matrix and the second intermediate coefficient matrix are calculated based on the brightness enhancement matrix using the first calculation formula and the second calculation formula, respectively. The brightness transformation matrix is ​​calculated using the third calculation formula based on the first and second intermediate coefficient matrices. The first calculation formula is: matMidCoef =1.05 + (dLumEnhance / 113.0 - 0.03); The second calculation formula is: matBrightenCoef = (dLumEnhance / 113.0 - 0.03) / 3.0; The third calculation formula is: matPower = 1.0 / matMidCoef / (1 - matBrightenCoef); Wherein, matMidCoef represents the first intermediate coefficient matrix, dLumEnhance represents the brightness enhancement matrix, matBrightenCoef represents the second intermediate coefficient matrix, and matPower represents the brightness transformation matrix.

[0010] In an optional implementation, the step of performing an exponentiation operation on the brightness image based on the brightness transformation matrix to obtain a brightness-enhanced image includes: A brightness enhancement image is calculated using the fourth calculation formula, based on the brightness transformation matrix and the brightness image; in the brightness enhancement image, the brightness enhancement of the dark areas is greater than the brightness enhancement of the bright areas. The fourth calculation formula is: matVBrighten = 255 * (matV / 255.0) ^ matPower; Wherein, matVBrighten represents the brightness enhancement image, matV represents the brightness image, and matPower represents the brightness transformation matrix.

[0011] In an optional implementation, the step of obtaining the boundary pixels at the boundary between bright and dark areas in the brightness-enhanced image based on the binary image includes: Calculate the area of ​​each dark region in the binary image; Based on the image position of the edge pixels of the dark area with an area greater than a set area threshold, the corresponding boundary pixels are obtained from the brightness-enhanced image.

[0012] In an optional implementation, the step of updating the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected includes: A brightness reference value is calculated based on the brightness values ​​of all pixels in the set of points to be corrected; the brightness reference value is the average or median brightness of all pixels in the set of points to be corrected. Reduce the brightness value of pixels in the set of points to be corrected whose brightness value is higher than the brightness reference value; Increase the brightness value of pixels in the set of points to be corrected whose brightness value is lower than the brightness reference value.

[0013] In an optional implementation, for each pixel whose brightness is adjusted in the set of points to be corrected, the brightness adjustment range of the pixel whose brightness is adjusted is negatively correlated with the distance between the pixel whose brightness is adjusted and the corresponding boundary pixel.

[0014] A second aspect of the present invention provides an image processing apparatus, comprising: The acquisition module is configured to obtain a luminance image based on the HSV image of the original RGB image; The binarization processing module is configured to: obtain a binary image based on the negative image of the brightness image; The brightness enhancement module is configured to: obtain a brightness enhancement image based on the brightness image; The boundary determination module is configured to: obtain boundary pixels at the boundaries of bright and dark areas in the brightness-enhanced image based on the binary image; for each boundary pixel, obtain a set of points to be corrected corresponding to the boundary pixel from the brightness-enhanced image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; The correction module is configured to: for each set of points to be corrected, update the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected, to obtain a target set of points corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set of points is higher than the brightness uniformity of all pixels in the set of points to be corrected; update the brightness of the pixels at the corresponding positions in the brightness enhancement image based on all target set of points, to obtain a target brightness image; update the V channel data in the HSV image based on the target brightness image, to obtain a target HSV image; The image conversion module is configured to obtain a target RGB image based on the target HSV image.

[0015] A third aspect of the present invention provides an endoscope, comprising: Image acquisition equipment used to acquire raw RGB images; An image processing device is configured to perform any of the image processing methods provided in the first aspect above to obtain a target RGB image based on the original RGB image processing; and a display device for displaying the target RGB image.

[0016] A fourth aspect of the present invention provides an electronic device including a processor and a memory, the memory storing machine-executable instructions executable by the processor, the processor executing the machine-executable instructions to implement the image processing method provided in the first aspect above.

[0017] A fifth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the image processing method provided in the first aspect described above.

[0018] The image processing method, apparatus, endoscope, device, and storage medium provided in any of the above embodiments of the present invention have at least the following beneficial technical effects: A luminance image is obtained by using an HSV image derived from the original RGB image. Then, a binary image and a luminance-enhanced image are obtained from the luminance image. The boundary pixels on the boundary line between dark and bright areas in the luminance-enhanced image are then obtained based on the binary image, improving the accuracy of boundary recognition between dark and bright areas. Since boundary pixel localization can be achieved solely based on the binary image, the amount of data processing is reduced. Next, a corresponding set of points to be corrected is obtained based on the boundary pixels. This set includes the boundary pixels and pixels located on the dark and bright sides of the boundary pixels, respectively. These pixels are all adjacent to each other and on the same straight line. Therefore, all pixels in the set of points to be corrected best represent the luminance difference between dark and bright areas. Therefore, the brightness values ​​of all pixels in the target point set are updated based on the brightness values ​​of all pixels in the target point set to make the brightness of the pixels after brightness correction more uniform, thus obtaining the corresponding target point set. It can be seen that the brightness of the point that best represents the brightness difference between the dark and bright areas has been smoothed. This not only enables a smooth transition between the brightness of the dark and bright areas, but also improves the brightness of the dark areas. This allows the target HSV image after updating the V channel data based on the target point set to have the same technical effect. As a result, in the target RGB image converted from the target HSV image, not only do the dark areas have a good brightness improvement effect, but the overall image also has a good image color reproduction effect, and the image quality is effectively improved. Furthermore, since only the V channel data (i.e., the brightness image) in the HSV image needs to be processed, and the H and S channel image data do not need to be processed, and the image processing does not involve a large amount of computation, any of the above-mentioned solutions provided by the embodiments of the present invention also have the beneficial technical effects of high image processing efficiency, image sequence playback speed meeting video playback requirements (30 frames / s, image processing time per frame within 33ms), no stuttering, and good clinical application effect.

[0019] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This diagram illustrates a structural block diagram of an electronic device provided by an embodiment of the present invention. Figure 2 A flowchart of an image processing method provided by an embodiment of the present invention is shown; Figure 3 This diagram illustrates a comparison of the effects of an original RGB image and a target RGB image provided by an embodiment of the present invention. Figure 4 A schematic diagram of an endoscope provided in an embodiment of the present invention is shown; Figure 5 A functional block diagram of an image processing apparatus provided by an embodiment of the present invention is shown. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0023] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0024] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0025] In low-light environments, images acquired by image acquisition devices may suffer from high noise, blurred texture information, low contrast, and incorrect color reproduction, which can affect the quality of subsequent image processing. For example, in clinical applications of endoscopy, the human body cavities and organs are in low-light environments. Even if the endoscope tip can provide illumination, the captured images will still have low-light areas, leading to the aforementioned quality problems.

[0026] To address the aforementioned technical problems, three main solutions exist: first, traditional image enhancement methods; second, deep learning-based image enhancement methods; and third, methods improved based on classical histogram equalization and Retinex theory. However, these methods suffer from the following drawbacks: Traditional image enhancement methods are mostly based on histogram equalization to enhance the brightness and contrast of low-light images. However, histogram equalization suffers from problems such as gray-level overlap due to gray-level merging, loss of local image details, significant image block artifacts, and blurring of image background and target contours. The other two methods are computationally intensive and have long response times, making them unsuitable for applications with high timeliness requirements, such as endoscopy.

[0027] Therefore, to at least address the image quality issues arising in low-light environments in related technologies, this invention provides an image processing method. This method obtains a luminance image from an HSV image based on the original RGB image, then generates a binary image and a luminance-enhanced image based on the luminance image. Next, the binary image is used to acquire boundary pixels along the boundary lines between dark and bright areas in the luminance-enhanced image, improving the accuracy of boundary recognition between dark and bright areas. Since boundary pixel localization can be achieved solely based on the binary image, the amount of data processing is reduced. Furthermore, a corresponding set of points to be corrected is obtained based on the boundary pixels. This set includes the boundary pixels and pixels located on the dark and bright sides of the boundary pixels, respectively. These pixels are adjacent to each other and lie on the same straight line. Therefore, all pixels in the set of points to be corrected best represent the luminance difference between dark and bright areas. Therefore, the brightness values ​​of all pixels in the target point set are updated based on the brightness values ​​of all pixels in the target point set to achieve higher uniformity in brightness after correction, thus obtaining the corresponding target point set. It is evident that the brightness of the points best representing the brightness difference between dark and bright areas has been smoothed. This not only achieves a smooth transition between dark and bright areas but also enhances the brightness of dark areas. Consequently, the target HSV image updated based on the target point set's V channel data also exhibits the same technical effect. Consequently, the target RGB image converted from the target HSV image not only shows a good brightness enhancement effect in dark areas but also demonstrates excellent overall color reproduction. Furthermore, since processing is only required based on the V channel data (i.e., the brightness image) in the HSV image, without processing the H and S channel image data, and the image processing does not involve large-scale computations, any of the above-mentioned solutions provided in this embodiment of the invention also possesses beneficial technical effects such as high image processing efficiency, image sequence playback speed meeting video playback requirements (30 frames / s, image processing time per frame within 33ms), no stuttering, and excellent clinical application results.

[0028] The image processing method provided by this invention can be applied to electronic devices. Please refer to [link / reference]. Figure 1 This is a structural block diagram of an electronic device. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0029] The memory is used to store programs or data. The memory may be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.

[0030] The processor is used to read / write data or programs stored in memory and to perform the corresponding functions.

[0031] The communication module is used to establish communication connections between electronic devices and other communication terminals via a network, and to send and receive data via the network.

[0032] It should be understood that, Figure 1 The structure shown is only a schematic diagram of an electronic device; the electronic device may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0033] In some embodiments, the electronic device may be an image processing module, which may be sold as a separate product or as a processing module in an image device that has both image acquisition and image processing functions, to execute the image processing method provided in the embodiments of the present invention and improve image quality.

[0034] The following combination Figure 2 The image processing method provided in the embodiments of the present invention will be described below. Figure 2 This is a flowchart of an image processing method provided in an embodiment of the present invention, the image processing method comprising: In step S100, a luminance image is obtained based on the HSV image of the original RGB image; In step S200, a binary image is obtained based on the negative image of the brightness image; In step S300, a brightness enhancement image is obtained based on the brightness image; In step S400, the boundary pixels at the boundaries of bright and dark areas in the brightness-enhanced image are obtained based on the binary image. In step S500, for each boundary pixel, a set of points to be corrected corresponding to the boundary pixel is obtained from the brightness enhancement image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; In step S600, for each set of points to be corrected, the brightness values ​​of the pixels in the set of points to be corrected are updated according to the brightness values ​​of all pixels in the set of points to be corrected, so as to obtain the target set corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set is higher than the brightness uniformity of all pixels in the set of points to be corrected. In step S700, the brightness of the pixels at the corresponding positions in the brightness enhancement image is updated according to all target point sets to obtain the target brightness image; In step S800, the V channel data in the HSV image is updated according to the target brightness image to obtain the target HSV image; In step S900, a target RGB image is obtained based on the target HSV image.

[0035] In low-light environments, the image processing method provided in this embodiment of the invention can be used to enhance the brightness of the original RGB image acquired by the image acquisition module. After processing, the resulting target RGB image is then displayed on the display module for user viewing. For example, in endoscopy applications, the image processing method provided in this embodiment of the invention can be used to process images acquired in real time by the endoscope, and the resulting target RGB image can be output to the display module in real time, achieving smooth display of the image sequence acquired by the endoscope.

[0036] The execution subject of the image processing method provided in this embodiment of the invention can start executing the above steps S100 to S900 when it receives the original RGB image. In this case, by default, all received original RGB images are processed. Even if there is no low-light area in the original RGB image, the processed original RGB image can have better quality, as described above, and will not be repeated here.

[0037] Alternatively, if it is determined that quality enhancement processing is required based on the original RGB image, for example, when the original RGB image is received, the brightness value of the original RGB image can be obtained first. If it is found that the difference between the lowest brightness value and the highest brightness value is greater than a set difference, or the lowest brightness value is lower than a set brightness value, then the above steps S100 to S900 can be executed. Because in this case, the quality of the original RGB image is at a good level, so no further quality enhancement is required. This can reduce the number of images that need to be processed to a certain extent and make the image output more immediate.

[0038] In the above description, the original RGB image can be acquired by the image acquisition module and sent to the execution entity, or it can be sent to the execution entity by the server, or it can be obtained based on the user's selection operation from the execution entity's image library. This embodiment of the invention does not limit the source of the original RGB image. Furthermore, the setting of the difference value and the setting of the brightness value can be set based on experience or experimentation, and will not be elaborated here.

[0039] After obtaining the original RGB image, step S100 is executed to convert the original RGB image into an HSV image. The conversion principle can be found in relevant technologies. Then, the V channel image data can be extracted from the HSV image to obtain the luminance image; the extraction principle can also be found in relevant technologies. It should be understood that image data is typically stored in matrix form at the underlying level.

[0040] After obtaining the brightness image, the corresponding binary image and brightness enhancement image can be obtained by processing the brightness image. The acquisition of the binary image and the acquisition of the brightness enhancement image can be performed serially or in parallel. That is, the execution order of steps S200 and S300 is not restricted.

[0041] During step S200, to more accurately distinguish between dark and bright areas in the original RGB image, the original brightness values ​​of the brightness image can be inverted first, i.e., using 255 minus the original brightness value of each pixel to obtain the corresponding negative image. Next, the negative image is binarized. For example, a brightness threshold can be preset, setting the brightness values ​​of pixels in the negative image with values ​​greater than the threshold to 255, and setting the brightness values ​​of pixels with values ​​less than the threshold to 0. After processing the brightness values ​​of all pixels in the negative image in this way, the corresponding binary image is obtained. The brightness threshold can be set based on experience or experimentation.

[0042] However, to achieve better binarization results and improve the accuracy of distinguishing between dark areas and brightness, in some embodiments, the image processing method provided by this invention also offers another scheme for obtaining a binarized image of a negative image. That is, in step S200 above, the step of obtaining a binary image based on the negative image of the brightness image may include: In step S210, the negative image is subjected to a power operation according to a set exponent to obtain the power-operated negative image; In step S220, a brightness threshold is obtained based on the brightness values ​​of the original RGB image; In step S230, the brightness values ​​of pixels in the negative image after the exponentiation are updated to 255 for those with brightness values ​​greater than or equal to the brightness threshold, and the brightness values ​​of pixels with brightness values ​​less than the brightness threshold are updated to 0, so as to obtain the corresponding binary image.

[0043] The process of obtaining a binary image based on negative image processing through steps S210 to S230 is as follows: First, steps S210 and S220 are used to obtain a better negative image and brightness threshold. It can be seen that the execution order of steps S210 and S220 is not limited. They can be executed serially or in parallel.

[0044] During step S210, the negative image can be first subjected to a power operation based on a set exponent to improve the difference in brightness values ​​of each pixel in the negative image. This facilitates more accurate differentiation between dark and bright areas in the subsequently generated binary image. In some examples, to achieve better differentiation between dark and bright areas, the set exponent can be in the range of (1, 2). For example, the exponent can be 1.6, which achieves better binarization image processing results and makes it easier to differentiate between dark and bright areas in the original RGB image based on the binarized image. Based on this, the brightness value of each pixel in the negative image can be calculated to the power of 1.6 to obtain the negative image after the power operation.

[0045] During step S220, a brightness threshold that more closely matches the actual brightness of the original RGB image can be calculated based on the brightness values ​​of the original RGB image. This results in a higher consistency between the dark and bright areas of the subsequently obtained binary image and the dark and bright areas of the original RGB image, respectively. Specifically, the average or median brightness of the original RGB image can be used as the brightness threshold in step S200.

[0046] When the dark and bright areas of the binary image have higher consistency with the dark and bright areas of the original RGB image, respectively, to make the distinction between dark and bright areas easier and more accurate, in some embodiments, the image processing method provided by the present invention also provides another scheme for obtaining the brightness threshold. That is, the step of obtaining the brightness threshold based on the brightness value of the original RGB image in step S220 above may include: In step S221, a brightness reference value for the original RGB image is calculated based on the brightness value of the original RGB image; the brightness reference value is the average or median brightness value of the original RGB image. In step S222, the product of the brightness reference value and the set brightness coefficient is calculated to obtain the brightness threshold; wherein the set brightness coefficient has a value range of [0.7, 1.1].

[0047] Understandably, in the process of obtaining the brightness threshold, step S221 can be executed first to calculate a brightness reference value that can be used to characterize the brightness of the original RGB image based on the brightness value of each pixel in the original RGB image. This brightness reference value can be the average brightness or the median brightness.

[0048] After obtaining the brightness reference value, step S222 can be executed to calculate the product of the brightness reference value and the set brightness coefficient, and use this product as the brightness threshold. The set brightness coefficient has a value range of [0.7, 1.1]. In order to obtain a brightness that better reflects the original RGB image and to enable the subsequent binary image to have better dark and bright area differentiation, in some examples, the value of the set brightness coefficient is 0.9.

[0049] After obtaining the negative image and brightness threshold after exponentiation through any of the above embodiments, step S230 can be executed to set the brightness value of pixels in the negative image after exponentiation that have a brightness value greater than or equal to the brightness threshold to 255, and the brightness value of pixels that have a brightness value less than the brightness threshold to 0, so as to obtain the corresponding binary image.

[0050] During step S300, to obtain the enhanced brightness image, the brightness value of each pixel in the brightness image can be multiplied by a set enhancement coefficient to obtain a new brightness value, which is then updated to obtain the enhanced brightness image. The set enhancement coefficient is a value greater than 1 and can be set based on practical experience or experimentation. In other variations, the multiplication process can be replaced with an exponentiation operation, as long as the goal of achieving a brightness enhancement image that is higher than the original brightness image is achieved.

[0051] However, in order to significantly enhance the brightness of dark areas and avoid applying the same enhancement rate to bright areas (which could lead to overexposure in the bright areas after brightness enhancement), and to ensure better color balance in the subsequent target RGB image, in some embodiments, the image processing method provided by this invention also provides another scheme for obtaining a brightness-enhanced image. That is, the step of obtaining a brightness-enhanced image based on the brightness image in step S300 above may include: In step S310, the brightness transformation matrix is ​​calculated based on the set brightness enhancement matrix; In step S320, the brightness image is subjected to exponentiation processing according to the brightness transformation matrix to obtain a brightness-enhanced image.

[0052] Understandably, during the acquisition of the brightness-enhanced image, step S310 can be executed first to calculate a brightness transformation matrix based on the set brightness enhancement matrix. This matrix is ​​used to enhance the overall brightness of the brightness image, with the enhancement magnitude of dark areas being greater than that of bright areas. The number of rows and columns of this brightness transformation matrix is ​​the same as that of the brightness image, and the values ​​at the positions corresponding to pixels in the dark areas are greater than the values ​​at the positions corresponding to pixels in the bright areas. In the brightness transformation matrix, the values ​​at the positions corresponding to pixels in the bright areas can take values ​​in the range [0, 1]. These values ​​can all be the same, partially the same, or different from each other. Similarly, the values ​​at the positions corresponding to pixels in the dark areas can be greater than 1, which can be set according to actual needs or experience. Likewise, these values ​​can all be the same, partially the same, or different from each other.

[0053] In some embodiments, in order to obtain a more reasonable brightness transformation matrix so as to better brighten the overall brightness image while achieving better brightening of both dark areas and brightness, the image processing method provided in this embodiment of the invention also provides another scheme for obtaining the brightness transformation matrix. That is, the step of calculating the brightness transformation matrix according to the set brightness enhancement matrix in step S310 above may include: In step S311, the first intermediate coefficient matrix and the second intermediate coefficient matrix are calculated based on the brightness enhancement matrix using the first calculation formula and the second calculation formula, respectively. In step S312, the brightness transformation matrix is ​​calculated based on the first intermediate coefficient matrix and the second intermediate coefficient matrix using the third calculation formula.

[0054] The first calculation formula is: matMidCoef =1.05 + (dLumEnhance / 113.0 - 0.03); The second calculation formula is: matBrightenCoef = (dLumEnhance / 113.0 - 0.03) / 3.0; The third calculation formula is: matPower = 1.0 / ( matMidCoef× (1 - matBrightenCoef) ); In the above, matMidCoef represents the first intermediate coefficient matrix; dLumEnhance represents the brightness enhancement matrix, where the values ​​range from (1, 150); matBrightenCoef represents the second intermediate coefficient matrix; and matPower represents the brightness transformation matrix. Furthermore, the number of rows and columns of each of these matrices is the same as the number of rows and columns in the brightness image.

[0055] After obtaining the luminance transformation matrix through any embodiment in step S310, step S320 can be executed to perform an exponentiation operation on the luminance image based on the luminance transformation matrix to obtain a luminance-enhanced image. For example, the luminance transformation matrix can be used as the exponent of the matrix corresponding to the luminance image for the operation, and the resulting matrix is ​​the luminance-enhanced image.

[0056] In some embodiments, to improve the numerical stability and accuracy of the brightness enhancement image during the calculation process, the image processing method provided in this embodiment of the invention also provides another scheme for obtaining the brightness enhancement image. Specifically, step S320 above, which involves performing an exponentiation operation on the brightness image based on the brightness transformation matrix to obtain the brightness enhancement image, may include: In step S321, a brightness enhancement image is calculated based on the brightness transformation matrix and the brightness image using the fourth calculation formula; in the brightness enhancement image, the brightness enhancement of the dark area is greater than the brightness enhancement of the bright area.

[0057] The fourth calculation formula is: matVBrighten = 255 * (matV / 255.0) ^ matPower; Where matVBrighten represents the brightness enhancement image, matV represents the brightness image, and matPower represents the brightness transformation matrix.

[0058] As shown in the fourth calculation formula, the brightness image is first normalized, then exponentially processed using the brightness transformation matrix as an exponent, and finally the matrix obtained from the exponentiation is restored to its original scale before normalization, thus obtaining the brightness-enhanced image. The normalization process significantly improves the stability and accuracy of the numerical values, thereby enhancing the brightness accuracy in the brightness-enhanced image.

[0059] After obtaining the brightness-enhanced image through any embodiment of step S300, step S400 can be executed to obtain the boundary pixels at the boundaries of bright and dark areas in the brightness-enhanced image using a binary image. For example, since the binary image is generated based on a negative image of the brightness image, in the binary image, the position of the value 0 represents a relatively bright point in the original image, which belongs to the bright area, while the position of the value 255 represents a relatively dark point in the original image, which belongs to the dark area. Therefore, the area formed by consecutive values ​​of 0 can be regarded as a bright area, and the area formed by consecutive values ​​of 255 can be regarded as a dark area. In this way, if the values ​​of 0 or 255 are not always consecutive, there may be multiple dark areas and / or multiple bright areas. Based on this, the edge of each dark area can be used as the boundary line between the corresponding dark area and the bright area. Since the position of each pixel in the binary image corresponds one-to-one with the position of each pixel in the brightness enhancement image, the pixel at the corresponding position in the brightness enhancement image can be obtained based on the position of the boundary line in the binary image, thus obtaining the boundary pixel in step S400.

[0060] In some embodiments, when there is a need to reduce the amount of image data processing, small dark areas may not be processed, because small dark areas generally have a small impact on the overall image quality, thus simplifying the calculation. Based on this, the image processing method provided in this embodiment of the invention also provides another scheme for obtaining boundary pixels. That is, the step S400 above, which involves obtaining the boundary pixels at the boundary between bright and dark areas in the brightness-enhanced image based on the binary image, may include: In step S410, the area of ​​each dark region in the binary image is calculated; In step S420, the corresponding boundary pixels are obtained from the brightness-enhanced image based on the image position of the edge pixels of the dark area whose area is greater than a set area threshold.

[0061] In the process of acquiring boundary pixels, step S410 can be executed first to calculate the area of ​​each dark region in the binary image. The principle of area calculation can be found in related technologies. Then, step S420 is executed to filter the dark regions based on their areas, obtaining dark regions with areas greater than a set area threshold. The filtered dark regions will be applied to the subsequent brightness value update. Therefore, for these filtered dark regions, the corresponding boundary pixels will be further obtained from the brightness-enhanced image. Unselected dark regions can be ignored and do not need to participate in the subsequent brightness value update.

[0062] After obtaining the boundary pixel through any embodiment of step S400, step S500 can be executed to obtain the set of points to be corrected corresponding to the boundary pixel from the brightness enhancement image for each boundary pixel. A set of points to be corrected includes a boundary pixel and pixels located on the dark side and bright side of the boundary pixel, respectively, and all pixels in a set of points to be corrected are adjacent to each other and on the same straight line.

[0063] Understandably, if all pixels in a set of points to be corrected are in the same column or row, the process of obtaining the set can begin with boundary pixels. These boundary pixels are then included in the set. Next, starting from the dark side of the boundary pixels, a first predetermined number of dark area pixels are obtained outwards from the pixel immediately adjacent to the boundary. For example, assuming the left side of a boundary pixel is the dark side, dark area pixels are selected progressively to the left of the boundary pixel in the row containing the boundary pixel, starting from the pixel to its left and adjacent to the boundary pixel, and added to the set until the total number of dark area pixels reaches the first predetermined number. Based on the same principle, a second predetermined number of bright area pixels can be obtained from the bright side of the boundary pixels.

[0064] In the above, the first and second preset quantities can be the same or different. Furthermore, the values ​​of the first and second preset quantities can be configured according to actual needs or experience. In some examples, to reduce computational load to a certain extent while ensuring a smooth transition between dark and bright areas and achieving better balance between them, both the first and second preset quantities can be set to 4. Based on this example, a set of points to be corrected includes a total of 9 pixels: 1 boundary pixel, 4 dark area pixels, and 4 bright area pixels.

[0065] The area threshold mentioned above can also be configured according to actual needs or experience. For example, the area threshold can be 10,000 pixels, but it is not limited to this.

[0066] After obtaining the set of points to be corrected through any embodiment in step S500, step S600 can be executed to correct the brightness of all or part of the pixels in the set of points to be corrected, so that the brightness uniformity of all pixels after brightness correction is greater than the brightness uniformity of all pixels before correction. The correction principle can be found in related technologies.

[0067] In some embodiments, in order to obtain a target RGB image with smoother brightness transitions and better color reproduction, the image processing method provided in this embodiment of the invention also provides another brightness correction scheme, namely, the step of updating the brightness values ​​of the pixels in the set of points to be corrected according to the brightness values ​​of all pixels in the set of points to be corrected in the above step S500 may include: In step S510, a brightness reference value is calculated based on the brightness values ​​of all pixels in the set of points to be corrected; the brightness reference value is the average or median brightness of all pixels in the set of points to be corrected. In step S520, the brightness values ​​of pixels in the set of points to be corrected that have brightness values ​​higher than the brightness reference value are reduced. In step S530, the brightness values ​​of pixels in the set of points to be corrected that have brightness values ​​lower than the brightness reference value are increased.

[0068] Understandably, in the brightness correction scheme shown in steps S510 to S530, step S510 can be executed first to process each set of points to be corrected separately, so as to obtain the brightness reference value corresponding to each set of points to be corrected. Each set of points to be corrected uses the average or median brightness value of all pixels it contains as its brightness reference value. This allows subsequent brightness correction to be based on the median or average brightness value, both of which reflect the brightness characteristics and levels of the original RGB image. Therefore, it ensures that the correction result not only improves the quality of dark areas but also maintains the brightness characteristics of the original RGB image, thus better restoring the original colors.

[0069] After obtaining the brightness reference value of each set of points to be corrected through step S510, steps S520 and S530 can be executed serially or in parallel. It can be seen that the execution order of steps S520 and S530 is not limited in this embodiment of the invention.

[0070] During steps S520 and S530, taking a set of points to be corrected as an example, all pixels in the set can be compared with a brightness reference value to identify pixels with brightness levels below and above the reference value. Next, the brightness of pixels with brightness levels below the reference value is increased, with the increase amount set according to actual needs or experience. Similarly, the brightness of pixels with brightness levels above the reference value is decreased, with the decrease amount also set according to actual needs or experience. The increase amount for pixels with brightness levels below the reference value can be the same or different; similarly, the decrease amount for pixels with brightness levels above the reference value can be the same or different. For ease of description, the increase and decrease amounts of brightness will be collectively referred to as the brightness adjustment range.

[0071] In some embodiments, to ensure a natural brightness transition of the pixels whose brightness is being adjusted, and to make the boundary transition between dark and bright areas more natural and smooth, during the process of adjusting the pixels whose brightness needs to be adjusted in the set of points to be corrected, for each pixel whose brightness is being adjusted, the brightness adjustment range of the pixel whose brightness is being adjusted is negatively correlated with the distance between the pixel whose brightness is being adjusted and the corresponding boundary pixel.

[0072] For example, suppose a set of points to be corrected includes nine pixels numbered 1 to 9. These nine pixels are arranged in the same order from dark to light areas, i.e., pixel 1, pixel 2, pixel 3, pixel 4, pixel 5, pixel 6, pixel 7, pixel 8, and pixel 9. The boundary pixel is the middle point, i.e., pixel 5; the pixels whose brightness needs to be adjusted are pixel 1, pixel 3, pixel 4, pixel 6, and pixel 8.

[0073] Based on this, it can be seen that pixels 4 and 6 are the closest to pixel 5, followed by pixel 3, then pixel 8, and then pixel 1. Therefore, based on the principle that the brightness adjustment range of a pixel is negatively correlated with the distance between the pixel and its corresponding boundary pixel, the closer a pixel is to a boundary pixel, the greater its brightness adjustment range, and the farther a pixel is from a boundary pixel, the smaller its brightness adjustment range. In the example above, pixels 4 and 6 have the largest brightness adjustment range. For example, taking 10% of the brightness reference value V as the maximum brightness adjustment range, and assuming the brightness of pixels 4 and 6 are A and B respectively, where A is less than the brightness reference value and B is greater than the brightness reference value, then the updated brightness value of pixel 4 is A + 10%V, and the updated brightness value of pixel 6 is B - 10%V. Since pixel 3 and pixel 5 are 1 pixel apart, with a pixel distance of 1, if the attenuation rate is 2%, then the brightness adjustment rate of pixel 3 is: (10% - n × 2%)V = 8%V, where n is the pixel distance. Similarly, the brightness adjustment rate and the updated brightness value of pixel 8 and pixel 1 can be calculated based on the above principle.

[0074] After adjusting the brightness of all pixels to be adjusted using any embodiment in step S600, a target point set corresponding to each set of points to be corrected can be obtained. Next, step S700 can be executed. During step S700, the brightness values ​​of all pixels contained in all target point sets can replace the brightness values ​​of pixels at corresponding positions in the brightness-enhanced image, thereby obtaining the target brightness image.

[0075] After obtaining the target brightness image, step S800 can be executed, keeping the H channel data and S channel data in the HSV image unchanged, and updating the V channel data to the data corresponding to the target brightness image, that is, replacing the original brightness image in the HSV image with the target brightness image, thereby obtaining the target HSV image.

[0076] After obtaining the target HSV image, step S900 can be executed to convert the target HSV image into a target RGB image. The conversion principle can be found in related technologies.

[0077] Therefore, in the target RGB image obtained through any of the above embodiments, the brightness of the dark areas can be significantly improved, and the overall image clarity and color reproduction are both excellent. Figure 3 As shown, Figure 3 This is a schematic diagram comparing the effects of an original RGB image and a target RGB image provided in an embodiment of the present invention. It can be seen that the target RGB image M1 has better image quality than the original RGB image M0.

[0078] After obtaining the target RGB image, in some embodiments, the target RGB image can also be output to a display module for user viewing. For example, in the field of endoscopy, the processed target RGB image sequence can be output to a display module for doctors to observe and make relevant diagnoses. It is worth noting that the technical features or solutions in any of the above embodiments of the present invention can be combined with each other, as long as there is no contradiction in the combination.

[0079] In addition, embodiments of the present invention also provide an endoscope, please refer to [link to relevant documentation]. Figure 4 , Figure 4 This is a schematic diagram of an endoscope provided in an embodiment of the present invention. The endoscope 400 includes: Image acquisition device 410 is used to acquire raw RGB images; The aforementioned image acquisition device 410 can be located at the tip of the insertion tube 440 of the endoscope operating handle 450; Image processing device 420 is configured to execute the image processing method provided in any of the above embodiments to obtain a target RGB image based on the original RGB image; and a display device 430 for displaying the target RGB image.

[0080] The endoscope provided in this embodiment of the invention is illustrative; it can be understood that the endoscope may also include components such as... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown.

[0081] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of an image processing apparatus is given below. Optionally, the image processing apparatus may employ the methods described above. Figure 1 The device structure of the electronic device is shown. Further, please refer to... Figure 5 , Figure 5 This is a functional block diagram of an image processing apparatus provided in an embodiment of the present invention. It should be noted that the image processing apparatus provided in this embodiment has the same basic principle and technical effects as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The image processing apparatus 500 includes: The acquisition module 510 is configured to obtain a luminance image based on the HSV image of the original RGB image; The binarization processing module 520 is configured to: obtain a binary image based on the negative image of the brightness image; The brightness enhancement module 530 is configured to: obtain a brightness enhancement image based on the brightness image; The boundary determination module 540 is configured to: obtain boundary pixels at the boundaries of bright and dark areas in the brightness-enhanced image based on the binary image; for each boundary pixel, obtain a set of points to be corrected corresponding to the boundary pixel from the brightness-enhanced image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; The correction module 550 is configured to: for each set of points to be corrected, update the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected, to obtain a target set of points corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set of points is higher than the brightness uniformity of all pixels in the set of points to be corrected; update the brightness of the pixels at the corresponding positions in the brightness enhancement image based on all target set of points, to obtain a target brightness image; update the V channel data in the HSV image based on the target brightness image, to obtain a target HSV image; The image conversion module 560 is configured to obtain a target RGB image based on the target HSV image.

[0082] In some embodiments, the process by which the binarization processing module 520 obtains a binary image from the negative image of the brightness image is configured as follows: The negative image is subjected to a power operation based on a set exponent to obtain the power-operated negative image. The brightness threshold is obtained based on the brightness values ​​of the original RGB image; In the negative image after the exponentiation, the brightness values ​​of pixels with brightness values ​​greater than or equal to the brightness threshold are updated to 255, and the brightness values ​​of pixels with brightness values ​​less than the brightness threshold are updated to 0, so as to obtain the corresponding binary image.

[0083] In some embodiments, the value range of the set index is (1, 2).

[0084] In some embodiments, the process by which the binarization processing module 520 obtains a brightness threshold based on the brightness values ​​of the original RGB image is configured as follows: Based on the brightness values ​​of the original RGB image, a brightness reference value for the original RGB image is calculated; the brightness reference value is the average or median brightness value of the original RGB image. The brightness threshold is obtained by multiplying the brightness reference value and the set brightness coefficient; wherein the set brightness coefficient has a value range of [0.7, 1.1].

[0085] In some embodiments, the value of the set index is 1.6, and / or the value of the set brightness coefficient is 0.9.

[0086] In some embodiments, the process by which the brightness enhancement module 530 obtains a brightness enhancement image based on the brightness image is configured as follows: The brightness transformation matrix is ​​calculated based on the set brightness enhancement matrix. The brightness image is subjected to a power operation based on the brightness transformation matrix to obtain a brightness-enhanced image.

[0087] In some embodiments, the process by which the brightness enhancement module 530 calculates the brightness transformation matrix based on a set brightness enhancement matrix is ​​configured as follows: The first intermediate coefficient matrix and the second intermediate coefficient matrix are calculated based on the brightness enhancement matrix using the first calculation formula and the second calculation formula, respectively. The brightness transformation matrix is ​​calculated using the third calculation formula based on the first and second intermediate coefficient matrices. The first calculation formula is: matMidCoef =1.05 + (dLumEnhance / 113.0 - 0.03); The second calculation formula is: matBrightenCoef = (dLumEnhance / 113.0 - 0.03) / 3.0; The third calculation formula is: matPower = 1.0 / ( matMidCoef× (1 - matBrightenCoef) ); Wherein, matMidCoef represents the first intermediate coefficient matrix, dLumEnhance represents the brightness enhancement matrix, matBrightenCoef represents the second intermediate coefficient matrix, and matPower represents the brightness transformation matrix.

[0088] In some embodiments, the process by which the brightness enhancement module 530 performs a power operation on the brightness image according to the brightness transformation matrix to obtain a brightness-enhanced image is configured as follows: A brightness enhancement image is calculated using the fourth calculation formula, based on the brightness transformation matrix and the brightness image; in the brightness enhancement image, the brightness enhancement of the dark areas is greater than the brightness enhancement of the bright areas. The fourth calculation formula is: matVBrighten = 255 * (matV / 255.0) ^ matPower; Wherein, matVBrighten represents the brightness enhancement image, matV represents the brightness image, and matPower represents the brightness transformation matrix.

[0089] In some embodiments, the process by which the boundary determination module 540 obtains the boundary pixels at the boundary between the bright and dark areas in the brightness-enhanced image based on the binary image is configured as follows: Calculate the area of ​​each dark region in the binary image; Based on the image position of the edge pixels of the dark area with an area greater than a set area threshold, the corresponding boundary pixels are obtained from the brightness-enhanced image.

[0090] In some embodiments, the process by which the correction module 550 updates the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected is configured as follows: A brightness reference value is calculated based on the brightness values ​​of all pixels in the set of points to be corrected; the brightness reference value is the average or median brightness of all pixels in the set of points to be corrected. Reduce the brightness value of pixels in the set of points to be corrected whose brightness value is higher than the brightness reference value; Increase the brightness value of pixels in the set of points to be corrected whose brightness value is lower than the brightness reference value.

[0091] In some embodiments, for each pixel whose brightness is adjusted in the set of points to be corrected, the brightness adjustment range of the pixel whose brightness is adjusted is negatively correlated with the distance between the pixel whose brightness is adjusted and the corresponding boundary pixel.

[0092] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown is either stored in or embedded in the operating system (OS) of the electronic device, and can be... Figure 1 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.

[0093] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0094] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0095] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0096] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An image processing method, characterized in that, include: The luminance image is obtained from the HSV image of the original RGB image; A binary image is obtained from the negative image of the brightness image; The brightness transformation matrix is ​​calculated based on the set brightness enhancement matrix. The brightness transformation matrix is ​​used to enhance the overall brightness of the brightness image, and the brightness enhancement of dark areas is greater than that of bright areas. The brightness image is subjected to a power operation based on the brightness transformation matrix to obtain a brightness-enhanced image; Based on the binary image, the boundary pixels at the boundaries between the bright and dark areas in the brightness-enhanced image are obtained; For each boundary pixel, a set of points to be corrected corresponding to the boundary pixel is obtained from the brightness-enhanced image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; For each set of points to be corrected, the brightness values ​​of the pixels in the set of points to be corrected are updated according to the brightness values ​​of all pixels in the set of points to be corrected, so as to obtain the target set corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set is higher than the brightness uniformity of all pixels in the set of points to be corrected. Based on all target point sets, the brightness of the pixels at the corresponding positions in the brightness enhancement image is updated to obtain the target brightness image; Based on the target brightness image, update the V channel data in the HSV image to obtain the target HSV image; The target RGB image is obtained based on the target HSV image.

2. The method according to claim 1, characterized in that, The step of obtaining a binary image from the negative image of the brightness image includes: The negative image is subjected to a power operation based on a set exponent to obtain the power-operated negative image. The brightness threshold is obtained based on the brightness values ​​of the original RGB image; In the negative image after the exponentiation, the brightness values ​​of pixels with brightness values ​​greater than or equal to the brightness threshold are updated to 255, and the brightness values ​​of pixels with brightness values ​​less than the brightness threshold are updated to 0, so as to obtain the corresponding binary image.

3. The method according to claim 2, characterized in that, The set index is set to a value range of (1, 2); and / or The step of obtaining the brightness threshold based on the brightness values ​​of the original RGB image includes: Based on the brightness values ​​of the original RGB image, a brightness reference value for the original RGB image is calculated; the brightness reference value is the average or median brightness value of the original RGB image. The brightness threshold is obtained by multiplying the brightness reference value and the set brightness coefficient; wherein the set brightness coefficient has a value range of [0.7, 1.1].

4. The method according to claim 3, characterized in that, The value of the set index is 1.6, and / or the value of the set brightness coefficient is 0.

9.

5. The method according to claim 1, characterized in that, The step of calculating the luminance transformation matrix based on the set luminance enhancement matrix includes: The first intermediate coefficient matrix and the second intermediate coefficient matrix are calculated based on the brightness enhancement matrix using the first calculation formula and the second calculation formula, respectively. The brightness transformation matrix is ​​calculated using the third calculation formula based on the first and second intermediate coefficient matrices. The first calculation formula is: matMidCoef =1.05 + (dLumEnhance / 113.0 - 0.03); The second calculation formula is: matBrightenCoef = (dLumEnhance / 113.0 - 0.03) / 3.0; The third calculation formula is: matPower = 1.0 / ( matMidCoef× (1 - matBrightenCoef) ); Wherein, matMidCoef represents the first intermediate coefficient matrix, dLumEnhance represents the brightness enhancement matrix, matBrightenCoef represents the second intermediate coefficient matrix, and matPower represents the brightness transformation matrix.

6. The method according to claim 1, characterized in that, The step of performing an exponentiation operation on the brightness image based on the brightness transformation matrix to obtain a brightness-enhanced image includes: A brightness enhancement image is calculated using the fourth calculation formula, based on the brightness transformation matrix and the brightness image; in the brightness enhancement image, the brightness enhancement of the dark areas is greater than the brightness enhancement of the bright areas. The fourth calculation formula is: matVBrighten = 255 * (matV / 255.0) ^ matPower; Wherein, matVBrighten represents the brightness enhancement image, matV represents the brightness image, and matPower represents the brightness transformation matrix.

7. The method according to claim 1, characterized in that, The step of obtaining the boundary pixels at the boundary between bright and dark areas in the brightness-enhanced image based on the binary image includes: Calculate the area of ​​each dark region in the binary image; Based on the image position of the edge pixels of the dark area with an area greater than a set area threshold, the corresponding boundary pixels are obtained from the brightness-enhanced image.

8. The method according to claim 1, characterized in that, The step of updating the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected includes: A brightness reference value is calculated based on the brightness values ​​of all pixels in the set of points to be corrected; the brightness reference value is the average or median brightness of all pixels in the set of points to be corrected. Reduce the brightness value of pixels in the set of points to be corrected whose brightness value is higher than the brightness reference value; Increase the brightness value of pixels in the set of points to be corrected whose brightness value is lower than the brightness reference value.

9. The method according to claim 8, characterized in that, For each pixel whose brightness is adjusted in the set of points to be corrected, the brightness adjustment range of the pixel whose brightness is adjusted is negatively correlated with the distance between the pixel whose brightness is adjusted and the corresponding boundary pixel.

10. An image processing apparatus, characterized in that, include: The acquisition module is configured to obtain a luminance image based on the HSV image of the original RGB image; The binarization processing module is configured to: obtain a binary image based on the negative image of the brightness image; The brightness enhancement module is configured to: calculate a brightness transformation matrix based on a set brightness enhancement matrix; the brightness transformation matrix is ​​used to enhance the overall brightness of the brightness image, with the brightness enhancement of dark areas being greater than the brightness enhancement of bright areas; and perform exponentiation processing on the brightness image based on the brightness transformation matrix to obtain a brightness-enhanced image. The boundary determination module is configured to: obtain boundary pixels at the boundaries of bright and dark areas in the brightness-enhanced image based on the binary image; for each boundary pixel, obtain a set of points to be corrected corresponding to the boundary pixel from the brightness-enhanced image; the set of points to be corrected includes the boundary pixel and pixels located on the dark side and bright side of the boundary pixel respectively; all pixels in the set of points to be corrected are adjacent to each other and on the same straight line; The correction module is configured to: for each set of points to be corrected, update the brightness values ​​of the pixels in the set of points to be corrected based on the brightness values ​​of all pixels in the set of points to be corrected, so as to obtain the target set corresponding to the set of points to be corrected; the brightness uniformity of all pixels in the target set is higher than the brightness uniformity of all pixels in the set of points to be corrected. Based on all target point sets, the brightness of the pixels at the corresponding positions in the brightness enhancement image is updated to obtain the target brightness image; based on the target brightness image, the V channel data in the HSV image is updated to obtain the target HSV image. The image conversion module is configured to obtain a target RGB image based on the target HSV image.

11. An endoscope, characterized in that, include: Image acquisition equipment used to acquire raw RGB images; An image processing apparatus for performing the method of any one of claims 1-9 to obtain a target RGB image based on the original RGB image; and a display device for displaying the target RGB image.

12. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor to implement the method of any one of claims 1-9.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Image processing method and system, automatic walking equipment and readable storage medium

    CN113449730A