CN110738603A - image gray scale processing method, device, computer equipment and storage medium - Google Patents
image gray scale processing method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110738603A CN110738603A CN201810791972.5A CN201810791972A CN110738603A CN 110738603 A CN110738603 A CN 110738603A CN 201810791972 A CN201810791972 A CN 201810791972A CN 110738603 A CN110738603 A CN 110738603A
- Authority
- CN
- China
- Prior art keywords
- gray
- value
- matrix
- row
- column
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 21
- 239000011159 matrix material Substances 0.000 claims abstract description 188
- 238000009826 distribution Methods 0.000 claims abstract description 105
- 238000000034 method Methods 0.000 claims abstract description 25
- 238000012545 processing Methods 0.000 claims description 21
- 230000015654 memory Effects 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 13
- 238000012937 correction Methods 0.000 description 11
- 238000003466 welding Methods 0.000 description 5
- 229910001148 Al-Li alloy Inorganic materials 0.000 description 3
- JFBZPFYRPYOZCQ-UHFFFAOYSA-N [Li].[Al] Chemical compound [Li].[Al] JFBZPFYRPYOZCQ-UHFFFAOYSA-N 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 239000001989 lithium alloy Substances 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 241001270131 Agaricus moelleri Species 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 230000001174 ascending effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/80—Geometric correction
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/90—Dynamic range modification of images or parts thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10116—X-ray image
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
The invention discloses image gray processing methods and devices, wherein the method comprises the steps of obtaining gray values of pixels in a target image to obtain a gray matrix, obtaining a balanced array according to the distribution trend of row/column gray in the gray matrix, and correcting the gray matrix according to the balanced array to obtain the gray matrix after the target image is corrected.
Description
Technical Field
The embodiment of the invention relates to an image processing technology, in particular to image gray scale processing methods and devices, a computer device and a storage medium.
Background
At present, the welding blowholes can be detected by scanning the welding positions through X-rays to obtain X-ray images, and if the welding blowholes exist, round dots with color darker than the color of the surroundings exist in the X-ray images, so the original points in the X-ray images can be identified through naked eyes or machines.
At present, the method for solving the uneven brightness of the X-ray image is mainly a histogram equalization method. The single histogram equalization method is to stretch the gray histogram of the X-ray image from a certain gray interval in a relatively concentrated manner, so that the gray histogram can be uniformly distributed in the whole gray range, thereby realizing the adjustment of the overall brightness of the X-ray image.
However, if the brightness of the X-ray image is adjusted to be bright as a whole, the too-dark area in the X-ray image becomes bright and clear, the too-bright area becomes brighter, and the too-bright area becomes unclear; conversely, if the brightness of the X-ray image is dimmed as a whole, the over-bright areas in the X-ray image become darker and clearer, and the over-dark areas continue to become darker, so that the over-dark areas become less clear.
Disclosure of Invention
The invention provides image gray processing methods, devices, computer equipment and storage media, which are used for achieving the purposes of balancing the contrast of an excessively dark area or an excessively bright area and increasing the definition of an image.
, an embodiment of the present invention provides methods for processing grayscale images, including:
acquiring a gray value of each pixel in a target image to obtain a gray matrix;
obtaining a balanced array according to the distribution trend of the row/column gray levels in the gray level matrix;
and correcting the gray matrix according to the balanced array to obtain the corrected gray matrix of the target image.
Optionally, the distribution trend of the elements in the balanced array is opposite to the row/column gray distribution trend.
Optionally, the obtaining a balanced array according to the row/column gray distribution trend in the gray matrix includes:
fitting to obtain a row/column gray distribution line according to the gray value sum of each row/column in the gray matrix;
respectively substituting the gray value and the serial number into the row/column gray distribution line to obtain a undetermined value of the gray value of each row/column;
and dividing the mean value of the gray value sum by each row/column gray undetermined value to obtain each numerical value in the balanced array.
Optionally, the dividing the mean of the gray value sum by each undetermined row/column gray value to obtain each value in the balanced array includes:
calculating values in the balanced array according to an th formula, the th formula comprising:
wherein, b isjIs the jth value in said equalized array b (n), said j being a positive integer less than or equal to said n;
when said a isiIs the sum of the gray values of the ith row in the gray matrix, n is the number of rows in the gray matrix, andis the sum of the gray values of the respective rows in the gray matrix, the'jIs the gray undetermined value of the jth row, and b (n) is an equalization array for the row; when said a isiIs the sum of the gray values of the ith column in the gray matrix, the n is the grayNumber of columns of degree matrix, saidIs the sum of gray values of each column in the gray matrix, the'jIs the j-th column gray pending value, and b (n) is the equalization array for the column.
Optionally, the modifying the gray-scale matrix according to the balanced array to obtain the modified gray-scale matrix of the target image includes:
and multiplying the gray value in the gray matrix by the numerical value of the corresponding balanced array to obtain the corrected gray value.
Optionally, when b (n) is an equalizing array for a row, the step of multiplying the gray value in the gray matrix by the value of the corresponding equalizing array to obtain the corrected gray value includes:
calculating the corrected gray value according to a second formula, wherein the second formula is as follows:
g′pq=gpqbp;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b ispIs the p-th value in (n) of said b; the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
Optionally, when b (n) is a column-oriented equalization array, the step of multiplying the gray value in the gray matrix by the numerical value of the corresponding equalization array to obtain the corrected gray value includes:
calculating the corrected gray value according to a third formula, wherein the third formula is as follows:
g′pq=gpqbq;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b isqIs the value of the qth of said b (n);the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
In a second aspect, an embodiment of the present invention further provides kinds of image grayscale processing apparatuses, including:
the acquisition module is used for acquiring the gray value of each pixel in the target image to obtain a gray matrix;
the processing module is used for obtaining a balanced array according to the row/column gray distribution trend in the gray matrix;
and the correcting module is used for correcting the gray matrix according to the balanced array to obtain the corrected gray matrix of the target image.
In a third aspect, an embodiment of the present invention further provides computer apparatuses, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the image grayscale processing method when executing the computer program.
In a fourth aspect, the embodiment of the present invention further provides computer-readable storage media, on which a computer program is stored, and the computer program, when executed by a processor, implements the image grayscale processing method described above.
According to the invention, the balanced array is obtained through the row/column gray distribution trend in the gray matrix, and the balanced array can balance the row/column gray distribution trend in the gray matrix to balance the gray value distribution in the gray matrix, so that the brightness of an over-dark area is improved, and the brightness of an over-bright area is reduced, therefore, the problem of uneven brightness distribution of a target image is solved, and the effect of increasing the definition of the target image is realized
Drawings
Fig. 1 is a flowchart of an image gray scale processing method provided by embodiment of the present invention;
fig. 2 is a flowchart of an image gray scale processing method provided by embodiment of the present invention;
fig. 3 is a flowchart of an image gray scale processing method provided by embodiment of the present invention;
fig. 4 is a flowchart of an image gray scale processing method according to a second embodiment of the present invention.
FIG. 5 is an X-ray image of an aluminum lithium alloy laser weld;
FIG. 6 is a distribution diagram of gray scale values and gray scale values of each column in the gray scale matrix according to the second embodiment of the present invention;
FIG. 7 is corrected X-ray images obtained according to the distribution trend of the column gray in the gray matrix according to the second embodiment of the present invention;
fig. 8 is a distribution diagram of gray scale values and gray scale values of each row in the gray scale matrix of times of corrections according to the second embodiment of the present invention;
FIG. 9 is a second corrected X-ray image according to the line gray distribution trend in the corrected gray matrix provided by the second embodiment of the present invention;
FIG. 10 is a corrected X-ray images obtained according to the line gray distribution trend in the gray matrix according to the second embodiment of the present invention;
fig. 11 is a distribution diagram of gray scale values and gray scale values of each row in the gray scale matrix according to the second embodiment of the present invention;
FIG. 12 is a second corrected X-ray image according to the distribution trend of column gray in corrected gray matrices, according to a second embodiment of the present invention;
FIG. 13 is a second corrected X-ray image according to the distribution trend of column gray in corrected gray matrices, according to a second embodiment of the present invention;
fig. 14 is a schematic structural diagram of an image gray scale processing apparatus according to a third embodiment of the present invention;
fig. 15 is a schematic structural diagram of an image gray scale processing apparatus according to a third embodiment of the present invention;
fig. 16 is a schematic structural diagram of an image gray scale processing apparatus according to a third embodiment of the present invention;
fig. 17 is a schematic structural diagram of computer devices according to the fourth embodiment of the present invention.
Detailed Description
The present invention will now be described in further detail with reference to the drawings and examples, it being understood that the specific embodiments herein described are merely illustrative of and not restrictive on the broad invention, and it should be further noted that for the purposes of description, only some, but not all, of the structures associated with the present invention are shown in the drawings.
Example
Fig. 1 is a flowchart of an image grayscale processing method provided by embodiment of the present invention, and this embodiment is applicable to a case where an image is unclear due to uneven brightness of the image, as shown in fig. 1, this method may be executed by an image grayscale processing apparatus, and this apparatus is applied to a computer device, and specifically includes the following steps:
and step 110, acquiring the gray value of each pixel in the target image to obtain a gray matrix.
Here, the gradation value is a luminance difference of each pixel in the target image, and the gradation value ranges from 0 to 255, where 255 is white and 0 is black.
The method for acquiring the gray value of each pixel in the target image in the embodiment may include:
converting the RGB value of each pixel in the target image into a gray value, and forming a gray matrix of the target image by the gray value according to the arrangement sequence of the pixels. Here, the method of converting the RGB values into the gray values may include the following:
1. floating point algorithm, Gray ═ R0.3 + G0.59 + B0.11;
2. integer method Gray ═ (R30 + G59 + B11)/100
3. Average value method, Gray ═ (R + G + B)/3;
4. only green color Gray ═ G was taken.
The Gray is a Gray value of pixels in the target image, and the RGB values respectively represent a red value, a green value and a blue value of the pixel.
And step 120, obtaining a balanced array according to the distribution trend of the row/column gray levels in the gray level matrix.
The row/column gray distribution tendency includes a row gray distribution tendency or a column gray distribution tendency. Here, the row gradation distribution tendency is a gradation variation tendency of the target image in the up-down direction of the image, and the column gradation distribution tendency is a gradation variation tendency of the target image in the left-right direction of the image.
Further , the line gray distribution trend in this embodiment can be represented by the sum of gray values of rows in the gray matrix, and the column gray distribution trend can be represented by the sum of gray values of columns in the gray matrix.
Optionally, the gray distribution trend can also be represented by a row gray distribution line, and the row gray distribution line is obtained by fitting the gray value of each row in the gray matrix and the corresponding row sequence number.
Optionally, the gray distribution trend can also be characterized by a column gray distribution line, and the column gray distribution line is obtained by fitting the gray values of each columns in the gray matrix and the corresponding column serial numbers.
The equalization array is used for correcting elements in the gray matrix, so that the row/column gray distribution trend of the corrected gray matrix tends to be equalized. Here, according to the line gray distribution trend, the correction object of each element of the obtained balanced array is each gray value of the corresponding line in the gray matrix; according to the column gray distribution trend, each element of the obtained average value array is corrected to obtain each gray value of a corresponding column in the gray matrix.
And step 130, correcting the gray matrix according to the balanced array to obtain a corrected gray matrix of the target image.
The balance array can reduce the over-high gray value and the over-low gray value in the gray matrix, so that the gray value distribution of the corrected gray matrix is balanced, and the target image is also balanced in brightness.
According to the technical scheme of the embodiment, the balanced array is obtained through the row/column gray distribution trend in the gray matrix, and the balanced array can balance the row/column gray distribution trend in the gray matrix to enable the gray value distribution in the gray matrix to be balanced, so that the brightness of an over-dark area is improved, and the brightness of an over-bright area is reduced, and therefore the problem of uneven brightness distribution of a target image is solved, and the effect of increasing the definition of the target image is achieved.
On the basis of the technical scheme, the distribution trend of elements in the balanced array is opposite to the row/column gray distribution trend. Here, the elements in the equalization array are composed of two parts, which are the numerical value and the numerical sequence number, respectively.
Assuming that the distribution trend of the gray scale of the row is ascending order, the distribution trend of the elements of the corresponding equalizing array is descending order, so that each element of the equalizing array can restrain the gray scale value of the corresponding row, the gray scale value with larger value is smaller, and the gray scale value with smaller value is larger. The gray values of the intermediate size do not vary much so that all the gray value distributions are balanced.
On the basis of the above technical solution, step 120, obtaining an equilibrium array according to the row/column gray distribution trend in the gray matrix, may include:
calculating the mean value of the gray value sum according to the gray value sum of each row/column in the gray matrix; dividing the average value by the sum of the gray values of each row/column, and forming an equilibrium array by the obtained results.
For example, the sum of the gray scale values of the t-th row is the sum of the gray scale values of rows in the t-th row in the gray scale matrix, and similarly, the sum of the gray scale values of the t-th column is the sum of the gray scale values of columns in the t-th column in the gray scale matrix, and t is a positive integer.
For example, taking the calculation of the balanced array corresponding to the gray-level values of each column as an example, it is assumed that the sum of the gray-level values of each column of the gray-level matrix is c1, c2, … …, ch, respectively, where h is the number of columns of the gray-level matrix, the mean value f is (c1+ c2+ … … + ch)/n, and the balanced array is [ f/c1, f/c2, … …, f/cf ].
The method for calculating the balanced array is simple in operation, can quickly perform balanced processing on the target image, and can reduce the operation amount and the workload of the processor.
Fig. 2 is a flowchart of an image gray scale processing method according to an embodiment of the present invention, based on the foregoing technical solution, as shown in fig. 2, the step 120 of obtaining an equalized array according to a row/column gray scale distribution trend in a gray scale matrix may include:
and step 121, fitting to obtain a row/column gray distribution line according to the sum of the gray values of each row/column in the gray matrix.
The method comprises the following steps of obtaining a gray value distribution line representing a gray value distribution trend of a row by fitting according to the sum of gray values of the rows in a gray matrix; and according to the sum of the gray values of all columns in the gray matrix, the column gray distribution line representing the column gray distribution trend is obtained through fitting.
Specifically, taking the fitting of the line gray distribution line as an example, it is necessary to calculate the gray value sum of each line in the gray matrix, form the gray value sum y1 of the 1 st line into a coordinate (1, y1), form the gray value sum y2 of the 2 nd line into a coordinate (2, y2), … …, and form the gray value sum ym of the m th line into a coordinate (m, ym); m is the number of rows. The fitting equation of the line gray distribution line is that y is px3+qx2And + rx + s, where p, q, r, s are unknown coefficients, and the coordinates are substituted into a fitting equation to calculate p, q, r, s. The fitting equation selected here is merely an exemplary illustration, and the present embodiment may also select a straight line and other curves as the line gray distribution lines. The preferred fitting method of the present embodiment is polynomial fitting.
Prior to step 121, the method may further comprise:
calculating th variance of the sum of gray values of each row, calculating second variance of the gray values of each column, judging whether the th variance is smaller than a th preset value, and judging whether the second variance is smaller than a second preset value;
when the th variance is less than the th preset value and the second variance is less than the second preset value, it indicates that the gray scales of the pixels on the target image are relatively balanced without performing the image gray scale processing of the present invention, when the th variance is greater than or equal to the th preset value and the second variance is less than the second preset value, it indicates that the target image is relatively balanced in the up-and-down direction of the image and relatively balanced in the left-and-right direction of the image, it indicates that the gray scale matrix needs to be corrected by rows when the th variance is less than the second preset value and the second variance is greater than or equal to the th preset value, it indicates that the target image is relatively balanced in the up-and-down direction of the image and relatively balanced in the left-and-right direction of the image, and it indicates that the gray scale matrix needs to be corrected by columns when the th variance is greater than or equal to the and the second variance is greater than or equal to the second preset value, it indicates that the entire target image is relatively balanced in the up-and left-and-right directions of the image, therefore, the gray scale matrix can be corrected.
And step 122, respectively replacing the gray values and the serial numbers into the row/column gray distribution lines to obtain undetermined values of the gray values of the rows and the columns.
For a row gray distribution line, the serial number is the row serial number of the gray matrix; for a column gray distribution line, the index is the row index of the gray matrix.
As an example, the fitting equation of the line gray scale distribution curve is y ═ px in step 1213+qx2+ rx + s for example, substituting x as the serial number into y ═ px3+qx2+ rx + s, new y1 (the gray level undetermined value in row 1), new y2 (the gray level undetermined value in row 2), … …, and new ym (the gray level undetermined value in row m). It is worth to be noted that the gray scale undetermined value obtained by fitting the equation can eliminate errors possibly existing in the gray scale sum value.
And step 123, dividing the mean value of the gray value sum by the undetermined value of the gray value of each row/column to obtain each numerical value in the balanced array.
Specifically, the values in the equalization array are calculated according to formula , where formula includes:
wherein, bjIs the j-th number value in the balanced array b (n), j is a positive integer less than or equal to n;
when a isiIs the sum of the gray values of the ith row in the gray matrix, n is the number of rows in the gray matrix,is the mean value of the sum of the gray values of the rows in the gray matrix, a'jIs the undetermined value of the gray level of the jth row, therefore, b (n) is a balanced array for the row; when a isiIs the sum of the gray values of the ith column in the gray matrix, n is the number of columns in the gray matrix,is the sum of gray values of each column in the gray matrix, a'jIs the jth column gray pending value, and b (n) is the equalization array for the column.
On the basis of the foregoing technical solution, as shown in fig. 3, the step 130 of correcting the gray-scale matrix according to the equalization array to obtain a corrected gray-scale matrix of the target image may include:
and step 131, multiplying the gray value in the gray matrix by the numerical value of the corresponding balanced array to obtain the corrected gray value.
When b (n) is the equalizing array for the row, the row sequence number of the gray matrix corresponds to the sequence number of the numerical values in the equalizing array, and step 131 may include:
calculating the corrected gray value according to a second formula, wherein the second formula is as follows:
g′pq=gpqbp;
wherein, gpqIs the gray value of the p row and q column in the gray matrix; g'pqIs the gray value of the qth row and the qth column in the corrected gray matrix; bpIs the p-th value in (b); p is less than or equal to the number of rows of the grayscale matrix; q is less than or equal to the number of columns of the gray-scale matrix.
When b (n) is the equalizing array for the columns, the column number of the gray matrix corresponds to the number of the values in the equalizing array, and step 131 may include:
calculating the corrected gray value according to a third formula, wherein the third formula is as follows:
g′pq=gpqbq;
wherein, gpqIs the gray value of the p row and q column in the gray matrix; g'pqIs the gray value of the qth row and the qth column in the corrected gray matrix; bqIs the value of q in (b); p is less than or equal to the number of rows of the grayscale matrix; q is less than or equal to the number of columns of the gray-scale matrix.
Example two
Fig. 4 is a flowchart of an image gray scale processing method according to a second embodiment of the present invention, which is applicable to a situation where an image is unclear due to uneven brightness of the image, and the method may be executed by a computer device, as shown in fig. 4, and specifically includes the following steps:
step 210, obtaining the gray value of each pixel in the target image to obtain a gray matrix.
And step 220, obtaining a balanced array according to the distribution trend of the row gray levels in the gray level matrix.
Fitting to obtain a line gray distribution line according to the sum of gray values of each line in the gray matrix; respectively substituting the gray values and the serial numbers into the line gray distribution lines to obtain undetermined values of the gray values of each line; and dividing the mean value of the gray value sum by each row of gray undetermined values to obtain each numerical value in the balanced array.
And step 230, correcting the gray matrix according to the balanced array to obtain a corrected gray matrix of the target image.
And multiplying the gray value in the gray matrix by the numerical value of the corresponding balanced array to obtain the corrected gray value.
And 240, obtaining a new balanced array according to the column gray distribution trend in the corrected gray matrix.
Fitting to obtain a new row gray distribution line according to the new gray value sum of each row in the corrected gray matrix; respectively substituting the new gray values and the serial numbers into the new row gray distribution lines to obtain undetermined values of the new gray values of all rows; and dividing the mean value of the new gray value sum by each new gray value undetermined value to obtain each numerical value in the new balanced array.
And step 250, correcting the corrected gray matrix according to the new balanced array to obtain a gray matrix of the target image after secondary correction.
And multiplying the gray value in the corrected gray matrix by the numerical value of the corresponding new balanced array to obtain the gray value after secondary correction.
In this embodiment, step 240 is the same as step 220, and step 250 is the same as step 230.
Example two is exemplified by taking an X-ray image (as shown in fig. 5) of an aluminum lithium alloy laser welding seam as a target image, wherein the left-side brightness is significantly lower than the right-side brightness. Acquiring a gray matrix of the X-ray image, wherein the gray matrix is 44X 891; calculating the sum of gray values of each column in the gray matrix, wherein a solid line in fig. 6 shows a distribution diagram of the sum of gray values of each column; performing polynomial fitting on the gray value sum and the column number of the gray matrix for 2 degrees to obtain a column gray distribution line (as shown by a dotted line in fig. 6) and a fitting equation thereof, wherein the fitting equation is that y is 0.0003416x2+5.36X +1425.04, obtaining undetermined gray value of each row according to a fitting equation, calculating the mean value of the gray value sum to be 3888.81, further obtaining a balanced array, correcting the gray matrix according to the balanced array, obtaining corrected X-ray images according to the corrected gray matrix as shown in FIG. 7, thus improving the light and shade distribution of the left and right sides of the corrected X-ray images, calculating the gray value sum of each row in the th corrected gray matrix, wherein the solid line in FIG. 8 shows the distribution diagram of the gray value sum of each row, and performing polynomial fitting for 2 times on the gray value sum and the column number of the gray matrix to obtain the row gray distribution line (as the dotted line in FIG. 8) and a fitting equation y 54X26566X +190334, obtaining undetermined gray value of each row according to the fitting equation, calculating the mean value of the gray value sum to be 68904.8, obtaining a new balanced array according to the mean value and the undetermined gray value of the new row, obtaining a gray matrix after times of correction according to the new balanced array, and obtaining an X-ray image after secondary correction according to the gray matrix after secondary correction as shown in figure 9, so that the light and shade distribution of the upper side and the lower side of the X-ray image after secondary correction is improved on the basis of the light and shade distribution of the left side and the right side of the X-ray image after secondary correction.
Example two is exemplified by taking an X-ray image (as shown in fig. 5) of an aluminum lithium alloy laser welding seam as a target image, wherein the left-side brightness is significantly lower than the right-side brightness. Acquiring a gray matrix of the X-ray image, the grayThe degree matrix is a 44 x 891 matrix; calculating the sum of gray values of each row in the gray matrix, wherein the solid line in fig. 10 shows the distribution diagram of the sum of gray values of each row; performing polynomial fitting on the gray value sum and the line sequence number of the gray matrix for 2 degrees to obtain a line gray distribution line (as a dotted line in fig. 10) and a fitting equation thereof, wherein the fitting equation is that y is 50.85x2+6288.6X +186645, obtaining undetermined gray value of each row according to a fitting equation, calculating the mean value of the gray value sum to be 3357.61, further obtaining a balanced array, correcting the gray matrix according to the balanced array, obtaining corrected X-ray images according to the corrected gray matrix as shown in FIG. 11, thus improving the light and shade distribution of the upper and lower sides of the corrected X-ray images, calculating the gray value sum of each column in the th corrected gray matrix, showing the distribution diagram of the gray value sum of each column by a solid line in FIG. 12, and performing polynomial fitting for 2 times on the gray value sum and the column serial number of the gray matrix to obtain a row gray distribution line (as a dotted line in FIG. 12) and a fitting equation y 54X26566X +190334, obtaining undetermined value of each row of gray scale according to the fitting equation, calculating the mean value of the gray scale value sum to be 68904.8, obtaining a new balanced array according to the mean value and the undetermined value of each new row of gray scale, obtaining the times corrected gray scale matrix according to the new balanced array, and obtaining the twice corrected X-ray image according to the twice corrected gray scale matrix, wherein the X-ray image is shown in figure 13, so that the light and shade distribution of the left side and the right side of the twice corrected X-ray image is improved on the basis of the improvement of the light and shade distribution of the left side and the right side of the twice corrected X-ray image.
It can be seen that the th example of the above two examples corrects the gray matrix according to the row gray distribution trend and secondarily corrects the gray matrix according to the column gray distribution trend, and the second example corrects the gray matrix according to the column gray distribution trend and secondarily corrects the gray matrix according to the row gray distribution trend.
In this embodiment, the gray matrix is corrected twice, and the line gray distribution trend and the column gray distribution trend are corrected respectively, and compared with times of correction, the line gray distribution trend and the column gray distribution trend can be equalized through two times of correction, the contrast of an over-dark area is improved in step , the contrast of an over-bright area is reduced, and the definition of a target image is improved in step .
EXAMPLE III
The image gray scale processing device provided by the third embodiment of the invention can execute the image gray scale processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 14 is a schematic structural diagram of an image grayscale processing apparatus according to an embodiment of the present invention, as shown in fig. 4, the image grayscale processing apparatus may include:
an obtaining module 310, configured to obtain a gray value of each pixel in the target image to obtain a gray matrix;
the processing module 320 is configured to obtain a balanced array according to a row/column gray distribution trend in the gray matrix;
and the correcting module 330 is configured to correct the gray matrix according to the balanced array to obtain a corrected gray matrix of the target image.
According to the invention, the balanced array is obtained through the row/column gray distribution trend in the gray matrix, and the balanced array can balance the row/column gray distribution trend in the gray matrix, so that the gray value in the gray matrix approaches to balance, thus the brightness of an over-dark area is improved, and the brightness of an over-bright area is reduced, therefore, the problem of uneven light and shade distribution of a target image is solved, and the effect of increasing the definition of the target image is realized.
Optionally, the distribution trend of the elements in the balanced array is opposite to the row/column gray distribution trend.
Optionally, as shown in fig. 15, the processing module 320 includes:
the fitting submodule 321 is configured to fit to obtain a row/column gray distribution line according to the sum of gray values of rows and columns in the gray matrix;
a carry-in submodule 322, configured to substitute the gray value and the serial number into the row/column gray distribution line, respectively, to obtain a undetermined value of the gray value of each row/column;
and the th calculation submodule 323 is used for dividing the mean value of the gray value sum by each row/column gray undetermined value to obtain each numerical value in the balanced array.
Optionally, the th calculation sub-module 323 is configured to:
calculating values in the balanced array according to an th formula, the th formula comprising:
wherein, b isjIs the jth value in said equalized array b (n), said j being a positive integer less than or equal to said n;
when said a isiIs the sum of the gray values of the ith row in the gray matrix, n is the number of rows in the gray matrix, andis the sum of the gray values of the respective rows in the gray matrix, the'jIs the gray undetermined value of the jth row, and b (n) is an equalization array for the row; when said a isiIs the sum of the gray values of the ith column in the gray matrix, the n is the number of the columns of the gray matrix, theIs the sum of gray values of each column in the gray matrix, the'jIs the j-th column gray pending value, and b (n) is the equalization array for the column.
Optionally, as shown in fig. 16, the modification module 330 includes:
the second calculating submodule 331 is configured to multiply the gray value in the gray matrix by the value of the corresponding equalizing array to obtain a corrected gray value.
Optionally, when b (n) is an equalization array for a row, the second calculating submodule 323 is configured to:
calculating the corrected gray value according to a second formula, wherein the second formula is as follows:
g'pq=gpqbp;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b ispIs the p-th value in (n) of said b; the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
Optionally, when b (n) is an equalization array for a column, the second calculating submodule 323 is configured to:
calculating the corrected gray value according to a third formula, wherein the third formula is as follows:
g′pq=gpqdq;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b isqIs the value of the qth of said b (n); the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
Example four
Fig. 17 is a schematic structural diagram of computer apparatuses according to a fourth embodiment of the present invention, where as shown in fig. 17, the computer apparatus includes a processor 70, a memory 71, an input device 72, and an output device 73, the number of the processors 70 in the computer apparatus may be or more, processors 70 are illustrated in fig. C, the processors 70, the memory 71, the input device 72, and the output device 73 in the computer apparatus may be connected by a bus or in another manner, and the connection by the bus is illustrated in fig. 17.
The memory 71 serves as computer-readable storage media, which can be used for storing software programs, computer-executable programs and modules, such as program instructions/modules corresponding to the image gray scale processing method in the embodiment of the present invention (for example, the information acquisition module 310, the processing module 320 and the modification module 330 in the image gray scale processing apparatus, the processor 70 executes various functional applications and data processing of the device/terminal/server by running the software programs, instructions and modules stored in the memory 71, so as to implement the image gray scale processing method.
The memory 71 may generally include a program storage area that may store an operating system, at least applications needed for functionality, and a data storage area that may store data created from use of the terminal, etc. additionally, the memory 71 may include high speed random access memory, and may also include non-volatile memory, such as at least disk storage devices, flash memory devices, or other non-volatile solid state storage devices, in examples, the memory 71 may further include memory remotely located with respect to the processor 70, which may be connected to the device/terminal/server via a network, examples of which include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 72 may be used to receive input numeric or character information and generate key signal inputs relating to user settings and function controls of the computer apparatus. The output device 73 may include a display device such as a display screen.
EXAMPLE five
An embodiment of the present invention further provides storage media containing computer-executable instructions, which when executed by a computer processor, perform image gray scale processing methods, including:
acquiring a gray value of each pixel in a target image to obtain a gray matrix;
obtaining a balanced array according to the distribution trend of the row/column gray levels in the gray level matrix;
and correcting the gray matrix according to the balanced array to obtain the corrected gray matrix of the target image.
Of course, the storage media containing computer-executable instructions provided by the embodiments of the present invention are not limited to the method operations described above, and may also perform related operations in the image gray scale processing method provided by any embodiments of the present invention.
Based on the understanding that the technical solutions of the present invention can be embodied in the form of software products, such as floppy disks, Read-Only memories (ROMs), Random Access Memories (RAMs), FLASH memories (flashes), hard disks, optical disks, etc., which are stored in a computer-readable storage medium, and include instructions for enabling computer devices (which may be personal computers, servers, or network devices, etc.) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the above search apparatus, each included unit and module are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1, A method for processing image gray scale, comprising:
acquiring a gray value of each pixel in a target image to obtain a gray matrix;
obtaining a balanced array according to the distribution trend of the row/column gray levels in the gray level matrix;
and correcting the gray matrix according to the balanced array to obtain the corrected gray matrix of the target image.
2. The method of claim 1, wherein the distribution trend of the elements in the equalized array is opposite to the row/column gray distribution trend.
3. The method according to claim 2, wherein the deriving an equalization array according to the row/column gray distribution trend in the gray matrix comprises:
fitting to obtain a row/column gray distribution line according to the gray value sum of each row/column in the gray matrix;
respectively substituting the gray value and the serial number into the row/column gray distribution line to obtain a undetermined value of the gray value of each row/column;
and dividing the mean value of the gray value sum by each row/column gray undetermined value to obtain each numerical value in the balanced array.
4. The method of claim 3, wherein dividing the mean of the gray value sums by each of the row/column gray undetermined values to obtain each value in the balanced array comprises:
calculating values in the balanced array according to an th formula, the th formula comprising:
wherein, b isjIs the jth value in said equalized array b (n), said j being a positive integer less than or equal to said n;
when said a isiIs the sum of the gray values of the ith row in the gray matrix, n is the number of rows in the gray matrix, andis the sum of the gray values of the respective rows in the gray matrix, the'jIs the gray undetermined value of the jth row, and b (n) is an equalization array for the row; when said a isiIs the sum of the gray values of the ith column in the gray matrix, the n is the number of the columns of the gray matrix, theIs the sum of gray values of each column in the gray matrix, the'jIs the j-th column gray pending value, and b (n) is the equalization array for the column.
5. The method of claim 4, wherein the modifying the gray-scale matrix according to the equalization array to obtain the modified gray-scale matrix of the target image comprises:
and multiplying the gray value in the gray matrix by the numerical value of the corresponding balanced array to obtain the corrected gray value.
6. The method of claim 5, wherein the step of multiplying the gray value in the gray matrix by the value of the corresponding equalizing array to obtain the modified gray value when b (n) is the equalizing array for the row comprises:
calculating the corrected gray value according to a second formula, wherein the second formula is as follows:
S’pqgpqbp;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b ispIs the p-th value in (n) of said b; the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
7. The method of claim 5, wherein b (n) is an equalizing array for a column, and the step of multiplying the gray value in the gray matrix by the value of the corresponding equalizing array to obtain the modified gray value comprises:
calculating the corrected gray value according to a third formula, wherein the third formula is as follows:
g’pq=gpqbq;
wherein, the gpqIs the gray value of the p row and the q column in the gray matrix; g'pqIs the gray value of the p row and q column in the corrected gray matrix; b isqIs the value of the qth of said b (n); the p is less than or equal to the number of rows of the gray matrix; the q is less than or equal to the number of columns of the gray matrix.
An image gradation processing apparatus of kinds, comprising:
the acquisition module is used for acquiring the gray value of each pixel in the target image to obtain a gray matrix;
the processing module is used for obtaining a balanced array according to the row/column gray distribution trend in the gray matrix;
and the correcting module is used for correcting the gray matrix according to the balanced array to obtain the corrected gray matrix of the target image.
Computer device of 9, kinds, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor when executing the program implements the image grey scale processing method according to any of claims 1-7, .
10, computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out the image grey scale processing method according to any of claims 1-7, .
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810791972.5A CN110738603B (en) | 2018-07-18 | 2018-07-18 | Image gray level processing method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810791972.5A CN110738603B (en) | 2018-07-18 | 2018-07-18 | Image gray level processing method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110738603A true CN110738603A (en) | 2020-01-31 |
CN110738603B CN110738603B (en) | 2024-07-12 |
Family
ID=69234933
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810791972.5A Active CN110738603B (en) | 2018-07-18 | 2018-07-18 | Image gray level processing method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110738603B (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111335633A (en) * | 2020-03-06 | 2020-06-26 | 中核华辰建筑工程有限公司 | Multifunctional assembled building assembly construction floor combined leveling device and method |
CN111800584A (en) * | 2020-08-11 | 2020-10-20 | 深圳市安健科技股份有限公司 | High dynamic range image processing method, device and computer readable storage medium |
CN111800583A (en) * | 2020-08-11 | 2020-10-20 | 深圳市安健科技股份有限公司 | High dynamic range image partition processing method and device and computer readable storage medium |
CN111797706A (en) * | 2020-06-11 | 2020-10-20 | 昭苏县西域马业有限责任公司 | Image-based parasite egg shape recognition system and method |
CN111915572A (en) * | 2020-07-13 | 2020-11-10 | 青岛大学 | Self-adaptive gear pitting quantitative detection system and method based on deep learning |
CN117152803A (en) * | 2023-10-30 | 2023-12-01 | 江苏圣点世纪科技有限公司 | Facial vein image equalization method |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101706953A (en) * | 2009-11-13 | 2010-05-12 | 北京中星微电子有限公司 | Histogram equalization based image enhancement method and device |
JP2013044959A (en) * | 2011-08-24 | 2013-03-04 | Canon Inc | Image display device and control method thereof |
CN103886628A (en) * | 2014-03-10 | 2014-06-25 | 百度在线网络技术(北京)有限公司 | Two-dimension code image generating method and device |
CN104751147A (en) * | 2015-04-16 | 2015-07-01 | 成都汇智远景科技有限公司 | Image recognition method |
CN105100763A (en) * | 2015-08-06 | 2015-11-25 | 京东方科技集团股份有限公司 | Color compensation method and circuit and display device |
CN105354248A (en) * | 2015-10-19 | 2016-02-24 | 南通大学 | Gray based distributed image bottom-layer feature identification method and system |
WO2017096946A1 (en) * | 2015-12-07 | 2017-06-15 | 乐视控股(北京)有限公司 | Method and device for locating high-frequency information of image |
CN107111995A (en) * | 2014-10-03 | 2017-08-29 | 夏普株式会社 | Image processor, display device, configuration decision maker, configuration decision method, recording medium |
CN108090511A (en) * | 2017-12-15 | 2018-05-29 | 泰康保险集团股份有限公司 | Image classification method, device, electronic equipment and readable storage medium storing program for executing |
CN108230272A (en) * | 2018-01-04 | 2018-06-29 | 京东方科技集团股份有限公司 | A kind of image enchancing method and device |
-
2018
- 2018-07-18 CN CN201810791972.5A patent/CN110738603B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101706953A (en) * | 2009-11-13 | 2010-05-12 | 北京中星微电子有限公司 | Histogram equalization based image enhancement method and device |
JP2013044959A (en) * | 2011-08-24 | 2013-03-04 | Canon Inc | Image display device and control method thereof |
CN103886628A (en) * | 2014-03-10 | 2014-06-25 | 百度在线网络技术(北京)有限公司 | Two-dimension code image generating method and device |
CN107111995A (en) * | 2014-10-03 | 2017-08-29 | 夏普株式会社 | Image processor, display device, configuration decision maker, configuration decision method, recording medium |
CN104751147A (en) * | 2015-04-16 | 2015-07-01 | 成都汇智远景科技有限公司 | Image recognition method |
CN105100763A (en) * | 2015-08-06 | 2015-11-25 | 京东方科技集团股份有限公司 | Color compensation method and circuit and display device |
US20170039991A1 (en) * | 2015-08-06 | 2017-02-09 | Boe Technology Group Co., Ltd. | Color compensation circuit, display apparatus, and color compensation method |
CN105354248A (en) * | 2015-10-19 | 2016-02-24 | 南通大学 | Gray based distributed image bottom-layer feature identification method and system |
WO2017096946A1 (en) * | 2015-12-07 | 2017-06-15 | 乐视控股(北京)有限公司 | Method and device for locating high-frequency information of image |
CN108090511A (en) * | 2017-12-15 | 2018-05-29 | 泰康保险集团股份有限公司 | Image classification method, device, electronic equipment and readable storage medium storing program for executing |
CN108230272A (en) * | 2018-01-04 | 2018-06-29 | 京东方科技集团股份有限公司 | A kind of image enchancing method and device |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111335633A (en) * | 2020-03-06 | 2020-06-26 | 中核华辰建筑工程有限公司 | Multifunctional assembled building assembly construction floor combined leveling device and method |
CN111797706A (en) * | 2020-06-11 | 2020-10-20 | 昭苏县西域马业有限责任公司 | Image-based parasite egg shape recognition system and method |
CN111915572A (en) * | 2020-07-13 | 2020-11-10 | 青岛大学 | Self-adaptive gear pitting quantitative detection system and method based on deep learning |
CN111915572B (en) * | 2020-07-13 | 2023-04-25 | 青岛大学 | Adaptive gear pitting quantitative detection system and method based on deep learning |
CN111800584A (en) * | 2020-08-11 | 2020-10-20 | 深圳市安健科技股份有限公司 | High dynamic range image processing method, device and computer readable storage medium |
CN111800583A (en) * | 2020-08-11 | 2020-10-20 | 深圳市安健科技股份有限公司 | High dynamic range image partition processing method and device and computer readable storage medium |
CN111800583B (en) * | 2020-08-11 | 2022-03-08 | 深圳市安健科技股份有限公司 | High dynamic range image partition processing method and device and computer readable storage medium |
CN111800584B (en) * | 2020-08-11 | 2022-04-29 | 深圳市安健科技股份有限公司 | High dynamic range image processing method, device and computer readable storage medium |
CN117152803A (en) * | 2023-10-30 | 2023-12-01 | 江苏圣点世纪科技有限公司 | Facial vein image equalization method |
CN117152803B (en) * | 2023-10-30 | 2024-02-09 | 江苏圣点世纪科技有限公司 | Facial vein image equalization method |
Also Published As
Publication number | Publication date |
---|---|
CN110738603B (en) | 2024-07-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110738603A (en) | image gray scale processing method, device, computer equipment and storage medium | |
US11069286B2 (en) | Color compensation method, compensation device, and display device | |
US10602032B2 (en) | Method of correcting image distortion of optical device in display device and display device | |
US9135688B2 (en) | Method for brightness equalization of various images | |
CN107680542B (en) | Partitioned backlight control method and device | |
US9491446B2 (en) | Image processing device, image display device, image processing method, and image processing program | |
KR102307501B1 (en) | Optical compensation system and Optical compensation method thereof | |
CN109036333B (en) | Display parameter correction method and device of display, terminal equipment and storage medium | |
JP2006033062A5 (en) | ||
US9036047B2 (en) | Apparatus and techniques for image processing | |
US10089910B2 (en) | Image display device, correction data generation method, and image correction device and method, as well as image correction system | |
US8823617B2 (en) | Liquid crystal display apparatus and program used for the same | |
US9432596B2 (en) | Image processing apparatus and image processing method | |
CN110930919B (en) | Image processing method and display driving device | |
CN111340721B (en) | Pixel correction method, device, equipment and readable storage medium | |
CN109920381B (en) | Method and equipment for adjusting backlight value | |
US20170195520A1 (en) | Image processing method, apparatus, and image forming device | |
US20200143760A1 (en) | Driving method and driving device for display panel, and display device | |
JP2023519275A (en) | Display effect enhancement method, device, facility | |
CN102752608A (en) | Method and device for realizing fast color correction | |
CN116016807B (en) | Video processing method, system, storable medium and electronic equipment | |
CN113822809B (en) | Dim light enhancement method and system thereof | |
KR101497933B1 (en) | System and Method for compositing various images using clustering technique | |
US20070177217A1 (en) | Apparatus and method for adjusting sharpness of image | |
CN107591142B (en) | Method and device for regulating and controlling picture display quality and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |