Image contrast enhancement method and system

By using nonlinear functions and grayscale mapping algorithms in image processing, local contrast enhancement is performed for specific brightness areas, which solves the problem that the existing technology is difficult to achieve the expected visual effects, and achieves more efficient image detail improvement and visual effect enhancement.

CN119722471AInactive Publication Date: 2025-03-28SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411668178.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image contrast adjustment methods are difficult to achieve the desired visual effect when processing images with specific brightness areas, especially in scenes where fine adjustments to the local contrast of the image are required.

Method used

The image contrast enhancement method based on nonlinear functions and grayscale mapping algorithms is used to enhance the grayscale distribution of specific feature points or regions in the image, and the image brightness value is nonlinearly mapped to achieve contrast stretching or compression of different grayscale pixel values.

Benefits of technology

It significantly improves the contrast of the image, makes the image details clearer and more visible, enhances the visual effect, improves the adaptability of the image in different display environments, and significantly improves the accuracy of image analysis and recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119722471A_ABST
    Figure CN119722471A_ABST
Patent Text Reader

Abstract

The invention discloses an image contrast enhancement method and system, belongs to the technical field of image processing, and aims at performing local contrast enhancement on gray distribution of specific feature points or regions in an image based on a nonlinear function and a gray mapping algorithm and providing contrast stretching or compression of different degrees for pixel values of different gray levels. The nonlinear function specifically comprises image graying, gray histogram design and nonlinear mapping of image brightness values by using a nonlinear function formula; the gray mapping algorithm specifically comprises image numeralization, pixel interpolation calculation and gray mapping. According to the method, the specific brightness area of the image can be finely adjusted, a better visual effect is achieved, the contrast of the image is remarkably improved, and image details are clearer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, in particular to an image contrast enhancement method and system. Background Art

[0002] With the development of digital image processing technology, image contrast adjustment has become an important means to improve the visual effect of images. Existing contrast adjustment methods mostly use techniques such as linear stretching or nonlinear transformation to enhance the dynamic range and detail performance of images. However, these methods may not achieve the expected visual effect when processing images with specific brightness areas, especially in scenes where fine adjustment of local image contrast is required.

[0003] In the image processing process, contrast enhancement is an important step in image data enhancement, which can be used to improve visual effects and enhance image feature points. However, commonly used image contrast enhancement algorithms, such as histogram equalization, linear contrast stretching, filters, etc., only target global contrast and cannot enhance contrast for feature points. For any image, especially images with specific feature points, common image enhancement techniques cannot improve visual effects and feature enhancement because some image features are not obvious and are relatively complex. Summary of the invention

[0004] The technical task of the present invention is to address the above deficiencies and provide an image contrast enhancement method and system, which are particularly suitable for fine adjustment of specific brightness areas of an image to achieve better visual effects.

[0005] The technical solution adopted by the present invention to solve its technical problem is:

[0006] An image contrast enhancement method, based on nonlinear functions and grayscale mapping algorithms, performs local contrast enhancement for the grayscale distribution of specific feature points or regions in an image, and can provide different degrees of contrast stretching or compression for pixel values ​​of different grayscales;

[0007] The nonlinear function specifically includes image grayscale, grayscale histogram design, and nonlinear mapping of image brightness values ​​using a nonlinear function formula;

[0008] The grayscale mapping algorithm specifically includes image digitization, pixel interpolation calculation, and grayscale mapping.

[0009] This method can enhance the contrast of multiple features of an image according to the grayscale range. It is suitable for a variety of image processing scenarios, including medical imaging, satellite image analysis, video surveillance, etc., and can significantly improve the accuracy of image analysis and recognition.

[0010] Furthermore, the implementation steps of the method include:

[0011] 1) Convert the image into a grayscale image, and then calculate the histogram of the obtained grayscale image to reveal the distribution of grayscale values ​​in the image;

[0012] 2) Define a nonlinear function formula and perform nonlinear mapping on the brightness value of the image according to preset parameters;

[0013] 3) Setting grayscale curve parameters, by adjusting the slope of the curve within a preset grayscale range, to achieve contrast enhancement of a specific grayscale area of ​​the image;

[0014] 4) Apply a nonlinear function to transform the image numerical array to obtain a contrast-enhanced image numerical array.

[0015] Furthermore, the grayscale histogram includes two coordinate systems, the x-axes of the two coordinate systems represent the grayscale value, and the y-axes represent the number of pixels and the grayscale value corresponding to the grayscale value, respectively.

[0016] Furthermore, the nonlinear function is defined as shown in formula (1):

[0017]

[0018] Here, j is an accumulator variable used to generate linearly varying parameters between x1 and x2.

[0019] Furthermore, assuming x1=a, y1=c, x2=b, y2=d, it means that pixels with grayscale values ​​less than a are mapped to c, pixels with grayscale values ​​between a and b have their mapped grayscales increase with the curve, and pixels with grayscale values ​​greater than b are mapped to d.

[0020] For example, x1=150, y1=50, x2=220, y2=255; that is, pixels with grayscale values ​​less than 150 are mapped to 50, and pixels with grayscale values ​​between 150 and 220 have their mapped grayscales increase with the curve, and pixels with grayscale values ​​greater than 220 are mapped to 255.

[0021] Furthermore, the initial value of the accumulated variable j is 1, and from x1 to x2, as the grayscale value increases by 1, the j value accumulates by 1.

[0022] Further, the step 4) is specifically as follows:

[0023] First, define the curve parameter array. Each element corresponds to the y coordinate of a point on the curve. The x coordinate defaults to 0 to 1, which is mapped to the pixel value of 0 to y. max scope;

[0024] Accept the pixel value to be adjusted and the curve parameter array as input; call the interp function of the numpy library to interpolate the input pixel value according to the curve defined by formula (1) to obtain the target pixel value; call the clip function to limit the interpolated pixel value to 0 to y max The result is converted to an 8-bit unsigned integer within the valid range, ensuring that the result is suitable for image data.

[0025] The present invention also claims protection for an image contrast enhancement system, comprising a nonlinear function module and a grayscale mapping module, which performs local contrast enhancement for the grayscale distribution of specific feature points or regions in an image, and provides different degrees of contrast stretching or compression for pixel values ​​of different grayscales;

[0026] The nonlinear function module includes image grayscale, grayscale histogram calculation and nonlinear function formula calculation;

[0027] The grayscale mapping module specifically includes image digitization, pixel interpolation calculation, and grayscale mapping;

[0028] The system achieves image contrast enhancement through the above-mentioned image contrast enhancement method.

[0029] The present invention also claims protection for an image contrast enhancement device, comprising: at least one memory and at least one processor;

[0030] The at least one memory is used to store a machine-readable program;

[0031] The at least one processor is used to call the machine-readable program to implement the above method.

[0032] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which, when executed by a processor, causes the processor to perform the above method.

[0033] Compared with the prior art, the image contrast enhancement method and system of the present invention have the following beneficial effects:

[0034] 1. Significantly improve the contrast of the image, making the image details more clearly visible.

[0035] 2. Enhance the visual effects of images and improve their adaptability in different display environments.

[0036] 3. A simple and efficient image contrast adjustment method is provided, which can be easily integrated into the existing image processing system.

[0037] 4. It is applicable to a variety of image processing scenarios, including medical imaging, satellite image analysis, video surveillance, etc., and can significantly improve the accuracy of image analysis and recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a flowchart of an image contrast enhancement method provided by an embodiment of the present invention;

[0039] Figure 2 is an original image to be processed and its corresponding grayscale histogram provided by an embodiment of the present invention;

[0040] Figure 3 is a grayscale curve function diagram provided by an embodiment of the present invention;

[0041] Figure 4 is a diagram illustrating the contrast enhancement image effect provided by an embodiment of the present invention;

[0042] Figure 5 The contrast enhancement image corresponding to different parameters provided by the embodiment of the present invention is shown in FIG. Figure I ;

[0043] Figure 6 The contrast enhancement image corresponding to different parameters provided by the embodiment of the present invention is shown in FIG. Figure II . DETAILED DESCRIPTION

[0044] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0045] The embodiment of the present invention provides an image contrast enhancement method, which performs local contrast enhancement on the grayscale distribution of specific feature points or regions in an image based on a nonlinear function and a grayscale mapping algorithm, and can provide different degrees of contrast stretching or compression for pixel values ​​of different grayscales. The method is suitable for a variety of image processing scenarios, including medical imaging, satellite image analysis, video surveillance, etc., and can significantly improve the accuracy of image analysis and recognition.

[0046] The nonlinear function specifically includes image grayscale, grayscale histogram design, and nonlinear mapping of image brightness values ​​using a nonlinear function formula;

[0047] The grayscale mapping algorithm specifically includes image digitization, pixel interpolation calculation, and grayscale mapping.

[0048] This method can enhance the contrast of multiple features of an image according to the grayscale range.

[0049] The specific implementation steps of this method are as follows:

[0050] 1. Convert the image to a grayscale image, and then calculate the histogram of the grayscale image to reveal the distribution of grayscale values ​​in the image. Figure 2 Shown is the original image and its corresponding grayscale histogram showing the distribution of grayscale values ​​in the image.

[0051] The grayscale histogram consists of two coordinate systems, in which the x-axis and y-axis represent grayscale values, and are used to show the distribution of grayscale values ​​in the image; in the other coordinate system, the x-axis represents the grayscale value, and the y-axis represents the number of pixels corresponding to the grayscale value, and is used to show the mapping of image pixel values, such as Figure 3 shown.

[0052] 2. Define a nonlinear function to perform nonlinear mapping on the brightness value of the image according to the preset parameters x1, x2, y1, y2. The nonlinear function is defined as shown in formula (1):

[0053]

[0054] Here, j is an accumulator variable used to generate linearly varying parameters between x1 and x2.

[0055] The initial value of the accumulated variable j is 1. From x1 to x2, as the grayscale value increases by 1, the j value accumulates by 1.

[0056] 3. Set the grayscale curve parameters and adjust the slope of the curve within the preset grayscale range to enhance the contrast of specific grayscale areas of the image.

[0057] Assume x1 = 150, y1 = 50, x2 = 220, y2 = 255; then the meaning is: pixels with grayscale values ​​less than 150 are mapped to 50, pixels with grayscale values ​​between 150 and 220, the mapped grayscale increases with the curve, and pixels with grayscale values ​​greater than 220 are mapped to 255. The nonlinear function curve is as follows Figure 3 shown.

[0058] 4. Apply nonlinear functions to transform the image numerical array to obtain the image numerical array after contrast enhancement. The details are as follows:

[0059] First, define the curve parameter array. Each element corresponds to the y coordinate of a point on the curve. The x coordinate defaults to 0 to 1, which is mapped to the pixel value range of 0 to 255.

[0060] Accepts as input an array of pixel values ​​to be adjusted and curve parameters.

[0061] The interp function of the numpy library is called to interpolate the input pixel values ​​according to the curve defined by formula (1) to obtain the target pixel values. The clip function is called to limit the interpolated pixel values ​​to the valid range of 0 to 255 and convert them to 8-bit unsigned integer type to ensure that the result is suitable for image data.

[0062] Will Figure 2 Original image application in Figure 3After the grayscale curve function parameters are shown, the following is generated: Figure 4 Contrast enhanced image shown.

[0063] Under different grayscale curve functions, the image presents different effects, such as Figure 5 and Figure 6 As shown, the left side is the curve function, and the right side is the corresponding contrast enhancement image effect diagram.

[0064] The embodiment of the present invention further provides an image contrast enhancement system, comprising a nonlinear function module and a grayscale mapping module, which performs local contrast enhancement for the grayscale distribution of specific feature points or regions in an image, and provides different degrees of contrast stretching or compression for pixel values ​​of different grayscales;

[0065] The nonlinear function module includes image grayscale, grayscale histogram calculation and nonlinear function formula calculation;

[0066] The grayscale mapping module specifically includes image digitization, pixel interpolation calculation, and grayscale mapping.

[0067] The system realizes image contrast enhancement through the image contrast enhancement method described in the above embodiment.

[0068] The implementation steps are as follows:

[0069] 1. Convert the image into a grayscale image, and then calculate the histogram of the resulting grayscale image to reveal the distribution of grayscale values ​​in the image.

[0070] The grayscale histogram consists of two coordinate systems, in which the x-axis and y-axis represent grayscale values, and are used to show the distribution of grayscale values ​​in the image; in the other coordinate system, the x-axis represents the grayscale value, and the y-axis represents the number of pixels corresponding to the grayscale value, and is used to show the mapping of image pixel values, such as Figure 3 shown.

[0071] 2. Define a nonlinear function to perform nonlinear mapping on the brightness value of the image according to the preset parameters x1, x2, y1, y2. The nonlinear function is defined as shown in formula (1):

[0072]

[0073] Here, j is an accumulator variable used to generate linearly varying parameters between x1 and x2.

[0074] The initial value of the accumulated variable j is 1. From x1 to x2, as the grayscale value increases by 1, the j value accumulates by 1.

[0075] 3. Set the grayscale curve parameters and adjust the slope of the curve within the preset grayscale range to enhance the contrast of specific grayscale areas of the image.

[0076] Assume x1 = 150, y1 = 50, x2 = 220, y2 = 255; then the meaning is: pixels with grayscale values ​​less than 150 are mapped to 50, pixels with grayscale values ​​between 150 and 220, the mapped grayscale increases with the curve, and pixels with grayscale values ​​greater than 220 are mapped to 255. The nonlinear function curve is as follows Figure 3 shown.

[0077] 4. Apply nonlinear functions to transform the image numerical array to obtain the image numerical array after contrast enhancement. The details are as follows:

[0078] First, define the curve parameter array. Each element corresponds to the y coordinate of a point on the curve. The x coordinate defaults to 0 to 1, which is mapped to the pixel value range of 0 to 255.

[0079] Accepts as input an array of pixel values ​​to be adjusted and curve parameters.

[0080] The interp function of the numpy library is called to interpolate the input pixel values ​​according to the curve defined by formula (1) to obtain the target pixel values. The clip function is called to limit the interpolated pixel values ​​to the valid range of 0 to 255 and convert them to 8-bit unsigned integer type to ensure that the result is suitable for image data.

[0081] Will Figure 2 Original image application in Figure 3 After the grayscale curve function parameters are shown, the following is generated: Figure 4 Contrast enhanced image shown.

[0082] An embodiment of the present invention further provides an image contrast enhancement device, comprising: at least one memory and at least one processor;

[0083] The at least one memory is used to store a machine-readable program;

[0084] The at least one processor is used to call the machine-readable program to implement the image contrast enhancement method described in the above embodiment.

[0085] The embodiment of the present invention further provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the image contrast enhancement method described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code that implements the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.

[0086] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0087] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0088] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0089] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0090] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A method for enhancing image contrast, characterized in that: Based on nonlinear functions and grayscale mapping algorithms, local contrast enhancement is performed for the grayscale distribution of specific feature points or regions in the image, and different degrees of contrast stretching or compression can be provided for pixel values ​​of different grayscales. The nonlinear function specifically includes image grayscale, grayscale histogram design, and nonlinear mapping of image brightness values ​​using a nonlinear function formula; The grayscale mapping algorithm specifically includes image digitization, pixel interpolation calculation, and grayscale mapping.

2. The image contrast enhancement method according to claim 1, characterized in that: The implementation steps of this method include: 1) Convert the image into a grayscale image, and then calculate the histogram of the obtained grayscale image to reveal the distribution of grayscale values ​​in the image; 2) Define a nonlinear function formula and perform nonlinear mapping on the brightness value of the image according to preset parameters; 3) Setting grayscale curve parameters, by adjusting the slope of the curve within a preset grayscale range, to achieve contrast enhancement of a specific grayscale area of ​​the image; 4) Apply a nonlinear function to transform the image numerical array to obtain a contrast-enhanced image numerical array.

3. The image contrast enhancement method according to claim 1 or 2, characterized in that: The grayscale histogram includes two coordinate systems, wherein the x-axes of the two coordinate systems represent grayscale values, and the y-axes represent the number of pixels corresponding to the grayscale value and the grayscale value, respectively.

4. The image contrast enhancement method according to claim 3, characterized in that: The nonlinear function is defined as shown in formula (1): Here, j is an accumulator variable used to generate linearly varying parameters between x1 and x2.

5. The image contrast enhancement method according to claim 4, characterized in that: Assume x1=a, y1=c, x2=b, y2=d, which means that pixels with grayscale values ​​less than a are mapped to c, pixels with grayscale values ​​between a and b have their mapped grayscales increase with the curve, and pixels with grayscale values ​​greater than b are mapped to d.

6. The image contrast enhancement method according to claim 4, characterized in that: The initial value of the accumulated variable j is 1. From x1 to x2, as the grayscale value increases by 1, the j value accumulates by 1.

7. The image contrast enhancement method according to claim 5, characterized in that: The step 4) is specifically as follows: First, define the curve parameter array. Each element corresponds to the y coordinate of a point on the curve. The x coordinate defaults to 0 to 1, which is mapped to the pixel value of 0 to y. max scope; Accept the pixel value to be adjusted and the curve parameter array as input; call the interp function of the numpy library to interpolate the input pixel value according to the curve defined by formula (1) to obtain the target pixel value; Call the clip function to limit the interpolated pixel values ​​to 0 to y max The result is converted to an 8-bit unsigned integer within the valid range, ensuring that the result is suitable for image data.

8. An image contrast enhancement system, characterized in that: It includes a nonlinear function module and a grayscale mapping module, which performs local contrast enhancement for the grayscale distribution of specific feature points or regions in the image, and provides different degrees of contrast stretching or compression for pixel values ​​of different grayscales; The nonlinear function module includes image grayscale, grayscale histogram calculation and nonlinear function formula calculation; The grayscale mapping module specifically includes image digitization, pixel interpolation calculation, and grayscale mapping; The system realizes image contrast enhancement through the image contrast enhancement method described in any one of claims 1 to 7.

9. An image contrast enhancement device, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 7.

10. A computer-readable medium, characterized in that The computer readable medium stores computer instructions, which, when executed by a processor, cause the processor to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • White balance and dark primary color adaptive histogram underwater image enhancement method

    CN106897972A

  • Fingerprint image enhancement method

    CN111079689A

  • Image processing method and device, computer readable storage medium and electronic equipment

    CN115375592A

  • Method and image processing device for image dynamic range compression with local contrast enhancement

    US20140254928A1