Image processing method, image processing device and readable storage medium
By segmenting image blocks and calculating the probability of gray level occurrence, and determining distribution matrices and curves, the problem of high image noise and poor enhancement effects is solved, and high-quality image processing is achieved.
Patent Information
- Application Number
- CN202410662500.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-05-27
AI Technical Summary
Image processing methods in the prior art have problems such as high image noise and poor enhancement effects.
By acquiring an image with M gray levels, dividing it into N non-overlapping image blocks, calculating the gray level occurrence probability of each image block, determining the gray level distribution matrix and gray level distribution curve, and updating the image to reduce noise and improve contrast.
It effectively suppresses image noise, improves image contrast and enhancement effects, and ensures image quality.
Smart Images

Figure CN118247171B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image processing method, an image processing device and a readable storage medium. Background Art
[0002] Due to the rapid development of image processing technology, observers have put forward higher requirements for the images output by display devices or systems. In response to this requirement, researchers will use image processing methods to improve the quality of images and improve the contrast of images to meet the requirements of observers. However, traditional image processing methods have technical problems such as more image noise. Summary of the invention
[0003] The present invention aims to at least solve the technical problems existing in the prior art or related art, such as more image noise and poor image enhancement effect.
[0004] To this end, a first aspect of the present invention is to propose an image processing method.
[0005] A second aspect of the present invention is to provide an image processing device.
[0006] A third aspect of the present invention is to provide another image processing device.
[0007] A fourth aspect of the present invention is to provide a readable storage medium.
[0008] In view of this, according to a first aspect of the present invention, an image processing method is proposed, the image processing method comprising: obtaining a first image, the first image being an image with M gray levels; dividing the first image into N image blocks, the N image blocks not overlapping each other; obtaining M×N occurrence probabilities based on the N image blocks, each image block corresponding to M occurrence probabilities of M gray levels, the occurrence probability being the probability of occurrence of a pixel point of the gray level in the image block; determining a distribution matrix of the M gray levels based on the M×N occurrence probabilities; determining a gray distribution curve based on the distribution matrix; and updating the first image based on the gray distribution curve to obtain a second image.
[0009] The image processing method in the present technical solution determines the distribution matrix of M gray levels according to M×N occurrence probabilities, and then determines the gray distribution curve according to the distribution matrix, and updates the first image to the second image. The information features of different areas of the image can be obtained through N image blocks, and the noise of the second image is suppressed. At the same time, the contrast of the second image is improved, and the image enhancement effect of the second image is guaranteed.
[0010] According to a second aspect of the present invention, an image processing device is proposed, which includes: a processing module for acquiring a first image, the first image being an image with M gray levels; the processing module is also used to divide the first image into N image blocks, the N image blocks do not overlap with each other; the processing module is also used to acquire M×N occurrence probabilities based on the N image blocks, each image block corresponds to M occurrence probabilities of M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of the gray level in the image block; the processing module is also used to determine a distribution matrix of the M gray levels based on the M×N occurrence probabilities; the processing module is also used to determine a gray distribution curve based on the distribution matrix; the processing module is also used to update the first image based on the gray distribution curve to obtain a second image.
[0011] The image processing device in the present technical solution determines a distribution matrix of M gray levels according to M×N occurrence probabilities, and then determines a gray distribution curve according to the distribution matrix, and updates the first image to the second image. The information features of different image regions can be obtained through N image blocks, thereby suppressing the noise of the second image. At the same time, the contrast of the second image is improved, thereby ensuring the image enhancement effect of the second image.
[0012] According to a third aspect of the present invention, another image processing device is provided, comprising a processor and a memory, wherein a program or instruction is stored in the memory, and when the program or instruction is executed by the processor, the steps of the image processing method in any of the above technical solutions are implemented. Therefore, the image processing device has all the beneficial effects of the image processing method in any of the above technical solutions, which will not be described in detail here.
[0013] According to a fourth aspect of the present invention, a readable storage medium is provided, on which a program or instruction is stored, and when the program or instruction is executed by a processor, an image processing method as in any of the above technical solutions is implemented. Therefore, the readable storage medium has all the beneficial effects of the image processing method in any of the above technical solutions, which will not be described in detail here.
[0014] Additional aspects and advantages of the present invention will become apparent from the following description or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0016] Figure 1 One of the flowcharts of the image processing method in the embodiment of the present invention is shown;
[0017] Figure 2 The second flowchart of the image processing method in the embodiment of the present invention is shown;
[0018] Figure 3 The third flowchart of the image processing method in the embodiment of the present invention is shown;
[0019] Figure 4 A fourth flowchart of the image processing method in an embodiment of the present invention is shown;
[0020] Figure 5 FIG5 shows a fifth flow chart of an image processing method in an embodiment of the present invention;
[0021] Figure 6 FIG6 shows a sixth flow chart of an image processing method in an embodiment of the present invention;
[0022] Figure 7 FIG7 shows a seventh flow chart of an image processing method in an embodiment of the present invention;
[0023] Figure 8 A schematic diagram showing an image processing method in an embodiment of the present invention;
[0024] Fig. 9 One of the structural block diagrams of the image processing device in the embodiment of the present invention is shown;
[0025] Fig.10 The second structural block diagram of the image processing device in the embodiment of the present invention is shown. DETAILED DESCRIPTION
[0026] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0027] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0028] Combine the following Figures 1 to 10 , the image processing method, image processing device and readable storage medium provided by the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0029] like Figure 1 As shown, an embodiment of the present invention provides an image processing method, the image processing method comprising:
[0030] Step 102, acquiring a first image;
[0031] Step 104, dividing the first image into N image blocks, where the N image blocks do not overlap each other;
[0032] Step 106, obtaining M×N occurrence probabilities according to the N image blocks;
[0033] Step 108, determining a distribution matrix of M gray levels based on the M×N occurrence probabilities;
[0034] Step 110, determining a grayscale distribution curve according to the distribution matrix;
[0035] Step 112: Update the first image according to the grayscale distribution curve to obtain a second image.
[0036] In this embodiment, an image processing method is proposed to acquire a first image, wherein the first image is an image with M gray levels, and the gray level is used to represent the color depth of the image.
[0037] Exemplarily, the first image may be an image acquired in real time and may have 256 gray levels.
[0038] Exemplarily, the first image may have 1024 gray levels.
[0039] The first image is divided into N image blocks, wherein the N image blocks are non-overlapping image blocks.
[0040] Exemplarily, the first image may be an image with a size of 1024×1024, and the first image is divided into 16 image blocks, each of which has a size of 256×256.
[0041] According to the N image blocks, M×N occurrence probabilities are obtained, wherein each image block corresponds to M occurrence probabilities of M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of a gray level in the image block.
[0042] Exemplarily, after the first image is divided into N image blocks, M occurrence probabilities of M gray levels in each image block are determined, thereby obtaining M×N occurrence probabilities of the M gray levels.
[0043] According to the M×N occurrence probabilities, a distribution matrix of the M gray levels is determined, wherein the distribution matrix is a matrix representing the distribution of the M gray levels.
[0044] Exemplarily, the distribution matrix of the M gray levels may be obtained by calculating the cumulative histogram of the M gray levels.
[0045] According to the distribution matrix, a grayscale distribution curve is determined, wherein the grayscale distribution curve is a curve representing the distribution of M grayscale levels.
[0046] Exemplarily, the grayscale distribution curve may be a calibrated distribution curve.
[0047] According to the grayscale distribution curve, the first image is updated to obtain a second image, wherein the second image is an enhanced image.
[0048] Exemplarily, the grayscale of the first image is adjusted according to the grayscale distribution curve, and the contrast of the first image is improved to obtain the second image.
[0049] The image processing method in this embodiment determines the distribution matrix of M gray levels based on M×N occurrence probabilities, and then determines the gray distribution curve based on the distribution matrix, and updates the first image to the second image. The information features of different image areas can be obtained through N image blocks, and the noise of the second image is suppressed. At the same time, the contrast of the second image is improved, and the image enhancement effect of the second image is guaranteed.
[0050] In some embodiments, optionally, Figure 2 As shown, an image processing method is proposed to obtain M×N occurrence probabilities according to N image blocks, including:
[0051] Step 202, obtaining N grayscale histograms corresponding to N image blocks;
[0052] Step 204, determining M×N occurrence probabilities according to the M×N occurrence counts.
[0053] In this embodiment, N grayscale histograms corresponding to N image blocks are obtained, wherein the grayscale histogram is used to represent the grayscale features of the image block, and each grayscale histogram includes M occurrence times of M grayscale levels in the image block, where the occurrence times are the number of occurrences of grayscale pixels in the image block.
[0054] For example, the grayscale histogram is H(x)={f1,f2,f3,…,f L}, where H(x) is the grayscale histogram, L is the number of grayscale levels, f1,f2,f3,…,f L is the number of times L gray levels appear.
[0055] Based on the M×N occurrence counts, determine the M×N occurrence probabilities.
[0056] Exemplarily, the M×N occurrence times correspond one-to-one to the M×N occurrence probabilities.
[0057] The image processing method in this embodiment determines M×N occurrence probabilities based on M×N occurrence times, thereby ensuring the data accuracy of the M×N occurrence probabilities and further ensuring the data accuracy of the distribution matrix.
[0058] In some embodiments, optionally, Figure 3As shown, an image processing method is proposed. Determining M×N occurrence probabilities according to M×N occurrence counts, including:
[0059] Step 302, obtaining the number of pixels in the image block;
[0060] Step 304, respectively calculating the ratios of M×N occurrence counts to the number of pixels to obtain M×N occurrence probabilities.
[0061] In this embodiment, the number of pixels in the image block is obtained, where the number of pixels is the number of pixel points in the image block.
[0062] Exemplarily, the number of pixels can be 256.
[0063] Respectively calculate the ratios of M×N occurrence counts to the number of pixels to obtain M×N occurrence probabilities.
[0064] Exemplarily, the calculation formula for the occurrence probability can be P i (k)=f k / N (0 < k < L), i represents the i-th image block, P i (k) represents the occurrence probability of the i-th image block, k represents the k-th gray level, f k is the occurrence probability of the k-th gray level, and N is the number of pixels.
[0065] The image processing method in this embodiment obtains M×N occurrence probabilities by respectively calculating the ratios of M×N occurrence counts to the number of pixels, ensuring the data accuracy of M×N occurrence probabilities, and further ensuring the data accuracy of the distribution matrix.
[0066] In some embodiments, optionally, as Figure 4 shown, an image processing method is proposed. Based on M×N occurrence probabilities, determining the distribution matrix of M gray levels, including:
[0067] Step 402, generating N cumulative histograms corresponding to N image blocks according to M×N occurrence probabilities;
[0068] Step 404, establishing a distribution matrix according to N cumulative histograms.
[0069] In this embodiment, N cumulative histograms corresponding to N image blocks are generated according to M×N occurrence probabilities, where the cumulative histogram is used to represent the gray cumulative probability of the image block.
[0070] Exemplarily, a random clipLimit (limit value) is selected, and the cumulative histogram is calculated according to a conventional CLAHE (Contrast Limited Adaptive Histogram Equalization) method.
[0071] A distribution matrix is established based on N cumulative histograms.
[0072] For example, according to the CDF (Cumulative Distribution Function, cumulative histogram) formula, a distribution matrix can be obtained.
[0073] The image processing method in this embodiment generates N cumulative histograms corresponding to N image blocks based on M×N occurrence probabilities, and then establishes a distribution matrix based on the N cumulative histograms, thereby ensuring the data accuracy of the distribution matrix and further ensuring the curve accuracy of the grayscale distribution curve.
[0074] In some embodiments, optionally, Figure 5 As shown, an image processing method is proposed to determine the grayscale distribution curve according to the distribution matrix, including:
[0075] Step 502, obtaining a preset expected matrix;
[0076] Step 504, setting the distribution matrix as input data, and setting the expected matrix as output data;
[0077] Step 506, determining the weight value corresponding to the distribution matrix according to the input data and the output data;
[0078] Step 508: Determine the grayscale distribution curve according to the weight value and the distribution matrix.
[0079] In this embodiment, a preset expected matrix is obtained, the distribution matrix is set as input data, and the expected matrix is set as output data, wherein the expected matrix is a preset matrix, the input data is the independent variable data, and the output data is the dependent variable data.
[0080] Exemplarily, the input data may be input data of an RLS (Recursive Least Squares) algorithm, and the output data may be output data of the RLS algorithm.
[0081] According to the input data and the output data, the weight value corresponding to the distribution matrix is determined, and then according to the weight value and the distribution matrix, the grayscale distribution curve is determined, wherein the weight value is the weight value corresponding to the distribution matrix.
[0082] Exemplarily, the expected matrix may be a uniformly varying linear output matrix.
[0083] The image processing method in this embodiment determines the weight value corresponding to the distribution matrix based on the input data and the output data, and then determines the grayscale distribution curve based on the weight value and the distribution matrix, thereby ensuring the data accuracy of the grayscale distribution curve and further ensuring the image quality of the second image.
[0084] In some embodiments, optionally, Figure 6 As shown, an image processing method is proposed, which determines the weight value corresponding to the distribution matrix according to the input data and the output data, including:
[0085] Step 602, performing data fitting on the input data and the output data according to the recursive least square method to determine the data correspondence relationship between the input data and the output data;
[0086] Step 604: Determine the weight value according to the data correspondence.
[0087] In this embodiment, data fitting is performed on the input data and the output data according to the recursive least square method to determine the data corresponding relationship between the input data and the output data, wherein the data corresponding relationship represents the fitting relationship between the input data and the output data.
[0088] Determine the weight value based on the data correspondence.
[0089] Exemplarily, the RLS algorithm is used to find the most appropriate weight value according to the input matrix, the expected output and the forgetting factor.
[0090] The image processing method in this embodiment performs data fitting on the input data and the output data according to the recursive least squares method to determine the data correspondence between the input data and the output data, and then determines the weight value based on the data correspondence, thereby ensuring the data accuracy of the weight value and further ensuring the curve accuracy of the grayscale distribution curve.
[0091] In some embodiments, optionally, Figure 7 As shown, an image processing method is proposed, which updates a first image according to a grayscale distribution curve to obtain a second image, including:
[0092] Step 702, obtaining the grayscale value corresponding to each pixel in the first image;
[0093] Step 704: update the grayscale value data according to the grayscale distribution curve to obtain a second image.
[0094] In this embodiment, the grayscale value corresponding to each pixel in the first image is obtained, wherein the grayscale value represents the grayscale level of the pixel.
[0095] Exemplarily, obtain the grayscale values corresponding to all pixel points in the first image.
[0096] According to the grayscale distribution curve, update the grayscale values to obtain the second image.
[0097] Exemplarily, use the cubic spline interpolation method to reconstruct the pixel grayscale values to obtain the second image.
[0098] Exemplarily, as Figure 8 shown, obtain the input first image, divide the first image into N image blocks, establish N grayscale histograms corresponding to the N image blocks, and then obtain the N cumulative histograms of the N image blocks, obtain the image distribution of the first image, determine the best fitting curve through the cumulative distribution function and the recursive least squares method, and then output the second image through the cubic spline interpolation method.
[0099] Exemplarily, divide the image into k non-overlapping sub-blocks of size m×n, where m and n are the length and width of the sub-blocks.
[0100] Calculate the grayscale histogram of each sub-block: The grayscale histogram is H(x)={f1,f2,f3,…,f L}, where H(x) is the grayscale histogram, L is the number of grayscale levels, and f1,f2,f3,…,f L are the number of occurrences of the L grayscale levels.
[0101] Calculate the occurrence probability of each grayscale level: P i (k)=f k / N (0 < k < L), i represents the i-th image block, P i (k) represents the occurrence probability of the i-th image block, k represents the k-th grayscale level, f k is the occurrence probability of the k-th grayscale level, N is the number of pixels, and L is the number of grayscale levels.
[0102] Select a random clipLimit (limit value) and calculate its cumulative histogram: , where P i (k) represents the occurrence probability of the i-th image block, k represents the k-th grayscale level, L is the number of grayscale levels, and CDF i (k) is the cumulative histogram of the k-th grayscale level in the i-th image block. According to the above formula, the distribution matrix X k of each grayscale level in the image can be obtained.
[0103] Take the distribution matrix X k as the input matrix, and use the RLS algorithm to find the most suitable weights according to the input matrix, the expected output D k and the forgetting factor λ. Where D kIt is a uniformly changing linear output matrix from 0 to L.
[0104] Generate the best fitting curve, which is the new CDF curve, and then use the cubic spline interpolation method to reconstruct the pixel grayscale value.
[0105] The image processing method in this embodiment updates the grayscale value data according to the grayscale distribution curve to obtain the second image, thereby improving the image quality of the second image.
[0106] The above methods may be implemented in various ways depending on the specific features and / or example applications. For example, the methods may be implemented by a combination of hardware, firmware, and / or software. For example, in a hardware implementation, the processor may be implemented in one or more application-specific integrated circuits, digital signal processors, digital signal processing devices, programmable logic devices, field programmable gate arrays, controllers, microcontrollers, microprocessors, electronic devices, other device units for performing the above functions, and / or combinations thereof.
[0107] like Fig. 9 As shown, an embodiment of the present invention provides an image processing device 900, and the image processing device 900 includes:
[0108] A processing module 902 is used to obtain a first image, where the first image is an image with M gray levels;
[0109] The processing module 902 is further configured to divide the first image into N image blocks, where the N image blocks do not overlap with each other;
[0110] The processing module 902 is further used to obtain M×N occurrence probabilities according to the N image blocks, where each image block corresponds to M occurrence probabilities of M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of a gray level in the image block;
[0111] The processing module 902 is further used to determine a distribution matrix of M gray levels based on the M×N occurrence probabilities;
[0112] The processing module 902 is further used to determine a grayscale distribution curve according to the distribution matrix;
[0113] The processing module 902 is further configured to update the first image according to the grayscale distribution curve to obtain a second image.
[0114] In this embodiment, an image processing device 900 is proposed, and a processing module 902 acquires a first image, wherein the first image is an image with M gray levels, and the gray level is used to represent the color depth of the image.
[0115] Exemplarily, the first image may be an image acquired in real time and may have 256 gray levels.
[0116] Exemplarily, the first image may have 1024 gray levels.
[0117] The processing module 902 divides the first image into N image blocks, wherein the N image blocks are non-overlapping image blocks.
[0118] Exemplarily, the first image may be an image with a size of 1024×1024, and the first image is divided into 16 image blocks, each of which has a size of 256×256.
[0119] The processing module 902 obtains M×N occurrence probabilities according to the N image blocks, wherein each image block corresponds to M occurrence probabilities of M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of a gray level in the image block.
[0120] Exemplarily, after the first image is divided into N image blocks, M occurrence probabilities of M gray levels in each image block are determined, thereby obtaining M×N occurrence probabilities of the M gray levels.
[0121] The processing module 902 determines a distribution matrix of M gray levels according to the M×N occurrence probabilities, wherein the distribution matrix is a matrix representing the distribution of the M gray levels.
[0122] Exemplarily, the distribution matrix of the M gray levels may be obtained by calculating the cumulative histogram of the M gray levels.
[0123] The processing module 902 determines a grayscale distribution curve according to the distribution matrix, wherein the grayscale distribution curve is a curve representing the distribution of M grayscale levels.
[0124] Exemplarily, the grayscale distribution curve may be a calibrated distribution curve.
[0125] The processing module 902 updates the first image according to the grayscale distribution curve to obtain a second image, wherein the second image is an enhanced image.
[0126] Exemplarily, the grayscale of the first image is adjusted according to the grayscale distribution curve, and the contrast of the first image is improved to obtain the second image.
[0127] The image processing device 900 in this embodiment determines a distribution matrix of M gray levels based on M×N occurrence probabilities, and then determines a gray distribution curve based on the distribution matrix, and updates the first image to the second image. The information features of different image regions can be obtained through N image blocks, thereby suppressing the noise of the second image. At the same time, the contrast of the second image is improved, thereby ensuring the image enhancement effect of the second image.
[0128] In some embodiments, optionally, the image processing device 900 further includes:
[0129] The processing module 902 is further used to obtain N grayscale histograms corresponding to the N image blocks, each grayscale histogram including M occurrence times of M grayscale levels in the image block;
[0130] The processing module 902 is further configured to determine M×N occurrence probabilities according to the M×N occurrence times.
[0131] The image processing device 900 in this embodiment determines M×N occurrence probabilities based on M×N occurrence times, thereby ensuring the data accuracy of the M×N occurrence probabilities and further ensuring the data accuracy of the distribution matrix.
[0132] In some embodiments, optionally, the image processing device 900 further includes:
[0133] The processing module 902 is further used to obtain the number of pixels of the image block;
[0134] The processing module 902 is further used to calculate the ratios of M×N occurrence times to the number of pixels respectively to obtain M×N occurrence probabilities.
[0135] The image processing device 900 in this embodiment calculates the ratios of M×N occurrence times to the number of pixels respectively to obtain M×N occurrence probabilities, thereby ensuring the data accuracy of the M×N occurrence probabilities and further ensuring the data accuracy of the distribution matrix.
[0136] In some embodiments, optionally, the image processing device 900 further includes:
[0137] The processing module 902 is further used to generate N cumulative histograms corresponding to the N image blocks according to the M×N occurrence probabilities;
[0138] The processing module 902 is further configured to establish a distribution matrix according to the N cumulative histograms.
[0139] The image processing device 900 in this embodiment generates N cumulative histograms corresponding to N image blocks based on M×N occurrence probabilities, and then establishes a distribution matrix based on the N cumulative histograms, thereby ensuring the data accuracy of the distribution matrix and further ensuring the curve accuracy of the grayscale distribution curve.
[0140] In some embodiments, optionally, the image processing device 900 further includes:
[0141] The processing module 902 is also used to obtain a preset expected matrix;
[0142] The processing module 902 is further used to set the distribution matrix as input data and the expected matrix as output data;
[0143] The processing module 902 is further used to determine the weight value corresponding to the distribution matrix according to the input data and the output data;
[0144] The processing module 902 is further used to determine the grayscale distribution curve according to the weight value and the distribution matrix.
[0145] The image processing device 900 in this embodiment determines the weight value corresponding to the distribution matrix based on the input data and the output data, and then determines the grayscale distribution curve based on the weight value and the distribution matrix, thereby ensuring the data accuracy of the grayscale distribution curve and further ensuring the image quality of the second image.
[0146] In some embodiments, optionally, the image processing device 900 further includes:
[0147] The processing module 902 is further used to perform data fitting on the input data and the output data according to the recursive least square method to determine the data correspondence relationship between the input data and the output data;
[0148] The processing module 902 is further used to determine the weight value according to the data correspondence.
[0149] The image processing device 900 in this embodiment performs data fitting on the input data and the output data according to the recursive least squares method to determine the data correspondence between the input data and the output data, and then determines the weight value based on the data correspondence, thereby ensuring the data accuracy of the weight value and further ensuring the curve accuracy of the grayscale distribution curve.
[0150] In some embodiments, optionally, the image processing device 900 further includes:
[0151] The processing module 902 is further used to obtain the gray value corresponding to each pixel in the first image;
[0152] The processing module 902 is further used to update the grayscale value data according to the grayscale distribution curve to obtain a second image.
[0153] The image processing device 900 in this embodiment updates the grayscale value data according to the grayscale distribution curve to obtain the second image, thereby improving the image quality of the second image.
[0154] In some embodiments, optionally, Fig.10 As shown, an image processing device 1000 is proposed, and the image processing device 1000 includes a processor 1002 and a memory 1004. The memory 1004 stores a program or instruction, and when the program or instruction is executed by the processor 1002, the steps of the image processing method in any of the above technical solutions are implemented. Therefore, the image processing device 1000 has all the beneficial effects of the image processing method in any of the above technical solutions, which will not be repeated here.
[0155] In some embodiments, optionally, a readable storage medium is provided on which a program or instruction is stored. When the program or instruction is executed by a processor, an image processing method as in any of the above embodiments is implemented, thereby having all the beneficial technical effects of the image processing method in any of the above embodiments.
[0156] The readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0157] A readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above devices, but is not limited thereto. A non-exhaustive list of more specific examples of computer-readable storage media includes: a portable computer floppy disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, a static random access memory, a portable optical disk read-only memory, a digital universal disk, a memory card, a floppy disk, a coding mechanical device (such as a punched card or a groove with a raised structure having instructions recorded thereon), and any suitable combination of the above devices. The computer-readable storage medium used herein should not be understood as a transmission signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium, or an electrical signal transmitted through a wire, etc.
[0158] It should be clarified that in the claims, specification and drawings of the present invention, the term "multiple" refers to two or more than two. Unless otherwise clearly defined, the orientation or position relationship indicated by the terms "upper" and "lower" is based on the orientation or position relationship shown in the drawings, which is only for the purpose of more conveniently describing the present invention and making the description process simpler, rather than indicating or implying that the device or element referred to must have the specific orientation described, be constructed and operated in a specific orientation, so these descriptions cannot be understood as limiting the present invention; the terms "connect", "install", "fix" and the like should be understood in a broad sense. For example, "connection" can be a fixed connection between multiple objects, or a detachable connection between multiple objects, or an integral connection; it can be a direct connection between multiple objects, or an indirect connection between multiple objects through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances of the above data.
[0159] In the claims, specification and drawings of the present invention, the description of the terms "one embodiment", "some embodiments", "specific embodiments" and the like means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In the claims, specification and drawings of the present invention, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0160] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An image processing method, characterized in that: The image processing method comprises: Acquire a first image, where the first image is an image with M gray levels; Dividing the first image into N image blocks, wherein the N image blocks do not overlap with each other; According to the N image blocks, M×N occurrence probabilities are obtained, each image block corresponds to M occurrence probabilities of the M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of the gray level in the image block; Based on the M×N occurrence probabilities, determining a distribution matrix of the M gray levels; According to the distribution matrix, determining a grayscale distribution curve; According to the grayscale distribution curve, updating the first image to obtain a second image; Determining the grayscale distribution curve according to the distribution matrix includes: Get the preset expectation matrix; Setting the distribution matrix as input data and setting the expectation matrix as output data; Determining a weight value corresponding to the distribution matrix according to the input data and the output data; Determining the grayscale distribution curve according to the weight value and the distribution matrix; The updating the first image according to the grayscale distribution curve to obtain a second image includes: Obtaining a grayscale value corresponding to each pixel in the first image; According to the grayscale distribution curve, updating the grayscale value to obtain the second image, wherein the pixel grayscale value is reconstructed using a cubic spline interpolation method to obtain the second image; The grayscale distribution curve is a calibrated distribution curve; The expected matrix is a uniformly changing linear output matrix.
2. The image processing method according to claim 1, characterized in that: The obtaining M×N occurrence probabilities according to the N image blocks includes: Obtaining N grayscale histograms corresponding to the N image blocks, each of the grayscale histograms including M occurrence times of the M grayscale levels in the image block; According to the M×N occurrence numbers, the M×N occurrence probabilities are determined.
3. The image processing method according to claim 2, characterized in that: The determining M×N occurrence probabilities according to the M×N occurrence times includes: Obtaining the number of pixels of the image block; The ratios of the M×N occurrence times to the number of pixels are calculated respectively to obtain the M×N occurrence probabilities.
4. The image processing method according to claim 1, characterized in that: The determining of the distribution matrix of the M gray levels based on the M×N occurrence probabilities comprises: Generating N cumulative histograms corresponding to the N image blocks according to the M×N occurrence probabilities; The distribution matrix is established according to the N cumulative histograms.
5. The image processing method according to claim 1, characterized in that: The step of determining a weight value corresponding to the distribution matrix according to the input data and the output data includes: Performing data fitting on the input data and the output data according to a recursive least squares method to determine a data correspondence relationship between the input data and the output data; The weight value is determined according to the data correspondence.
6. An image processing device, characterized in that: The image processing device comprises: A processing module, configured to acquire a first image, wherein the first image is an image having M gray levels; The processing module is further used to divide the first image into N image blocks, where the N image blocks do not overlap each other; The processing module is further used to obtain M×N occurrence probabilities according to the N image blocks, where each image block corresponds to the M occurrence probabilities of the M gray levels, and the occurrence probability is the probability of occurrence of a pixel point of the gray level in the image block; The processing module is further used to determine a distribution matrix of the M gray levels based on the M×N occurrence probabilities; The processing module is further used to determine a grayscale distribution curve according to the distribution matrix; The processing module is further used to update the first image according to the grayscale distribution curve to obtain a second image; The processing module is also used to obtain a preset expected matrix; Setting the distribution matrix as input data and setting the expectation matrix as output data; Determining a weight value corresponding to the distribution matrix according to the input data and the output data; Determining the grayscale distribution curve according to the weight value and the distribution matrix; The processing module is also used to obtain the gray value corresponding to each pixel in the first image; According to the grayscale distribution curve, updating the grayscale value to obtain the second image, wherein the pixel grayscale value is reconstructed using a cubic spline interpolation method to obtain the second image; The grayscale distribution curve is a calibrated distribution curve; The expected matrix is a uniformly changing linear output matrix.
7. An image processing device, characterized in that: include: processor; A memory, wherein a program or instruction is stored in the memory, and the processor implements the steps of the image processing method according to any one of claims 1 to 5 when executing the program or instruction in the memory.
8. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image processing method according to any one of claims 1 to 5 are implemented.
