Image enhancement method and device based on bilateral cumulative probability segmentation
Through the image enhancement method of bilateral cumulative probability segmentation, the problem of inability to adjust image contrast and information entropy in the prior art is solved, and the flexible selection of contrast and information amount is realized, and the applicability of image processing is enhanced.
Patent Information
- Application Number
- CN202010322907.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-22
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2040-04-22
AI Technical Summary
Existing histogram-based image processing methods cannot adjust the contrast and information entropy of images while maintaining brightness, resulting in inapplicability in some application areas.
The image enhancement method of bilateral cumulative probability segmentation is adopted. By calculating the histogram and cumulative probability of the input image, the image pixels are segmented and the contrast and information entropy are adjusted according to the parameters, so as to achieve controllability of contrast and information entropy.
This method can selectively adjust the contrast and information volume of images according to parameters, reduce grayscale merging, and provide higher flexibility. It is more suitable for a variety of application needs than classic histogram equalization processing.
Smart Images

Figure CN113112433B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image contrast enhancement, and in particular to an image enhancement method and device for bilateral cumulative probability segmentation with controllable contrast and information entropy. Background Art
[0002] There are many image processing methods based on histogram technology, among which the most classic one is the global histogram equalization processing method, which is one of the commonly used methods for digital image enhancement. Although the algorithm is simple, it is not suitable for application in some fields because the average brightness difference between the output and input images is large, and the contrast and information size of the enhanced processed image are fixed and cannot be selectively adjusted. Therefore, it is an urgent problem to design a histogram enhancement technology that can adjust the contrast and information entropy of the enhanced image while maintaining the brightness. Summary of the invention
[0003] The present invention aims to provide an image enhancement method and device for bilateral cumulative probability segmentation that overcomes one of the above problems or at least partially solves any of the above problems.
[0004] To achieve the above object, the technical solution of the present invention is specifically implemented as follows:
[0005] On one hand, the present invention provides an image enhancement method for bilateral cumulative probability segmentation, comprising: S1, obtaining a histogram calculation formula, calculating a histogram h(i), a probability p(i) and a cumulative probability cdfp(i) of an input image I, wherein the histogram calculation formula includes: Where i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray level variable; S2, set the initial value of the segmentation cumulative probability cdfPR, set the variable array hx of the segmentation histogram with a length of N, set the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, and set the initial value of the segmentation variable px, where the segmentation variable px varies in the range of [0,1]; S3, cyclically calculate the first cumulative probability cdfp1 from the first preset direction of the probability p(i) of the input image I, where the calculation formula of the first cumulative probability cdfp1 is: The loop variable i=1:N, when the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, the loop is exited, and the segmented first histogram array hx1 is recorded at the same time; S4, the second cumulative probability cdfp2 is calculated from the second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is: Loop variable i=N:-1:1, when the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented second histogram array hx2, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction; S5, update the variable array hx, where the variable array hx=hx1+hx2, update the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, where Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px. If the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value, and return to step S3. Otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained, in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and execute step S6; S6, calculate the remaining third histogram array hx3, wherein hx3=h-hx1-hx2; S7, remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set the common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the gray value indexes of the corresponding histograms respectively;
[0006] S8, calculate the new gray value of the common processing array Hx according to the following formula:
[0007] Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, P1 is the adjustment parameter of image details, brightness and contrast; S9, outputs the new enhanced image imageout.
[0008] The value range of P1 is [0,1].
[0009] Among them, P1=0.1.
[0010] The first preset direction is from left to right, and the second preset direction is from right to left.
[0011] Among them, the initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio of the total number of pixels of the segmented image to the total number of pixels of the original image p0 is 0, the initial value of the segmentation variable px is 0.5, and the preset value is 0.01.
[0012] Another aspect of the present invention provides an image enhancement device for bilateral cumulative probability segmentation, comprising: a first calculation module, used to obtain a histogram calculation formula, calculate the histogram h(i), probability p(i) and cumulative probability cdfp(i) of the input image I, wherein the histogram calculation formula includes: Wherein, i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray level variable; a setting module is used to set the initial value of the segmentation cumulative probability cdfPR, set the variable array hx of the segmentation histogram with a length of N, set the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, and set the initial value of the segmentation variable px, wherein the segmentation variable px varies in the range of [0,1]; a second calculation module is used to cyclically calculate the first cumulative probability cdfp1 from the first preset direction of the probability p(i) of the input image I, wherein the calculation formula of the first cumulative probability cdfp1 is: The loop variable i=1:N, when the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, the loop is exited, and the segmented first histogram array hx1 is recorded at the same time; the third calculation module is used to cyclically calculate the second cumulative probability cdfp2 from the second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is:
[0013] The loop variable i=N:-1:1, when the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, the loop is exited, and the segmented second histogram array hx2 is recorded at the same time, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction; an updating module is used to update the variable array hx, where the variable array hx=hx1+hx2, and the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is updated, where Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px. If the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value, and notify the second and third calculation modules. Otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained, in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and notify the fourth calculation module. ; The fourth calculation module is used to calculate the remaining third histogram array hx3, where hx3 = h-hx1-hx2; the placement module is used to remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set the common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the gray value index of the corresponding histogram respectively; the fifth calculation module is used to calculate the new gray value of the common processing array Hx according to the following formula:
[0014] Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, P1 is the adjustment parameter of image details, brightness and contrast; the output module is used to output the new enhanced image imageout.
[0015] The value range of P1 is [0,1].
[0016] Among them, P1=0.1.
[0017] The first preset direction is from left to right, and the second preset direction is from right to left.
[0018] Among them, the initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio of the total number of pixels of the segmented image to the total number of pixels of the original image p0 is 0, the initial value of the segmentation variable px is 0.5, and the preset value is 0.01.
[0019] It can be seen that the image enhancement method and device of bilateral cumulative probability segmentation provided by the embodiment of the present invention provide an image enhancement scheme of bilateral cumulative probability segmentation with controllable contrast and information entropy, and can freely select an enhanced image with suitable contrast and information amount according to the parameter size. The method is simple and effective, can reduce grayscale merging, and the contrast and information entropy can be adjusted, which is more flexible than classic histogram equalization enhancement. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. The accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0021] Figure 1 A flowchart of an image enhancement method for bilateral cumulative probability segmentation provided by an embodiment of the present invention;
[0022] Figure 2 A schematic diagram of the structure of an image enhancement device for bilateral cumulative probability segmentation provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of a contrast ratio and information entropy variation curve provided in an embodiment of the present invention;
[0024] Figure 4 A low-contrast image provided by an embodiment of the present invention - Einstein schematic diagram;
[0025] Figure 5 A low-brightness image-landscape schematic diagram provided by an embodiment of the present invention;
[0026] Figure 6 A schematic diagram of a normal brightness image provided by an embodiment of the present invention;
[0027] Figure 7 A schematic diagram of a plum blossom, a high-brightness image, provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0029] Figure 1 FIG. 1 is a flowchart of an image enhancement method for bilateral cumulative probability segmentation provided by an embodiment of the present invention, see Figure 1 The image enhancement method of bilateral cumulative probability segmentation provided by the embodiment of the present invention includes:
[0030] S1, obtain a histogram calculation formula, calculate the histogram h(i), probability p(i) and cumulative probability cdfp(i) of the input image I, wherein the histogram calculation formula includes:
[0031] Among them, i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray level variable.
[0032] Specifically, using the existing histogram probability and cumulative probability formula: and Calculate the histogram probability p(i) and the cumulative probability cdfp(i) respectively.
[0033] S2, sets the initial value of the segmentation cumulative probability cdfPR, sets the variable array hx of the segmentation histogram with a length of N, sets the initial value p0 of the ratio of the total number of pixels of the segmented image to the total number of pixels of the original image, and sets the initial value of the segmentation variable px, where the segmentation variable px varies in the range [0,1].
[0034] Specifically, in order to facilitate subsequent calculations, the initial value of the segmentation cumulative probability cdfPR is set in advance, the variable array hx of the segmentation histogram length is set to N, the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is set, and the initial value of the segmentation variable px is set.
[0035] As an optional implementation of the embodiment of the present invention, the initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio of the total number of pixels of the segmented image to the total number of pixels of the original image p0 is 0, and the initial value of the segmentation variable px is 0.5. That is, in the specific implementation, the initial value of the segmentation cumulative probability cdfPR can be set to 0.01, the segmentation histogram can be set to a variable array hx(256,1) of length 256, and the ratio of the total number of pixels of the segmented image to the total number of pixels of the original image can be set, that is, The initial value p0=0, and the initial value of the segmentation variable px=0.5 can be set.
[0036] S3, cyclically calculating the first cumulative probability cdfp1 from the first preset direction of the probability p(i) of the input image I, wherein the calculation formula of the first cumulative probability cdfp1 is: The loop variable i=1:N. When the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, the loop is exited and the segmented first histogram array hx1 is recorded.
[0037] As an optional implementation of the embodiment of the present invention, the first preset direction is from left to right. In a specific implementation, the cumulative probability cdfp1 is calculated cyclically from the left side of the input image probability histogram p(i) to the right side, The loop variable i=1:256. When the condition cdfp1>cdfPR is met, the loop is exited and the segmented histogram array hx1(256,1) is recorded.
[0038] S4, cyclically calculating the second cumulative probability cdfp2 from the second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is: The loop variable i=N:-1:1. When the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, the loop is exited and the segmented second histogram array hx2 is recorded, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction.
[0039] As an optional implementation of the embodiment of the present invention, the second preset direction is from right to left. In a specific implementation, the cumulative probability cdfp2 is calculated cyclically from the right side of the input image probability histogram p(i) to the left side, The loop variable i=256:-1:1. When the condition cdfp2>cdfPR is met, the loop is exited and the segmented histogram array hx2(256,1) is recorded.
[0040] S5, update the variable array hx, where the variable array hx = hx1 + hx2, update the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, where Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px. If the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value and return to step S3; otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and execute step S6.
[0041] As an optional implementation of the embodiment of the present invention, the preset value is 0.01.
[0042] In the specific implementation, update hx=hx1+hx2, The judgment condition is p0<px. If p0 is less than px, then cdfPR=cdfPR+0.01, and the process returns to steps S3 and S4 to continue the calculation. Otherwise, the loop operation is stopped.
[0043] S6, calculating the remaining third histogram array hx3, where hx3=h-hx1-hx2.
[0044] Specifically, through the above steps S3-S5, the segmentation histograms hx1 and hx2 that meet the conditions are found, and then the remaining histogram hx3=h-hx1-hx2 is calculated.
[0045] S7, remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set the common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the grayscale value indexes of the corresponding histograms.
[0046] Specifically, all non-zero elements of hx1, hx2 and hx3 are removed, and the common processing arrays Hx and idx are set, that is, Hx=hx1(hx1>0), idx=find(hx1>0), Hx=hx2(hx2>0), idx=find(hx2>0), Hx=hx3(hx3>0), idx=find(hx3>0), and idx respectively places the gray value indexes of the corresponding histograms.
[0047] S8, calculate the new gray value of the common processing array Hx according to the following formula:
[0048]
[0049] Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, and P1 is the adjustment parameter of image details, brightness and contrast.
[0050] As an optional implementation of the embodiment of the present invention, the value range of P1 is [0,1]. Preferably, P1=0.1. P1 can be changed as needed, and P1 can finely adjust the contrast and information entropy of the image. In the actual calculation process, selecting 0.1 can simplify the calculation and increase the calculation speed.
[0051] S9, output a new enhanced image imageout.
[0052] It can be seen that the image enhancement method of bilateral cumulative probability segmentation provided by the embodiment of the present invention provides an image enhancement scheme of bilateral cumulative probability segmentation with controllable contrast and information entropy, and can freely select enhanced images with suitable contrast and information amount according to the parameter size. The method is simple and effective, can reduce grayscale merging, and the contrast and information entropy can be adjusted, which is more flexible than classic histogram equalization enhancement.
[0053] Figure 2 FIG. 1 is a schematic diagram showing the structure of an image enhancement device for bilateral cumulative probability segmentation provided by an embodiment of the present invention. The image enhancement device for bilateral cumulative probability segmentation provided by an embodiment of the present invention is applied to the above method. The following is a general description of the structure of the image enhancement device for bilateral cumulative probability segmentation. For other matters not covered, please refer to the relevant description in the above image enhancement method for bilateral cumulative probability segmentation. Figure 2The image enhancement device of bilateral cumulative probability segmentation provided by the embodiment of the present invention comprises:
[0054] The first calculation module is used to obtain a histogram calculation formula to calculate the histogram h(i), probability p(i) and cumulative probability cdfp(i) of the input image I, wherein the histogram calculation formula includes:
[0055] Among them, i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray variable;
[0056] The setting module is used to set the initial value of the segmentation cumulative probability cdfPR, set the variable array hx of the segmentation histogram with a length of N, set the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, and set the initial value of the segmentation variable px, where the segmentation variable px varies in the range of [0,1];
[0057] The second calculation module is used to cyclically calculate the first cumulative probability cdfp1 from the first preset direction of the probability p(i) of the input image I, wherein the calculation formula of the first cumulative probability cdfp1 is: Loop variable i=1:N, when the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the first segmentation histogram array hx1;
[0058] The third calculation module is used to cyclically calculate the second cumulative probability cdfp2 from the second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is: Loop variable i=N:-1:1, when the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented second histogram array hx2 at the same time, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction;
[0059] An updating module is used to update the variable array hx, where the variable array hx=hx1+hx2, and to update the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, where Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px. If the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value, and notify the second calculation module and the third calculation module. Otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained, in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and notify the fourth calculation module.
[0060] A fourth calculation module, used for calculating the remaining third histogram array hx3, wherein hx3=h-hx1-hx2;
[0061] A placement module is used to remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set the common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the grayscale value index of the corresponding histogram respectively;
[0062] The fifth calculation module is used to calculate the new gray value of the common processing array Hx according to the following formula:
[0063]
[0064] Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, and P1 is the adjustment parameter of image detail, brightness and contrast;
[0065] The output module is used to output a new enhanced image imageout.
[0066] As an optional implementation of the embodiment of the present invention, the value range of P1 is [0, 1].
[0067] As an optional implementation of the embodiment of the present invention, P1=0.1.
[0068] As an optional implementation manner of the embodiment of the present invention, the first preset direction is from left to right, and the second preset direction is from right to left.
[0069] As an optional implementation of an embodiment of the present invention, the initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is 0, the initial value of the segmentation variable px is 0.5, and the preset value is 0.01.
[0070] It can be seen that the image enhancement device of bilateral cumulative probability segmentation provided by the embodiment of the present invention provides an image enhancement scheme of bilateral cumulative probability segmentation with controllable contrast and information entropy, and can freely select enhanced images with suitable contrast and information amount according to the parameter size. The method is simple and effective, can reduce grayscale merging, and the contrast and information entropy can be adjusted, which is more flexible than classic histogram equalization enhancement.
[0071] The following is a specific example to further illustrate the image enhancement method of bilateral cumulative probability segmentation under brightness preservation provided by an embodiment of the present invention:
[0072] In the implementation process of the invention, when P1=0.1, the contrast and information entropy change curve is a curve diagram showing the change of the average value of the contrast and information entropy (detail information amount) of 20 test images with px between [0,1], such as Figure 3 As shown in the figure. Other effect pictures are enhanced images with P1=0.1 and px=0.5, such as Figure 4 , 5 , 6, and 7.
[0073] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A bilateral cumulative probability segmentation image enhancement method, characterized in that: include: S1, obtaining a histogram calculation formula, calculating the histogram h(i), probability p(i) and cumulative probability cdfp(i) of the input image I, wherein the histogram calculation formula includes: Among them, i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray variable; S2, set the initial value of the segmentation cumulative probability cdfPR, set the variable array hx of the segmentation histogram with a length of N, set the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, and set the initial value of the segmentation variable px, wherein the segmentation variable px varies in the range [0,1]; S3, cyclically calculating a first cumulative probability cdfp1 from a first preset direction of the probability p(i) of the input image I, wherein the calculation formula of the first cumulative probability cdfp1 is: Loop variable i=1:N, when the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented first histogram array hx1; S4, cyclically calculating a second cumulative probability cdfp2 from a second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is: Loop variable i=N:-1:1, when the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented second histogram array hx2 at the same time, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction; S5, update the variable array hx, wherein the variable array hx=hx1+hx2, update the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, wherein, Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px. If the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value, and return to step S3. Otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and execute step S6. S6, calculating the remaining third histogram array hx3, where hx3=h-hx1-hx2; S7, remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set a common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the grayscale value indexes of the corresponding histograms respectively; S8, calculating a new grayscale value for the common processing array Hx according to the following formula: Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, and P1 is the adjustment parameter of image detail, brightness and contrast; S9, output a new enhanced image imageout.
2. The method according to claim 1, characterized in that The value range of P1 is [0,1].
3. The method according to claim 2, characterized in that The P1=0.
1.
4. The method according to claim 1, characterized in that: The first preset direction is from left to right, and the second preset direction is from right to left.
5. The method according to claim 1, characterized in that The initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is 0, the initial value of the segmentation variable px is 0.5, and the preset value is 0.
01.
6. An image enhancement device for bilateral cumulative probability segmentation, characterized in that: include: The acquisition module is used to obtain a histogram calculation formula to calculate the histogram h(i), probability p(i) and cumulative probability cdfp(i) of the input image I, wherein the histogram calculation formula includes: Among them, i is the gray level, h is the frequency of each gray level, x0 is the upper limit of the image gray level, and k is the image gray variable; A setting module is used to set the initial value of the segmentation cumulative probability cdfPR, set the variable array hx of the segmentation histogram with a length of N, set the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, and set the initial value of the segmentation variable px, wherein the segmentation variable px varies in the range of [0,1]; The second calculation module is used to cyclically calculate the first cumulative probability cdfp1 from the first preset direction of the probability p(i) of the input image I, wherein the calculation formula of the first cumulative probability cdfp1 is: Loop variable i=1:N, when the first cumulative probability cdfp1 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented first histogram array hx1; The third calculation module is used to cyclically calculate the second cumulative probability cdfp2 from the second preset direction of the probability p(i) of the input image I, wherein the calculation formula of the second cumulative probability cdfp2 is: Loop variable i=N:-1:1, when the second cumulative probability cdfp2 is greater than the initial value of the segmentation cumulative probability cdfPR, exit the loop and record the segmented second histogram array hx2 at the same time, where L is the total number of gray levels, and the first preset direction is opposite to the second preset direction; An updating module is used to update the variable array hx, wherein the variable array hx=hx1+hx2, and to update the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image, wherein Determine whether the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px; if the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is less than the initial value of the segmentation variable px, set cdfPR=cdfPR+preset value, and notify the second calculation module and the third calculation module; otherwise, stop the loop operation until the first histogram array hx1 and the second histogram array hx2 are obtained, in which the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is greater than or equal to the initial value of the segmentation variable px, and notify the fourth calculation module; The fourth calculation module is used to calculate the remaining third histogram array hx3, where hx3=h-hx1-hx2; A placement module, used to remove all non-zero elements of the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, set a common processing array Hx to place the first histogram array hx1, the second histogram array hx2 and the third histogram array hx3, and set idx to place the gray value indexes of the corresponding histograms respectively; The fifth calculation module is used to calculate the new gray value of the common processing array Hx according to the following formula: Where i=1...length(Hx), PX, CPX are the probability and cumulative probability of the common processing array Hx respectively; f(i) is the new gray value of the original image, and P1 is the adjustment parameter of image detail, brightness and contrast; The output module is used to output a new enhanced image imageout.
7. The device according to claim 6, characterized in that The value range of P1 is [0,1].
8. The device according to claim 7, characterized in that The P1=0.
1.
9. The device according to claim 6, characterized in that The first preset direction is from left to right, and the second preset direction is from right to left.
10. The device according to claim 6, characterized in that The initial value of the segmentation cumulative probability cdfPR is 0.01, the histogram length N is 256, the initial value of the ratio p0 of the total number of pixels of the segmented image to the total number of pixels of the original image is 0, the initial value of the segmentation variable px is 0.5, and the preset value is 0.01.
Citation Information
Patent Citations
Histogram balanced interpolation-based image enhancement method and system
CN105260999A
Secondary histogram equalization image enhancement method and system of histogram correction
CN105608685A
