CN113160087B - Image enhancement method, device, computer equipment and storage medium - Google Patents

Image enhancement method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN113160087B
CN113160087B CN202110476942.7A CN202110476942A CN113160087B CN 113160087 B CN113160087 B CN 113160087B CN 202110476942 A CN202110476942 A CN 202110476942A CN 113160087 B CN113160087 B CN 113160087B
Authority
CN
China
Prior art keywords
gray
image
value
gray value
point
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.)
Active
Application number
CN202110476942.7A
Other languages
Chinese (zh)
Other versions
CN113160087A (en
Inventor
侯丽
严明洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110476942.7A priority Critical patent/CN113160087B/en
Publication of CN113160087A publication Critical patent/CN113160087A/en
Application granted granted Critical
Publication of CN113160087B publication Critical patent/CN113160087B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

The application relates to the field of image processing, and discloses an image enhancement method, an image enhancement device, computer equipment and a storage medium, wherein the method comprises the following steps: acquiring an image, and converting the image into a single-channel gray image; calculating a segmentation threshold value of the gray image according to the gray value of each pixel point; determining a lower segmentation point of the gray image according to the segmentation threshold and the minimum gray value of the gray image, and determining an upper segmentation point of the gray image according to the segmentation threshold and the maximum gray value of the gray image; carrying out gray value compression on a first pixel point of which the gray value is smaller than that of the lower segmentation point in the gray image, and carrying out gray value compression on a second pixel point of which the gray value is larger than that of the upper segmentation point in the gray image; and carrying out gray value stretching on target pixel points, wherein the gray value of the pixel points in the gray image is larger than the gray value of the lower segmentation point and smaller than the gray value of the upper segmentation point, so as to obtain a gray enhanced image. The enhancement effect of the gray level image can be improved.

Description

Image enhancement method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of image processing, and in particular, to an image enhancement method, an image enhancement device, a computer device, and a storage medium.
Background
The image may be affected by factors such as acquisition equipment or external environment in the acquisition process, so that the phenomena of large image noise, low contrast, unclear target contour and the like are caused, the image needs to be enhanced, the current enhancement effect is not easy to control, the background and noise are enhanced while the target is enhanced, and the method is not suitable for various too simple or complex images.
Disclosure of Invention
The main purpose of the application is to provide an image enhancement method, an image enhancement device, computer equipment and a storage medium, which aim to solve the problems that the current image enhancement effect is not easy to control and the applicability is low.
In order to achieve the above object, the present application proposes an image enhancement method, including:
acquiring an image, and converting the image into a single-channel gray image;
acquiring the gray value of each pixel point of the gray image, and calculating the segmentation threshold value of the gray image according to the gray value of each pixel point;
acquiring a minimum gray value and a maximum gray value of the gray image, determining a lower segmentation point of the gray image according to the segmentation threshold and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold and the maximum gray value;
carrying out gray value compression on a first pixel point of which the gray value is smaller than that of the lower segmentation point in the gray image, and carrying out gray value compression on a second pixel point of which the gray value is larger than that of the upper segmentation point in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
Further, the acquiring the gray value of each pixel point of the gray image, and calculating the segmentation threshold of the gray image according to the gray value of each pixel point includes:
acquiring gray values of all pixel points of the gray image;
selecting a segmentation parameter value;
acquiring the number proportion of foreground points and a first average gray value of the foreground points, and the number proportion of background points and a second average gray value of the background points; the foreground points are pixel points with gray values smaller than the segmentation parameter values, and the background points are pixel points with gray values larger than the segmentation parameter values;
calculating the gray variance of the gray image according to the number proportion of the foreground points, the first average gray value, the number proportion of the background points and the second average gray value;
and when the value of the gray variance is maximum, determining the segmentation parameter value as a segmentation threshold value of the gray image.
Further, the compressing the gray value of the first pixel having the gray value smaller than the gray value of the pixel in the gray image than the first pixel having the gray value larger than the gray value of the pixel in the gray image than the second pixel having the gray value larger than the gray value of the pixel in the upper segment includes:
setting the gray value of a pixel point in the gray image smaller than the gray value of a first pixel point of the lower segmentation point to 0;
and setting the gray value of a second pixel point, of which the gray value is larger than that of the upper segmentation point, in the gray image to 255.
Further, the performing gray value stretching on the target pixel point, where the gray value of the pixel point in the gray image is greater than the gray value of the lower segment point and less than the gray value of the upper segment point, includes:
and inputting the gray value of the target pixel point into a preset stretching function, and stretching the gray value of the target pixel point based on the stretching function, wherein the stretching function is a linear function.
Further, the preset stretching function is:
where f (x, y) is the gray value of the target pixel before gray value stretching, f' (x, y) is the gray value of the target pixel after gray value stretching, t1 is the lower segment point, and t2 is the upper segment point.
Further, after the gray enhancement image is obtained, the method further comprises:
acquiring pixel information of the gray enhanced image;
and if the pixel information of the gray enhancement image does not meet the preset requirement, executing the image enhancement method again on the gray enhancement image.
Further, after the gray enhancement image is obtained, the method further comprises:
and recovering the gray enhancement image into a multi-channel color image.
The application also provides an image enhancement device, comprising:
and a conversion module: the method comprises the steps of acquiring an image, and converting the image into a single-channel gray image;
the calculation module: the method comprises the steps of obtaining gray values of all pixel points of the gray image, and calculating a segmentation threshold value of the gray image according to the gray values of all pixel points;
and a segmentation module: the method comprises the steps of obtaining a minimum gray value and a maximum gray value of a gray image, determining a lower segmentation point of the gray image according to a segmentation threshold value and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold value and the maximum gray value;
compression and stretching module: the gray value compression method comprises the steps of compressing gray values of first pixel points, of which the gray values are smaller than those of the lower segmentation points, in the gray image, and compressing gray values of second pixel points, of which the gray values of the pixel points are larger than those of the upper segmentation points, in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
The present application also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of any one of the image enhancement methods described above when the computer program is executed.
The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the image enhancement method of any of the above.
After an image is acquired, the image possibly contains color images of multiple channels, the image is firstly converted into a single-channel gray image, then gray values of all pixels of the gray image are acquired, a segmentation threshold value of the gray image is calculated according to the gray values of all pixels, gray value segmentation points of the gray image are determined, then the minimum gray value and the maximum gray value of the gray image are acquired, a lower segmentation point of the gray image is determined according to the segmentation threshold value and the minimum gray value, an upper segmentation point of the gray image is determined according to the segmentation threshold value and the maximum gray value, so that the pixels of the gray image are divided into three sections, then pixels of different sections are processed, and specifically, gray value compression is carried out on a first pixel with the gray value of the pixels of the gray image smaller than the lower segmentation point, and gray value compression is carried out on a second pixel with the gray value of the pixels of the gray image larger than the upper segmentation point; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, wherein the information owned by the first pixel points and the second pixel points after gray value compression is reduced, and the information owned by the target pixel points after gray value stretching is inversely increased, and then generating a gray enhancement image according to the first pixel points, the second pixel points and the target pixel points after gray value stretching after gray value compression, so that the foreground picture information in the image is increased, and the background picture information is reduced, thereby highlighting the main body in the image and improving the image enhancement effect.
Drawings
FIG. 1 is a flowchart of an embodiment of an image enhancement method according to the present application;
FIG. 2 is a flow chart of another embodiment of the image enhancement method of the present application;
FIG. 3 is a schematic structural diagram of an embodiment of an image enhancement device according to the present application;
FIG. 4 is a block diagram schematically illustrating the structure of an embodiment of a computer device according to the present application.
The realization, functional characteristics and advantages of the present application will be further described with reference to the embodiments, referring to the attached drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
Referring to fig. 1, an embodiment of the present application provides an image enhancement method, including steps S10-S40, and the detailed description of each step of the image enhancement method is as follows.
S10, acquiring an image, and converting the image into a single-channel gray level image.
The embodiment is applied to image recognition and analysis scenes, the images may be affected by factors such as acquisition equipment and external environment in the acquisition process, so that the images have the phenomena of large noise, low contrast, unclear target contour and the like, the images need to be subjected to enhancement processing, the images can be acquired firstly, the images can be images acquired by the acquisition equipment in real time or can be images extracted from a preset database, in order to reduce interference of various colors on image enhancement, the images need to be subjected to color space conversion, namely the images are converted into single-channel gray images, the gray images are divided into a plurality of grades according to logarithmic relation between white and black, generally, gray scales of the gray images are divided into 256 grades, wherein 255 grades represent full white, and 0 grade represents full black.
S20, acquiring gray values of all pixel points of the gray image, and calculating a segmentation threshold of the gray image according to the gray values of all pixel points.
In this embodiment, after converting an image into a single-channel gray image, the gray image needs to be segmented, that is, pixels with different gray values in the gray image are collected, and before collecting pixels with different gray values in the gray image, suitable gray value segmentation points need to be selected, the gray value segmentation points are defined as segmentation thresholds, specifically, the gray values of the pixels of the gray image are obtained, then the segmentation thresholds of the gray image are calculated according to the gray values of the pixels, and in one embodiment, the segmentation thresholds of the gray image are calculated according to the gray values of the pixels and based on the maximum inter-class method, so as to determine the gray value segmentation points of the gray image.
S30, acquiring the minimum gray level value and the maximum gray level value of the gray level image, determining a lower segmentation point of the gray level image according to the segmentation threshold value and the minimum gray level value, and determining an upper segmentation point of the gray level image according to the segmentation threshold value and the maximum gray level value.
In this embodiment, after a segmentation threshold of a gray image is obtained, that is, a segmentation point of a pixel in the gray image is selected, then a minimum gray value of the gray image is obtained, that is, a pixel with the minimum gray value of the pixel in the gray image is obtained, the gray value of the pixel is defined as the minimum gray value, and a maximum gray value of the gray image is obtained, that is, a pixel with the maximum gray value of the pixel in the gray image is obtained, the gray value of the pixel is defined as the maximum gray value, then a lower segmentation point of the gray image is determined according to the segmentation threshold and the minimum gray value, and an upper segmentation point of the gray image is determined according to the segmentation threshold and the maximum gray value. In one embodiment, the calculation manner of the lower segment point is as follows:
wherein t1 is a lower segmentation point, t is a segmentation threshold, and mi is a minimum gray value;
the calculation mode of the upper segmentation point is as follows:
wherein t2 is a lower segmentation point, t is a segmentation threshold, and ma is a maximum gray value.
S40, carrying out gray value compression on a first pixel point, the gray value of which is smaller than that of the lower segmentation point, in the gray image, and carrying out gray value compression on a second pixel point, the gray value of which is larger than that of the upper segmentation point, in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
In this embodiment, after determining the lower segment point and the upper segment point of the gray image, the gray value of the pixel point in the gray image is divided into 3 sections, including a first section with a gray value smaller than or equal to the lower segment point, a second section with a gray value larger than or equal to the upper segment point, and a target section with a gray value larger than the lower segment point and smaller than the upper segment point, the pixel point with a gray value smaller than the lower segment point in the gray image is defined as a first pixel, the pixel point with a gray value larger than the upper segment point in the gray image is defined as a second pixel, the pixel point with a gray value larger than the lower segment point and smaller than the upper segment point in the gray image is defined as a target pixel, then the first pixel point and the second pixel point are subjected to gray value compression, the first pixel point and the second pixel point after the gray value compression are stretched, the information possessed by the first pixel point and the second pixel point after the gray value compression is reduced, the pixel point with a gray value smaller than the lower segment point is defined as a first pixel point, the pixel point with a gray value greater than the upper segment point is stretched, then the second pixel point is increased, and the gray value in the image is increased by the second pixel point after the gray value is stretched, and the second pixel point is increased, and the gray value is increased, and the image is compared with the background image.
The embodiment provides a method for enhancing a gray image, after the image is obtained, the image possibly contains color images of multiple channels, the image is firstly converted into a single-channel gray image, then the gray value of each pixel point of the gray image is obtained, the dividing threshold value of the gray image is calculated according to the gray value of each pixel point, the gray value dividing point of the gray image is determined, the minimum gray value and the maximum gray value of the gray image are obtained, the lower dividing point of the gray image is determined according to the dividing threshold value and the minimum gray value, the upper dividing point of the gray image is determined according to the dividing threshold value and the maximum gray value, so that the pixels in the gray image are divided into three sections, then the pixels in different sections are processed, and specifically, the gray value of the pixels in the gray image is compressed by a first pixel point, and the gray value of the pixels in the gray image is greater than the second pixel point of the upper dividing point; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, wherein the information owned by the first pixel points and the second pixel points after gray value compression is reduced, and the information owned by the target pixel points after gray value stretching is inversely increased, and then generating a gray enhancement image according to the first pixel points, the second pixel points and the target pixel points after gray value stretching after gray value compression, so that the foreground picture information in the image is increased, and the background picture information is reduced, thereby highlighting the main body in the image and improving the image enhancement effect.
In one embodiment, as shown in fig. 2, the acquiring the gray value of each pixel of the gray image, and calculating the segmentation threshold of the gray image according to the gray value of each pixel includes:
s21: acquiring gray values of all pixel points of the gray image;
s22: selecting a segmentation parameter value;
s23: acquiring the number proportion of foreground points and a first average gray value of the foreground points, and the number proportion of background points and a second average gray value of the background points; the foreground points are pixel points with gray values smaller than the segmentation parameter values, and the background points are pixel points with gray values larger than the segmentation parameter values;
s24: calculating the gray variance of the gray image according to the number proportion of the foreground points, the first average gray value, the number proportion of the background points and the second average gray value;
s25: and when the value of the gray variance is maximum, determining the segmentation parameter value as a segmentation threshold value of the gray image.
In this embodiment, a segmentation threshold of a gray image is calculated, and gray values of each pixel point of the gray image are obtained first, that is, how many pixel points are included in the gray image and gray values of each pixel point are determined, the gray values of the pixel points are within a range of [0, 255], then a segmentation parameter value is selected, and one gray value is randomly selected as the segmentation threshold, for example, a gray value 125 is selected as the segmentation parameter value, and then a number proportion of foreground points and a first average gray value of the foreground points and a number proportion of background points and a second average gray value of the background points are obtained; the foreground points are pixels with gray values smaller than the segmentation parameter values, the background points are pixels with gray values larger than the segmentation parameter values, the gray variance of the gray image is calculated according to the number proportion of the foreground points, the first average gray value, the number proportion of the background points and the second average gray, and specifically, the average gray of the gray image is calculated firstly according to the following formula:
u=w0*u0+w1*u1
wherein u is the average gray level of the gray level image, w0 is the number proportion of foreground points, namely the proportion of foreground points to the pixel points of the gray level image, u0 is the average gray level of foreground points, w1 is the number proportion of background points, namely the proportion of background points to the pixel points of the gray level image, and u1 is the average gray level of background points.
And calculating the gray variance g of the gray image, wherein the formula is as follows:
g=w0*(u0-u) 2 +w1*(u1-u) 2
and determining that the selected segmentation parameter value is a segmentation threshold value when the selected segmentation parameter value enables the gray variance to be maximum. By adopting the method, different segmentation thresholds of each image are selected in a self-adaptive manner, so that the enhancement effect on images with different gray scales can be improved.
In one embodiment, the compressing the gray value of the first pixel having a gray value smaller than the gray value of the second pixel having a gray value larger than the gray value of the first pixel in the gray image, includes:
setting the gray value of a pixel point in the gray image smaller than the gray value of a first pixel point of the lower segmentation point to 0;
and setting the gray value of a second pixel point, of which the gray value is larger than that of the upper segmentation point, in the gray image to 255.
In this embodiment, when gray scale compression is performed on the first pixel point and the second pixel point, the gray scale compression modes of the first pixel point and the second pixel point are different, specifically, the gray scale value of the first pixel point in the gray scale image, which is smaller than the gray scale value of the first pixel point of the lower segment point, is set to 0, so that the first pixel point represents a pure black point, the gray scale value of the second pixel point in the gray scale image, which is larger than the gray scale value of the second pixel point of the upper segment point, is set to 255, so that the second pixel point represents a pure white point, thereby highlighting the target pixel point, enhancing the gray scale image, and improving the display effect of the target main body in the image.
In one embodiment, the performing gray value stretching on the target pixel point of the gray image, where the gray value of the pixel point is greater than the gray value of the lower segment point and less than the gray value of the upper segment point, includes:
and inputting the gray value of the target pixel point into a preset stretching function, and stretching the gray value of the target pixel point, wherein the stretching function is a linear function.
In this embodiment, when the gray value of the pixel point in the gray image is greater than the gray value of the lower segment point and less than the gray value of the target pixel point of the upper segment point, a preset stretching function is obtained, then each target pixel point is respectively input into the preset stretching function, the gray value of the target pixel point is stretched based on the stretching function, the stretching function is a linear function, and the linearly stretched target pixel point has more information, so that the target pixel point is highlighted, the gray image is enhanced, and the display effect of the target main body in the image is improved.
In one embodiment, the stretching function is as follows:
wherein f (x, y) is the gray value of the target pixel before gray value stretching, f' (x, y) is the gray value of the target pixel after gray value stretching, t1 is the lower segment point, t2 is the upper segment point, and gray stretching is performed on the gray value of the target pixel by the stretching function, so that the target pixel has more information, and the gray image is enhanced.
In one embodiment, after the obtaining the grayscale enhanced image, the method further includes:
acquiring pixel information of the gray enhanced image;
and if the pixel information of the gray enhancement image does not meet the preset requirement, executing the image enhancement method again on the gray enhancement image.
In this embodiment, after the grayscale enhanced image is obtained, the pixel information of the grayscale enhanced image is obtained, where the pixel information includes the pixel information of the target subject and the pixel information of the non-target subject in the grayscale enhanced image, if the pixel information of the target subject is greater than the first preset value and the pixel information of the non-target subject is smaller than the second preset value, it is determined that the pixel information of the grayscale enhanced image meets the preset requirement, and if the pixel information of the target subject is smaller than the first preset value and the pixel information of the non-target subject is greater than the second preset value, it is determined that the pixel information of the grayscale enhanced image does not meet the preset requirement, at this time, the image enhancement method is performed again on the grayscale enhanced image, and because the grayscale enhanced image is still the grayscale image, the steps S20-S40 are performed again on the grayscale enhanced image, thereby enhancing the enhancement effect of the image.
In one embodiment, after the obtaining the grayscale enhanced image, the method further includes:
and recovering the gray enhancement image into a multi-channel color image.
In this embodiment, after the gray enhancement image is obtained, enhancement is determined on the gray enhancement image, and the target subject in the gray enhancement image is highlighted, so that the target subject is better identified and analyzed, and in order to accurately identify the subject in the image, the gray enhancement image is restored to be a multi-channel color image, and the color image can be endowed with details of the subject in the image, so that the accuracy of identifying the target subject in the image is improved.
Referring to fig. 3, the present application further provides an image enhancement apparatus, including:
and a conversion module: the method comprises the steps of acquiring an image, and converting the image into a single-channel gray image;
the calculation module: the method comprises the steps of obtaining gray values of all pixel points of the gray image, and calculating a segmentation threshold value of the gray image according to the gray values of all pixel points;
and a segmentation module: the method comprises the steps of obtaining a minimum gray value and a maximum gray value of a gray image, determining a lower segmentation point of the gray image according to a segmentation threshold value and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold value and the maximum gray value;
compression and stretching module: the gray value compression method comprises the steps of compressing gray values of first pixel points, of which the gray values are smaller than those of the lower segmentation points, in the gray image, and compressing gray values of second pixel points, of which the gray values of the pixel points are larger than those of the upper segmentation points, in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
As described above, it is understood that each component of the image enhancement apparatus set forth in the present application may implement the functions of any one of the image enhancement methods described above.
Referring to fig. 4, a computer device is further provided in the embodiment of the present application, where the computer device may be a mobile terminal, and the internal structure of the computer device may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a display device and an input device connected by a system bus. The network interface of the computer device is used for communicating with an external terminal through network connection. The input means of the computer device is for receiving input from a user. The computer is designed to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium. The non-volatile storage medium stores an operating system, computer programs, and a database. The database of the computer device is used for storing data. The computer program is executed by a processor to implement an image enhancement method.
The processor executes the image enhancement method, including: acquiring an image, and converting the image into a single-channel gray image; acquiring the gray value of each pixel point of the gray image, and calculating the segmentation threshold value of the gray image according to the gray value of each pixel point; acquiring a minimum gray value and a maximum gray value of the gray image, determining a lower segmentation point of the gray image according to the segmentation threshold and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold and the maximum gray value; carrying out gray value compression on a first pixel point of which the gray value is smaller than that of the lower segmentation point in the gray image, and carrying out gray value compression on a second pixel point of which the gray value is larger than that of the upper segmentation point in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
The computer equipment provides a method for enhancing a gray image, after the image is acquired, the image possibly contains color images of multiple channels, the image is firstly converted into a single-channel gray image, then the gray value of each pixel point of the gray image is acquired, the dividing threshold value of the gray image is calculated according to the gray value of each pixel point, the gray value dividing point of the gray image is determined, the minimum gray value and the maximum gray value of the gray image are acquired, the lower dividing point of the gray image is determined according to the dividing threshold value and the minimum gray value, the upper dividing point of the gray image is determined according to the dividing threshold value and the maximum gray value, so that the pixels in the gray image are divided into three sections, then the pixels in different sections are processed, and particularly, the gray value of the pixels in the gray image is smaller than the first pixel point of the lower dividing point, and the gray value of the pixels in the gray image is larger than the second pixel point of the upper dividing point is compressed; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, wherein the information owned by the first pixel points and the second pixel points after gray value compression is reduced, and the information owned by the target pixel points after gray value stretching is inversely increased, and then generating a gray enhancement image according to the first pixel points, the second pixel points and the target pixel points after gray value stretching after gray value compression, so that the foreground picture information in the image is increased, and the background picture information is reduced, thereby highlighting the main body in the image and improving the image enhancement effect.
An embodiment of the present application further provides a computer readable storage medium having stored thereon a computer program which when executed by the processor implements an image enhancement method comprising the steps of: acquiring an image, and converting the image into a single-channel gray image; acquiring the gray value of each pixel point of the gray image, and calculating the segmentation threshold value of the gray image according to the gray value of each pixel point; acquiring a minimum gray value and a maximum gray value of the gray image, determining a lower segmentation point of the gray image according to the segmentation threshold and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold and the maximum gray value; carrying out gray value compression on a first pixel point of which the gray value is smaller than that of the lower segmentation point in the gray image, and carrying out gray value compression on a second pixel point of which the gray value is larger than that of the upper segmentation point in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
The computer readable storage medium provides a method for enhancing a gray image, after an image is acquired, the image possibly comprises color images of multiple channels, the image is firstly converted into a single-channel gray image, then gray values of all pixels of the gray image are acquired, a segmentation threshold value of the gray image is calculated according to the gray values of all pixels, gray value segmentation points of the gray image are determined, then the minimum gray value and the maximum gray value of the gray image are acquired, a lower segmentation point of the gray image is determined according to the segmentation threshold value and the minimum gray value, an upper segmentation point of the gray image is determined according to the segmentation threshold value and the maximum gray value, so that the pixels in the gray image are divided into three sections, then pixels in different sections are processed, specifically, gray values of pixels in the gray image are smaller than first pixels of the lower segmentation point are compressed, and gray values of pixels in the image are larger than second pixels of the upper segmentation point are compressed; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, wherein the information owned by the first pixel points and the second pixel points after gray value compression is reduced, and the information owned by the target pixel points after gray value stretching is inversely increased, and then generating a gray enhancement image according to the first pixel points, the second pixel points and the target pixel points after gray value stretching after gray value compression, so that the foreground picture information in the image is increased, and the background picture information is reduced, thereby highlighting the main body in the image and improving the image enhancement effect.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above.
Any reference to memory, storage, database, or other medium provided herein and used in embodiments may include non-volatile and/or volatile memory.
The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, apparatus, article or method that comprises the element.
The foregoing is merely a preferred embodiment of the present application and is not intended to limit the scope of the patent application.
All equivalent structures or equivalent flow changes made by the specification and the drawings of the application or directly or indirectly applied to other related technical fields are included in the protection scope of the application.

Claims (7)

1. An image enhancement method, comprising:
acquiring an image, and converting the image into a single-channel gray image;
acquiring the gray value of each pixel point of the gray image, and calculating the segmentation threshold value of the gray image according to the gray value of each pixel point;
acquiring a minimum gray value and a maximum gray value of the gray image, determining a lower segmentation point of the gray image according to the segmentation threshold and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold and the maximum gray value;
carrying out gray value compression on a first pixel point of which the gray value is smaller than that of the lower segmentation point in the gray image, and carrying out gray value compression on a second pixel point of which the gray value is larger than that of the upper segmentation point in the gray image; carrying out gray value stretching on a target pixel point, wherein the gray value of the pixel point in the gray image is larger than the gray value of the lower segmentation point and smaller than the gray value of the upper segmentation point, so as to obtain a gray enhanced image;
the compressing the gray value of the first pixel point of which the gray value is smaller than that of the lower segment point in the gray image, and the compressing the gray value of the second pixel point of which the gray value is larger than that of the upper segment point in the gray image, includes:
setting the gray value of a pixel point in the gray image smaller than the gray value of a first pixel point of the lower segmentation point to 0;
setting a gray value of a pixel point in the gray image to be 255, wherein the gray value of a second pixel point is larger than that of the upper segment point;
the step of stretching the gray value of the target pixel point of which the gray value of the pixel point in the gray image is larger than the gray value of the lower segmentation point and smaller than the gray value of the upper segmentation point comprises the following steps:
inputting the gray value of the target pixel point into a preset stretching function, and stretching the gray value of the target pixel point based on the stretching function, wherein the stretching function is a linear function;
the preset stretching function is as follows:
wherein f (x, y) is the gray value of the target pixel before gray value stretching, f (x, y) is the gray value of the target pixel after gray value stretching, t1 is the lower segment point, and t2 is the upper segment point.
2. The image enhancement method according to claim 1, wherein the acquiring the gray value of each pixel of the gray image, calculating the segmentation threshold of the gray image according to the gray value of each pixel, comprises:
acquiring gray values of all pixel points of the gray image;
selecting a segmentation parameter value;
acquiring the number proportion of foreground points and a first average gray value of the foreground points, and the number proportion of background points and a second average gray value of the background points; the foreground points are pixel points with gray values smaller than the segmentation parameter values, and the background points are pixel points with gray values larger than the segmentation parameter values;
calculating the gray variance of the gray image according to the number proportion of the foreground points, the first average gray value, the number proportion of the background points and the second average gray value;
and when the value of the gray variance is maximum, determining the segmentation parameter value as a segmentation threshold value of the gray image.
3. The image enhancement method according to claim 1, further comprising, after the obtaining the grayscale enhanced image:
acquiring pixel information of the gray enhanced image;
and if the pixel information of the gray enhancement image does not meet the preset requirement, executing the image enhancement method again on the gray enhancement image.
4. The image enhancement method according to claim 1, further comprising, after the obtaining the grayscale enhanced image:
and recovering the gray enhancement image into a multi-channel color image.
5. An image enhancement device for performing the image enhancement method of any of claims 1-4, comprising:
and a conversion module: the method comprises the steps of acquiring an image, and converting the image into a single-channel gray image;
the calculation module: the method comprises the steps of obtaining gray values of all pixel points of the gray image, and calculating a segmentation threshold value of the gray image according to the gray values of all pixel points;
and a segmentation module: the method comprises the steps of obtaining a minimum gray value and a maximum gray value of a gray image, determining a lower segmentation point of the gray image according to a segmentation threshold value and the minimum gray value, and determining an upper segmentation point of the gray image according to the segmentation threshold value and the maximum gray value;
compression and stretching module: the gray value compression method comprises the steps of compressing gray values of first pixel points, of which the gray values are smaller than those of the lower segmentation points, in the gray image, and compressing gray values of second pixel points, of which the gray values of the pixel points are larger than those of the upper segmentation points, in the gray image; and carrying out gray value stretching on the target pixel points, of which the gray values of the pixel points in the gray image are larger than those of the lower segmentation points and smaller than those of the upper segmentation points, so as to obtain a gray enhanced image.
6. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the image enhancement method of any of claims 1 to 4 when the computer program is executed.
7. A computer readable storage medium having stored thereon a computer program, characterized in that the computer program when executed by a processor realizes the steps of the image enhancement method according to any of claims 1 to 4.
CN202110476942.7A 2021-04-29 2021-04-29 Image enhancement method, device, computer equipment and storage medium Active CN113160087B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110476942.7A CN113160087B (en) 2021-04-29 2021-04-29 Image enhancement method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110476942.7A CN113160087B (en) 2021-04-29 2021-04-29 Image enhancement method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113160087A CN113160087A (en) 2021-07-23
CN113160087B true CN113160087B (en) 2024-03-19

Family

ID=76872825

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110476942.7A Active CN113160087B (en) 2021-04-29 2021-04-29 Image enhancement method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113160087B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114500498B (en) * 2021-12-28 2023-12-08 武汉联影医疗科技有限公司 DICOM file transmission and storage method, system, equipment and storage medium
CN113521683B (en) * 2021-08-27 2022-08-05 吉林师范大学 Intelligent physical ability comprehensive training control system
CN114298985B (en) * 2021-12-16 2023-12-22 苏州凌云光工业智能技术有限公司 Defect detection method, device, equipment and storage medium
CN114937097B (en) * 2022-02-23 2023-12-08 广州市巨应信息科技有限公司 Intelligent image compression method based on big data

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006237657A (en) * 2003-06-25 2006-09-07 Nikon Corp Image processing apparatus, image correction program, and recording medium
CN112348763A (en) * 2020-11-09 2021-02-09 西安宇视信息科技有限公司 Image enhancement method, device, electronic equipment and medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006237657A (en) * 2003-06-25 2006-09-07 Nikon Corp Image processing apparatus, image correction program, and recording medium
CN112348763A (en) * 2020-11-09 2021-02-09 西安宇视信息科技有限公司 Image enhancement method, device, electronic equipment and medium

Also Published As

Publication number Publication date
CN113160087A (en) 2021-07-23

Similar Documents

Publication Publication Date Title
CN113160087B (en) Image enhancement method, device, computer equipment and storage medium
CN111523414A (en) Face recognition method and device, computer equipment and storage medium
CN110059700B (en) Image moire recognition method and device, computer equipment and storage medium
CN109934262B (en) Picture variability judging method, device, computer equipment and storage medium
CN106875408B (en) Screenshot method and device and terminal equipment
CN109903272B (en) Target detection method, device, equipment, computer equipment and storage medium
CN111507298B (en) Face detection method, device, computer equipment and storage medium
CN112381092B (en) Tracking method, tracking device and computer readable storage medium
CN110909665A (en) Multitask image processing method and device, electronic equipment and storage medium
CN113179421A (en) Video cover selection method and device, computer equipment and storage medium
CN116091781A (en) Data processing method and device for image recognition
CN113065553A (en) Data processing method and device, three-dimensional scanning system and electronic device
CN111179245B (en) Image quality detection method, device, electronic equipment and storage medium
CN111768406A (en) Cell image processing method, device, equipment and storage medium
CN111008604A (en) Prediction image acquisition method and device, computer equipment and storage medium
CN116385898A (en) Satellite image processing method and system
CN116596903A (en) Defect identification method, device, electronic equipment and readable storage medium
CN113220859B (en) Question answering method and device based on image, computer equipment and storage medium
CN116612272A (en) Intelligent digital detection system for image processing and detection method thereof
CN112699809B (en) Vaccinia category identification method, device, computer equipment and storage medium
CN113139590B (en) Dimension reduction method and device for time series data, computer equipment and storage medium
CN112465037B (en) Target detection method, device, computer equipment and storage medium
CN111626288B (en) Data processing method, device, computer equipment and storage medium
CN109934870B (en) Target detection method, device, equipment, computer equipment and storage medium
CN118365973B (en) Multi-feature information fusion-based hybrid line state evaluation method and system

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
GR01 Patent grant