Image gray scale correction method and device, equipment, storage medium and product
By determining the color category of the image and the grayscale mean of the central rectangular area, performing grayscale projection and pixel-level compensation, the problem of local inhomogeneity in image grayscale correction is solved, and better image optimization effect is achieved.
Patent Information
- Application Number
- CN202510613899.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-12
AI Technical Summary
In the prior art, there is local grayscale unevenness in the image grayscale correction process, resulting in poor image optimization effect, especially when processing color images, it is difficult to balance the coordination of brightness and chromaticity channels.
By determining the color category of the image to be processed, especially when the gray-white image, the gray-scale mean value of the central rectangular area is determined, and gray-scale projection and pixel-level compensation are performed, a gray-scale equalization map image is constructed to achieve pixel-level compensation to improve image gray-scale uniformity.
It improves the uniformity and compensation effect of image grayscale correction, avoids the problem of local grayscale unevenness, and ensures that color images do not have color distortion during the grayscale correction process.
Smart Images

Figure CN120471814A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image grayscale correction method, device, equipment, storage medium and product. Background Art
[0002] Traditional image processing technology generally uses global histogram equalization or local area filtering to correct image grayscale. However, the above methods will lead to uneven local grayscale of the image, and when facing color images, it is difficult to balance the coordination of brightness and chrominance channels, resulting in poor image optimization effects and difficulty in meeting actual optimization needs.
[0003] The above content is only used to assist in understanding the technical solution of the present invention and does not constitute an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of the present invention is to provide an image grayscale correction method, device, equipment, storage medium and product, aiming to solve the technical problem in the existing technology that local grayscale unevenness exists in the image grayscale correction process, resulting in poor image optimization effect.
[0005] To achieve the above object, the present invention provides an image grayscale correction method, which includes the following steps:
[0006] Determine the color category of the image to be processed;
[0007] When the image to be processed is a gray-white image, determining a central rectangular area of the image to be processed, and calculating a grayscale mean value of the central rectangular area;
[0008] Performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image;
[0009] A target image is obtained by performing pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean.
[0010] Optionally, performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image includes:
[0011] Constructing a projection image corresponding to the image to be processed;
[0012] Performing horizontal grayscale projection on the image to be processed to obtain a horizontal grayscale array;
[0013] Smoothing the horizontal grayscale array to obtain a target grayscale array;
[0014] The target grayscale array is filled into the projection image to obtain a grayscale balanced mapping image.
[0015] Optionally, the smoothing the horizontal grayscale array to obtain a target grayscale array includes:
[0016] Converting the horizontal grayscale array into a grayscale projection function;
[0017] The grayscale projection function is smoothed by a preset smoothing function to obtain a target grayscale array.
[0018] Optionally, performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image includes:
[0019] Calculating the image pixel difference between the image to be processed and the grayscale balanced mapping image;
[0020] Grayscale uniformity processing is performed according to the image pixel difference and the grayscale mean to obtain a target image.
[0021] Optionally, the performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image further includes:
[0022] Rotating the target image to obtain a rotated grayscale image;
[0023] Based on the rotated grayscale image as the image to be processed, the central rectangular area of the image to be processed is determined, and the grayscale mean of the central rectangular area is calculated; a projection image corresponding to the image to be processed is constructed; grayscale projection is performed on the image to be processed to obtain a grayscale balanced mapping image; pixel-level compensation is performed based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, and output a rotation direction correction mapping matrix;
[0024] The rotation direction correction mapping matrix is restored to obtain the target image.
[0025] Optionally, the image grayscale correction method further includes:
[0026] When the image to be processed is a color image, converting the image to be processed into an HSV color space to obtain a hue image, a saturation image, and a brightness image;
[0027] Based on the brightness image as the image to be processed, determining the central rectangular area of the image to be processed, and calculating the grayscale mean of the central rectangular area;
[0028] Performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image;
[0029] A step of performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean value to obtain a target brightness image;
[0030] The target brightness image, the hue image, and the saturation image are restored into an RGB image to obtain a target image.
[0031] In addition, to achieve the above-mentioned object, the present invention further provides an image grayscale correction device, the image grayscale correction device comprising:
[0032] A determination module, used for determining the color category of the image to be processed;
[0033] a calculation module, configured to determine a central rectangular area of the image to be processed and calculate a grayscale mean of the central rectangular area when the image to be processed is a gray-white image;
[0034] A projection module, configured to perform grayscale projection on the image to be processed to obtain a grayscale balanced mapping image;
[0035] The compensation module is used to perform pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also proposes an image grayscale correction device, which includes: a memory, a processor, and an image grayscale correction program stored on the memory and runnable on the processor, and the image grayscale correction program is configured to implement the steps of the image grayscale correction method described above.
[0037] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which an image grayscale correction program is stored. When the image grayscale correction program is executed by a processor, the steps of the image grayscale correction method described above are implemented.
[0038] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the image grayscale correction method described above are implemented.
[0039] The present invention determines the color category of an image to be processed; when the image to be processed is a gray-white image, determines the central rectangular area of the image to be processed and calculates the grayscale mean of the central rectangular area; constructs a projection image corresponding to the image to be processed; performs grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; performs pixel-level compensation based on the image to be processed, the grayscale balanced mapping image and the grayscale mean to obtain a target image, and by constructing a grayscale projection image of the image to be processed and performing pixel-level compensation in combination with the grayscale mean of the central rectangular area of the image to be processed, the grayscale uniformity of the image and the image compensation effect are improved, thereby avoiding the technical problem in the prior art that local grayscale unevenness exists in the image grayscale correction process, resulting in poor image optimization effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0042] Figure 1 1 is a flow chart of a first embodiment of an image grayscale correction method according to the present invention;
[0043] Figure 2 2 is a flow chart of a second embodiment of the image grayscale correction method of the present invention;
[0044] Figure 3 1 is a flow chart of a third embodiment of the image grayscale correction method of the present invention;
[0045] Figure 4 This is a structural block diagram of a first embodiment of an image grayscale correction device according to the present invention;
[0046] Figure 5 It is a structural diagram of an image grayscale correction device in a hardware operating environment involved in an embodiment of the present invention.
[0047] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0049] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0050] Based on this, the embodiment of the present invention provides an image grayscale correction method, referring to Figure 1 , Figure 1 FIG1 is a flow chart of a first embodiment of an image grayscale correction method according to the present invention.
[0051] In this embodiment, the image grayscale correction method includes:
[0052] Step S10: Determine the color category of the image to be processed.
[0053] Step S20: When the image to be processed is a gray-white image, a central rectangular area of the image to be processed is determined, and a grayscale mean value of the central rectangular area is calculated.
[0054] Step S30: performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image.
[0055] Step S40: performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image.
[0056] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, a control computer, etc. The following describes this embodiment and the following embodiments using a control computer as an example.
[0057] It is understandable that image grayscale correction is mainly aimed at grayscale images and color images. There are differences in grayscale correction actions for different types of images. This embodiment takes grayscale images as an example for explanation.
[0058] The central rectangular area of the image to be processed refers to the central rectangular area CentROI constructed based on the geometric center coordinates (R, C) of the image to be processed and the adaptive step size parameters n1 and n2 using the dynamic weight center positioning algorithm. It is different from the true geometric center. Specifically, the formula for locating the central rectangular area using the dynamic weight center positioning algorithm is:
[0059]
[0060] Wherein, R is the horizontal coordinate of the geometric center coordinate of the image to be processed, C is the vertical coordinate of the geometric center coordinate of the image to be processed, W is the length of the image to be processed, H is the width of the image to be processed, and n1 and n2 are adaptive compensation parameters.
[0061] Specifically, calculating the grayscale mean of the central rectangular area refers to calculating the grayscale mean MeanT of the central area CentROI on the image Image1. When the parameter MeanVa!=-1 is set, MeanVa is assigned to MeanT, otherwise the original value is used. The formula is as follows:
[0062]
[0063] Where CenROI is the dynamic center area, I(x,y) is the image pixel grayscale value
[0064] Furthermore, performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image includes:
[0065] Constructing a projection image corresponding to the image to be processed;
[0066] Performing horizontal grayscale projection on the image to be processed to obtain a horizontal grayscale array;
[0067] Smoothing the horizontal grayscale array to obtain a target grayscale array;
[0068] The target grayscale array is filled into the projection image to obtain a grayscale balanced mapping image.
[0069] In a specific implementation, constructing the projection image corresponding to the image to be processed can be to copy the image to be processed to obtain an image whose parameters are completely consistent with the image to be processed, so as to facilitate the subsequent filling of the grayscale array. Performing horizontal grayscale projection on the image to be processed to obtain the horizontal grayscale array means performing a horizontal grayscale projection operation on the image. The horizontal grayscale array HorGrayVa of the image is obtained, and after smoothing the horizontal grayscale array HorGrayVa, HorGrayVa2 is obtained. Then HorGrayVa2 is filled into the projected image to obtain a grayscale balanced mapping image.
[0070] Furthermore, the smoothing process is performed on the horizontal grayscale array to obtain a target grayscale array, including:
[0071] Converting the horizontal grayscale array into a grayscale projection function;
[0072] The grayscale projection function is smoothed by a preset smoothing function to obtain a target grayscale array.
[0073] Specifically, the grayscale projection array HorGrayVa is converted into a continuous function f(x) with the image width as the x-axis and the grayscale value as the y-axis. The grayscale projection data f(x) is smoothed, and the preset smoothing function is SmoothSize. The smoothed grayscale array HorGrayVa2 is obtained. The formula is as follows:
[0074]
[0075] Among them, SmoothSize=2k+1 is the smoothing window size.
[0076] This embodiment determines the color category of the image to be processed; when the image to be processed is a gray-white image, determines the central rectangular area of the image to be processed and calculates the grayscale mean of the central rectangular area; constructs a projection image corresponding to the image to be processed; performs grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; performs pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image. By constructing a grayscale projection image of the image to be processed and performing pixel-level compensation based on the grayscale mean of the central rectangular area of the image to be processed, the image grayscale uniformity and the image compensation effect are improved, thereby avoiding the technical problem of local grayscale unevenness in the image grayscale correction process in the prior art, which leads to poor image optimization effect.
[0077] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 Step S40 includes:
[0078] Step S401: Calculating the image pixel difference between the image to be processed and the grayscale balanced mapping image.
[0079] Step S402: performing grayscale uniformization processing according to the image pixel difference and the grayscale mean to obtain a target image.
[0080] It should be noted that grayscale equalization is achieved by grayscale difference calculation. The grayscale equalization mapping image Image3 is subtracted from the processed image Image1 to obtain the image pixel difference, and then the grayscale mean MeanT is added to obtain the target image Image4.
[0081] The specific formula is:
[0082]
[0083] Among them I out (x,y) is Image4, I in That is Image1, Mxy That is Image3.
[0084] Furthermore, the pixel-level compensation is performed according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, further comprising:
[0085] Rotating the target image to obtain a rotated grayscale image;
[0086] Based on the rotated grayscale image as the image to be processed, the central rectangular area of the image to be processed is determined, and the grayscale mean of the central rectangular area is calculated; a projection image corresponding to the image to be processed is constructed; grayscale projection is performed on the image to be processed to obtain a grayscale balanced mapping image; pixel-level compensation is performed based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, and output a rotation direction correction mapping matrix;
[0087] The rotation direction correction mapping matrix is restored to obtain the target image.
[0088] In the specific implementation, the target image Image4(I in ) performs rotation transformation to generate a rotated grayscale image I rot , then use Xu Na's grayscale image as the image to be processed, and repeatedly perform the steps of determining the central rectangular area of the image to be processed and calculating the grayscale mean of the central rectangular area; constructing a projection image corresponding to the image to be processed; performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; performing pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image corresponding to the rotated grayscale image, and finally outputting a rotation direction correction mapping matrix.
[0089] Specifically, for the target image Image4(I in ) performs rotation transformation to generate a rotated grayscale image I rot :
[0090] I rot (u,v)=I rot (-v,u)
[0091] Repeat the correction process for I rot Perform image grayscale mean processing to generate the rotation direction correction mapping matrix M rot :
[0092]
[0093] The rotation correction result is restored to the original direction to obtain the final image ImageR.
[0094] This embodiment calculates the image pixel difference between the image to be processed and the grayscale equalization mapping image; performs grayscale equalization processing based on the image pixel difference and the grayscale mean to obtain a target image, and performs grayscale correction in the horizontal or vertical direction to improve the effect of image grayscale correction.
[0095] Based on the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction and will not be described in detail later. Figure 3 , after step S10, further comprising:
[0096] Step S20: When the image to be processed is a color image, convert the image to be processed into the HSV color space to obtain a hue image, a saturation image, and a brightness image;
[0097] Step S30 : Based on the brightness image as the image to be processed, determine the central rectangular area of the image to be processed, and calculate the grayscale mean of the central rectangular area.
[0098] Step S40 : performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image.
[0099] Step S50 : performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target brightness image.
[0100] Step S60 : restoring the target brightness image, the hue image, and the saturation image into an RGB image to obtain a target image.
[0101] It should be noted that, since the color image needs to avoid color cast and color distortion after grayscale correction, when facing a color image, the color image can be converted from the RGB color space to the HSV color space to obtain a hue image, a saturation image, and a brightness image. At this time, in order to avoid color distortion, when performing grayscale correction, only the brightness image can be processed, and the brightness image can be used as the image to be processed. The contents described in the first and second embodiments above are repeated to perform image grayscale mean processing on the brightness image to obtain the target brightness image V corr , and the corrected target brightness image V corr , merged with the original hue image and saturation image, and restored to the RGB color space to achieve grayscale correction of the color image without color distortion.
[0102] This embodiment converts the image to be processed into the HSV color space when the image to be processed is a color image to obtain a hue image, a saturation image, and a brightness image; based on the brightness image as the image to be processed, determines the central rectangular area of the image to be processed, and calculates the grayscale mean of the central rectangular area; performs grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; performs pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target brightness image; and restores the target brightness image, the hue image, and the saturation image to an RGB image to obtain a target image, thereby achieving grayscale correction of the color image without color distortion.
[0103] This application also provides an image grayscale correction device, please refer to Figure 4 , the image grayscale correction device includes:
[0104] The determination module 10 is used to determine the color category of the image to be processed.
[0105] The calculation module 20 is configured to determine a central rectangular area of the image to be processed and calculate a grayscale mean value of the central rectangular area when the image to be processed is a gray-white image.
[0106] The projection module 30 is used to perform grayscale projection on the image to be processed to obtain a grayscale balanced mapping image.
[0107] The compensation module 40 is configured to perform pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image.
[0108] In one embodiment, the projection module 30 is further used to construct a projection image corresponding to the image to be processed; perform horizontal grayscale projection on the image to be processed to obtain a horizontal grayscale array; smooth the horizontal grayscale array to obtain a target grayscale array; and fill the target grayscale array into the projection image to obtain a grayscale balance mapping image.
[0109] In one embodiment, the projection module 30 is further configured to convert the horizontal grayscale array into a grayscale projection function; and smooth the grayscale projection function using a preset smoothing function to obtain a target grayscale array.
[0110] In one embodiment, the compensation module 40 is further configured to calculate the image pixel difference between the image to be processed and the grayscale equalization mapping image; and perform grayscale equalization processing according to the image pixel difference and the grayscale mean to obtain a target image.
[0111] In one embodiment, the compensation module 40 is further used to rotate the target image to obtain a rotated grayscale image; based on the rotated grayscale image as the image to be processed, the central rectangular area of the image to be processed is returned and the grayscale mean of the central rectangular area is calculated; a projection image corresponding to the image to be processed is constructed; grayscale projection is performed on the image to be processed to obtain a grayscale balanced mapping image; pixel-level compensation is performed based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, so as to output a rotation direction correction mapping matrix; and the rotation direction correction mapping matrix is restored to obtain a target image.
[0112] In one embodiment, the determination module 10 is further used to convert the image to be processed into the HSV color space when the image to be processed is a color image to obtain a hue image, a saturation image, and a brightness image; based on the brightness image as the image to be processed, determine the central rectangular area of the image to be processed, and calculate the grayscale mean of the central rectangular area; perform grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; perform pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target brightness image; and restore the target brightness image, the hue image, and the saturation image to an RGB image to obtain a target image.
[0113] This embodiment determines the color category of the image to be processed; when the image to be processed is a gray-white image, determines the central rectangular area of the image to be processed and calculates the grayscale mean of the central rectangular area; constructs a projection image corresponding to the image to be processed; performs grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; performs pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image. By constructing a grayscale projection image of the image to be processed and performing pixel-level compensation based on the grayscale mean of the central rectangular area of the image to be processed, the image grayscale uniformity and the image compensation effect are improved, thereby avoiding the technical problem of local grayscale unevenness in the image grayscale correction process in the prior art, which leads to poor image optimization effect.
[0114] The present application provides an image grayscale correction device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the image grayscale correction method in the above-mentioned embodiment one.
[0115] Reference below Figure 5, which shows a schematic structural diagram of an image grayscale correction device suitable for implementing the embodiments of the present application. The image grayscale correction device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The image grayscale correction device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0116] like Figure 5 As shown, the image grayscale correction device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the image grayscale correction device. The processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the image grayscale correction device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an image grayscale correction device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0117] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0118] The image grayscale correction device provided in this application utilizes the image grayscale correction method described in the aforementioned embodiment to address the technical issues surrounding image grayscale correction. Compared to the prior art, the image grayscale correction device provided in this application achieves the same beneficial effects as the image grayscale correction method described in the aforementioned embodiment. Other technical features of the image grayscale correction device are the same as those disclosed in the aforementioned embodiment and are not further elaborated upon here.
[0119] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0120] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0121] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, wherein the computer-readable program instructions are used to execute the image grayscale correction method in the above-mentioned embodiment.
[0122] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0123] The computer-readable storage medium may be included in the image grayscale correction device; or may exist independently without being assembled into the image grayscale correction device.
[0124] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the image grayscale correction device, the image grayscale correction device performs image grayscale correction.
[0125] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0126] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0127] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0128] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned image grayscale correction method, thereby resolving the technical issues associated with image grayscale correction. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are similar to those of the image grayscale correction method provided in the aforementioned embodiments and are not further elaborated here.
[0129] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned image grayscale correction method when executed by a processor.
[0130] The computer program product provided in this application can solve the technical problem of image grayscale correction. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the image grayscale correction method provided in the above embodiment, and will not be repeated here.
[0131] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for image grayscale correction, characterized in that: The image grayscale correction method comprises: Determine the color category of the image to be processed; When the image to be processed is a gray-white image, determining a central rectangular area of the image to be processed, and calculating a grayscale mean value of the central rectangular area; Performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; A target image is obtained by performing pixel-level compensation based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean.
2. The image grayscale correction method according to claim 1, wherein: The grayscale projection of the image to be processed to obtain a grayscale balanced mapping image includes: Constructing a projection image corresponding to the image to be processed; Performing horizontal grayscale projection on the image to be processed to obtain a horizontal grayscale array; Smoothing the horizontal grayscale array to obtain a target grayscale array; The target grayscale array is filled into the projection image to obtain a grayscale balanced mapping image.
3. The image grayscale correction method according to claim 2, wherein: The smoothing process on the horizontal grayscale array to obtain a target grayscale array includes: Converting the horizontal grayscale array into a grayscale projection function; The grayscale projection function is smoothed by a preset smoothing function to obtain a target grayscale array.
4. The image grayscale correction method according to claim 1, wherein: The step of performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image includes: Calculating the image pixel difference between the image to be processed and the grayscale balanced mapping image; Grayscale uniformity processing is performed according to the image pixel difference and the grayscale mean to obtain a target image.
5. The image grayscale correction method according to claim 4, wherein: The pixel-level compensation is performed according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, further comprising: Rotating the target image to obtain a rotated grayscale image; Based on the rotated grayscale image as the image to be processed, the central rectangular area of the image to be processed is determined, and the grayscale mean of the central rectangular area is calculated; a projection image corresponding to the image to be processed is constructed; grayscale projection is performed on the image to be processed to obtain a grayscale balanced mapping image; pixel-level compensation is performed based on the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image, and output a rotation direction correction mapping matrix; The rotation direction correction mapping matrix is restored to obtain the target image.
6. The image grayscale correction method according to any one of claims 1 to 5, wherein: The image grayscale correction method further includes: When the image to be processed is a color image, converting the image to be processed into an HSV color space to obtain a hue image, a saturation image, and a brightness image; Based on the brightness image as the image to be processed, determining the central rectangular area of the image to be processed, and calculating the grayscale mean of the central rectangular area; Performing grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; A step of performing pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean value to obtain a target brightness image; The target brightness image, the hue image, and the saturation image are restored into an RGB image to obtain a target image.
7. An image grayscale correction device, characterized in that: The image grayscale correction device comprises: A determination module, used for determining the color category of the image to be processed; a calculation module, configured to determine a central rectangular area of the image to be processed and calculate a grayscale mean of the central rectangular area when the image to be processed is a gray-white image; A projection module, configured to perform grayscale projection on the image to be processed to obtain a grayscale balanced mapping image; The compensation module is used to perform pixel-level compensation according to the image to be processed, the grayscale balanced mapping image, and the grayscale mean to obtain a target image.
8. An image grayscale correction device, characterized in that: The image grayscale correction device includes: a memory, a processor, and an image grayscale correction program stored in the memory and executable on the processor, wherein the image grayscale correction program is configured to implement the image grayscale correction method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium stores an image grayscale correction program, and when the image grayscale correction program is executed by the processor, the image grayscale correction method according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the image grayscale correction method according to any one of claims 1 to 6 are implemented.