A method and apparatus for processing a grayscale image
By using an automatic color level algorithm and thresholding, the problem of overexposure in fluorescent grayscale image stretching is solved, thereby improving contrast and brightness. It is suitable for processing various grayscale images.
Patent Information
- Application Number
- CN202310091645.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-09
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-02-09
AI Technical Summary
The conventional stretching method of fluorescence grayscale images easily leads to over-stretching, which causes part of the fluorescence signal to be overexposed, thus affecting the observation effect.
An automatic color level algorithm is used to determine the white and black thresholds by setting high and low truncation ratios. The image pixels are then re-divided based on these thresholds, and intermediate thresholds are introduced when necessary to avoid over-stretching and improve contrast and brightness.
It effectively avoids overexposure of fluorescence signals, improves image contrast and brightness, enhances the observation effect of weak fluorescence signals, reduces overexposure, and is suitable for image processing at different gray levels.
Smart Images

Figure CN116228574B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a grayscale image processing method and device. Background Art
[0002] Fluorescence imaging analysis is a visualization analysis technology currently widely used in live animal imaging. Fluorescence images can be captured using an infrared indium gallium arsenide (InGaAs) camera, and further research and analysis can be performed by analyzing the fluorescence signals detected in the fluorescence images.
[0003] Fluorescent grayscale images captured in existing technologies often have low contrast. Grayscale stretching is often used to improve contrast. Specifically, only image data within a specified grayscale range is retained. For example, grayscale values below a are set to zero, and grayscale values above b are set to the image's grayscale level. However, this stretching method can overstretch the image, potentially overexposing some fluorescent signals. Summary of the Invention
[0004] Therefore, the present invention aims to solve the technical problem in the prior art that the stretching method may over-stretch the image and cause part of the fluorescent signal to be overexposed, thereby providing a grayscale image processing method and device.
[0005] According to a first aspect, an embodiment of the present invention provides a grayscale image processing method, comprising the following steps: obtaining original grayscale data of a first image, wherein the original grayscale data includes grayscale values corresponding to each pixel of the first image;
[0006] Based on the preset high truncation ratio, the preset low truncation ratio and the original grayscale data, the pixels of the first image are eliminated, the grayscale values of the remaining pixels of the first image are counted, and the maximum grayscale value and the minimum grayscale value among the grayscale values of the remaining pixels of the first image are determined, and the maximum grayscale value is used as the white field threshold G max The minimum grayscale value is used as the black field threshold G min ;
[0007] When the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the grayscale values of the first image that are less than or equal to the black field threshold G are min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image;
[0008] When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the grayscale values of the first image that are less than or equal to the black field threshold G are min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
[0009] Optionally, according to the white field threshold G max And the black field threshold G min Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel, including:
[0010] Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid , and determine the intermediate threshold G mid The corresponding intermediate mapping gray value;
[0011] Greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Sure.
[0012] Optionally, the determination is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid ,include:
[0013] Determine whether the second preset multiple of the optimal threshold is within (G min , G max ), the optimal threshold is a threshold obtained by iteratively calculating the grayscale values of pixels in the first image;
[0014] If the second preset multiple of the optimal threshold is (G min , G max ), the value of the second preset multiple of the optimal threshold is used as the intermediate threshold Gmid ;
[0015] If the second preset multiple of the optimal threshold is not within (G min , G max ) range, it is determined whether the optimal threshold is within (G min , G max )
[0016] If the optimal threshold is (G min , G max ) range, then the optimal threshold and the white field threshold G max The average value is taken as the intermediate threshold G mid ;
[0017] If the optimal threshold is not within (G min , G max ) range, the black field threshold G min With the white field threshold G max The average value is taken as the intermediate threshold G mid .
[0018] Optionally, the optimal threshold is determined by the following steps:
[0019] Set the initial threshold T;
[0020] Determine a grayscale value corresponding to a first pixel R1 greater than the initial threshold T and a grayscale value corresponding to a second pixel R2 less than or equal to the initial threshold T in the original grayscale data;
[0021] Calculating a first mean of the grayscale values corresponding to the first pixel R1 and a second mean of the grayscale values corresponding to the second pixel R2;
[0022] Calculating an average of the first mean and the second mean to obtain a third mean;
[0023] Determining whether a difference between the third mean and the initial threshold T is within a preset range;
[0024] If so, determining the initial threshold T as the optimal threshold;
[0025] Otherwise, the third mean is used as the initial threshold T, and the above steps are re-executed to determine whether the new initial threshold T is the optimal threshold.
[0026] Optionally, the intermediate mapping grayscale value is determined by the following steps:
[0027] Calculate the initial mapping grayscale value V using the first preset function mid , the first preset function is the white field threshold Gmax , black field threshold G min , the intermediate threshold G mid and a relationship function between the gray levels of the first image;
[0028] The initial mapping gray value V mid A third preset multiple of is used as the intermediate mapping grayscale value.
[0029] Optionally, the first preset function is:
[0030]
[0031] Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, V mid is the initial mapping grayscale value, and M is the grayscale level of the first image.
[0032] Optionally, the grayscale image processing method further includes:
[0033] Obtaining a dark background image, and calculating an average value of the grayscale value of each pixel of the dark background image;
[0034] Calculating an analog amplification value, where the analog amplification value is a ratio of the grayscale of the first image to the maximum grayscale value Max of the first image;
[0035] Calculating a background value of the first image according to an average value of the grayscale values of each pixel of the dark background image and the simulated amplification value;
[0036] The value greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Determine, including:
[0037] Greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min And the background value of the first image is determined to be greater than the intermediate threshold Gmid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max And the background value of the first image is determined.
[0038] Optionally, the grayscale image processing method further includes: performing Laplace sharpening processing on the target image to obtain a second image; superimposing the target image with the second image, or superimposing it with the product of the sharpening coefficient of the second image, to obtain the sharpened target image.
[0039] Optionally, when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula:
[0040]
[0041] When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula:
[0042]
[0043] Among them, G max is the white field threshold, G min is the black field threshold, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0044] Optionally, when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula:
[0045]
[0046] Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, G point is the intermediate mapping grayscale value, M is the grayscale of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0047] According to a second aspect, an embodiment of the present invention provides a grayscale image processing device, comprising:
[0048] an acquisition module, configured to acquire original grayscale data of a first image, wherein the original grayscale data includes a grayscale value corresponding to each pixel of the first image;
[0049] A culling module is configured to cull pixels of the first image based on a preset high truncation ratio, a preset low truncation ratio, and the original grayscale data, calculate the grayscale values of the remaining pixels of the first image, and determine the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image, and use the maximum grayscale value as the white field threshold G max The minimum grayscale value is used as the black field threshold G min ;
[0050] The first generating module is used to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image;
[0051] The second generating module is used to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is less than or equal to the first preset multiple of the grayscale level of the first image. min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
[0052] According to a third aspect, an embodiment of the present invention provides a computer device comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above-mentioned grayscale image processing method by executing the computer instructions.
[0053] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the above-mentioned grayscale image processing method.
[0054] The technical solution of the present invention has the following advantages:
[0055] In the embodiment of the present invention, the two situations of the presence of a high effective fluorescence signal and the absence of a high effective fluorescence signal in the first image are fully considered. When a high effective fluorescence signal exists, the grayscale value of each pixel of the first image is re-determined according to three threshold intervals, which are respectively less than the black field threshold G min , greater than the black field threshold G min And less than the white field threshold G max and greater than the white field threshold G max , which can fully improve the contrast of the first image; when there is no high effective fluorescence signal, the gray value of each pixel of the first image is determined according to two threshold intervals, which are less than the black field threshold G min and greater than the black field threshold G min , and the maximum grayscale value Max of the first image is used as the white field threshold G max The calculation is performed to avoid the overexposure of part of the fluorescent signal due to overstretching of the first image, thereby improving the observation effect. In addition, in this embodiment, the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image are re-determined according to the preset high cutoff ratio and the preset low cutoff ratio, and the maximum grayscale value of the grayscale values of the remaining pixels is used as the white field threshold G max , the minimum gray value is used as the black field threshold G min , further based on the re-determined white field threshold G max With black field threshold G min Redetermining the grayscale value of each pixel in the first image reduces overexposure in the target image while increasing its overall brightness, thereby enhancing the first image. Furthermore, in this embodiment, there is no need to customize the grayscale value for stretching. The automatic color scale algorithm effectively determines the stretching threshold, reduces overexposure, and effectively enhances weak fluorescence signals in fluorescent grayscale images. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0057] Figure 1 This is a flowchart of a specific example of a grayscale image processing method in Example 1 of the present application;
[0058] Figure 2 This is a function diagram of a specific example of the traditional grayscale image stretching method in Example 1 of the present application;
[0059] Figure 3 This is a schematic diagram of a specific example in which the first image in Example 1 of the present application is a fluorescent low-grayscale image;
[0060] Figure 4 This is a schematic diagram of a specific example in which the first image in Example 1 of the present application is a fluorescent high-grayscale image;
[0061] Figure 5 This is a schematic diagram of a specific example of processing the first image, which is a fluorescent low-grayscale image, in Example 1 of the present application;
[0062] Figure 6 This is a schematic diagram of a specific example of processing the first image, which is a fluorescent high-grayscale image, in Example 1 of the present application;
[0063] Figure 7 This is a function diagram of a specific example of stretching transformation of a fluorescent low-grayscale image in Example 1 of the present application;
[0064] Figure 8 This is a function diagram of a specific example of stretching transformation of a fluorescent high grayscale image in Example 1 of the present application;
[0065] Figure 9 This is a flowchart of a specific example of determining the intermediate threshold in Example 1 of the present application;
[0066] Figure 10 This is a flowchart of a specific example of determining the optimal threshold in Example 1 of the present application;
[0067] Figure 11 This is a flowchart of a specific example of the first image processing process in Example 1 of the present application;
[0068] Figure 12 This is a principle block diagram of a specific example of a grayscale image processing device in Example 2 of the present application;
[0069] Figure 13 This is a structural diagram of a specific example of a computer device in Example 3 of the present application. DETAILED DESCRIPTION
[0070] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0071] In the description of the present invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0072] In the description of the present invention, it should be noted that, unless otherwise expressly specified or limited, the terms "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components; wireless connections or wired connections. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.
[0073] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0074] Example 1
[0075] This embodiment provides a grayscale image processing method, which can be executed by a server or terminal device, and performs pixel truncation, threshold determination, discrimination, and output of a target image through the server or terminal device, thereby achieving grayscale image processing, such as Figure 1 As shown, the following steps are included:
[0076] Step S101 : acquiring original grayscale data of a first image, wherein the original grayscale data includes grayscale values corresponding to each pixel of the first image.
[0077] The traditional grayscale image stretching method is to customize the grayscale values within a certain grayscale interval, that is, the grayscale values in the image within the range [a, b] can be stretched to between [c, d], such as Figure 2 As shown, Mf is the grayscale of the f(x, y) image, and Mg is the grayscale of the g(x, y) image. In practical applications, only image data within a specified grayscale range is retained. Specifically, grayscale values below a are set to zero, and grayscale values above b are set to the image's grayscale (for example, 255 for an 8-bit image) to highlight the effective fluorescence signal. In embodiments of the present invention, an automatic color scale algorithm can be used to stretch the fluorescence grayscale image, as follows.
[0078] The first image may be a fluorescent grayscale image, such as Figure 3 or Figure 4 As shown, Figure 3 The first image in is a fluorescence low grayscale image, Figure 4 The first image in the image is a fluorescent high-grayscale image. Histogram statistics are performed on the first image to calculate the number of pixels at each grayscale level in the first image and the cumulative distribution function of each grayscale level. For example, taking the first image as an 8-bit image, the grayscale level of the first image is 255, and its grayscale value is 0-255. The number of pixels corresponding to each grayscale value and the cumulative distribution function are counted to be used for truncation of pixels in the first image. The original grayscale data can include the grayscale value corresponding to each pixel in the first image, and can also include the number of pixels corresponding to each grayscale value and the cumulative distribution function.
[0079] Step S102: Based on the preset high truncation ratio, the preset low truncation ratio and the original grayscale data, the pixels of the first image are removed, the grayscale values of the remaining pixels of the first image are counted, and the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image are determined, and the maximum grayscale value is used as the white field threshold G. max The minimum grayscale value is used as the black field threshold G min .
[0080] Set the cutoff ratio, which includes the preset high cutoff ratio C high With the preset low cutoff ratio C low , so as to remove pixels corresponding to some smaller grayscale values and some larger grayscale values in the first image. In this embodiment, the low cutoff ratio C is preset. low Can be set to 5%, preset high cutoff ratio C high It can be set to 0.5% to truncate the histogram of the first image to the left and right. For example: suppose the total number of pixels in the first image is N, and the number of pixels with a grayscale value of 0 is N[0]. Then, starting from the lowest pixel grayscale value of the first image, the total number of pixels to be removed is C. low *N+N[0] pixels; let the number of pixels with grayscale values be N[grayscale], then the total number of pixels removed from the highest grayscale value of the first image is C. high *N+N[grayscale] pixels. That is, we can first remove the number of pixels N[0] with a grayscale value of 0, and then based on the remaining pixels, according to the preset low cutoff ratio C low Then remove C upwards low *N. Further, C high *N+N[grayscale] is the same.
[0081] After the pixels of the first image are eliminated, the maximum grayscale value and the minimum grayscale value of the remaining pixels are determined, and the maximum grayscale value of the remaining pixels is used as the white field threshold G max , the minimum gray value is used as the black field threshold G min It should be noted that, in this embodiment, the maximum grayscale value among the grayscale values of the remaining pixels is not the same as the maximum grayscale value Max of the first image.
[0082] Step S103: when the maximum grayscale value Max of the first image is greater than a first preset multiple of the grayscale level M of the first image, the grayscale values of the first image that are less than or equal to the black field threshold G are min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image.
[0083] In this embodiment, the first preset multiple can be less than 1, for example, it can be 0.6, and it can be set that when the maximum grayscale value Max of the first image is greater than 0.6 times the grayscale level M of the first image, it is considered that there is a high effective fluorescence signal in the first image, such as Figure 4 For example, the grayscale value of each pixel of the first image can be re-determined by formula (1) to obtain the target image.
[0084]
[0085] Among them, G max is the white field threshold, G min is the black field threshold, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image. In this embodiment, the first grayscale value can be 0, and the second grayscale value can be 255.
[0086] Step S104: when the maximum grayscale value Max of the first image is less than or equal to a first preset multiple of the grayscale level M of the first image, the grayscale value of the first image that is less than or equal to the black field threshold G is min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
[0087] In this embodiment, it can be set that when the maximum grayscale value Max of the first image is less than or equal to 0.6 times the grayscale level M of the first image, it is considered that there is no high effective fluorescence signal in the first image, such as Figure 3 As shown. The maximum grayscale value Max of the first image can be used as the white field threshold G max , the grayscale value of each pixel in the first image can be re-determined by formula (2) to obtain the target image.
[0088]
[0089] Among them, G min is the black field threshold, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image. The fluorescent low grayscale image stretching transformation function is as follows: Figure 7 shown.
[0090] In this embodiment, the two situations of the presence of a high effective fluorescence signal and the absence of a high effective fluorescence signal in the first image are fully considered. When a high effective fluorescence signal exists, the grayscale value of each pixel in the first image is re-determined according to three threshold intervals, which are respectively less than the black field threshold G min , greater than the black field threshold G min And less than the white field threshold G max and greater than the white field threshold G max , which can fully improve the contrast of the first image; when there is no high effective fluorescence signal, the gray value of each pixel of the first image is determined according to two threshold intervals, which are less than the black field threshold G min and greater than the black field threshold G min , and the maximum grayscale value Max of the first image is used as the white field threshold G max The calculation is performed to avoid the overexposure of part of the fluorescent signal due to overstretching of the first image, thereby improving the observation effect. In addition, in this embodiment, the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image are re-determined according to the preset high cutoff ratio and the preset low cutoff ratio, and the maximum grayscale value of the grayscale values of the remaining pixels is used as the white field threshold G max , the minimum gray value is used as the black field threshold G min , further based on the re-determined white field threshold G max With black field threshold G minRedetermining the grayscale value of each pixel in the first image reduces overexposure in the target image while increasing its overall brightness, thereby enhancing the first image. Furthermore, in this embodiment, there is no need to customize the grayscale value for stretching. The automatic color scale algorithm effectively determines the stretching threshold, reduces overexposure, and effectively enhances weak fluorescence signals in fluorescent grayscale images.
[0091] The first image can be a near-infrared fluorescence image of a living small animal captured by a scientific research-grade deep-cooled infrared indium gallium arsenide (InGaAs) camera, or it can be other types of grayscale images. The grayscale image processing method provided in an embodiment of the present invention is not only applicable to fluorescence images, but also to other types of grayscale images.
[0092] As an optional implementation, in the embodiment of the present invention, according to the white field threshold G max And the black field threshold G min Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel, including:
[0093] Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid , and determine the intermediate threshold G mid The corresponding intermediate mapping gray value;
[0094] The first image is smaller than or equal to the black field threshold G min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image.
[0095] When there is a high effective fluorescence signal in the first image, due to the use of the same ratio to stretch the image, over-enhancement may occur. Therefore, in order to further reduce the over-enhancement of the fluorescence signal generated by stretching the first image, in this embodiment, the intermediate threshold G can be set. mid The grayscale value of each pixel in the first image is further determined. The grayscale value of each pixel in the first image can be re-determined using formula (3) to obtain the target image.
[0096]
[0097] Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, G point is the intermediate mapping grayscale value, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image. The fluorescent high grayscale image stretching transformation function is as follows: Figure 8 shown.
[0098] In this embodiment, by setting the intermediate threshold G mid , the grayscale value of each pixel of the first image is divided into four intervals, which are less than the black field threshold G min , greater than the black field threshold G min And less than the middle threshold G mid , greater than the middle threshold G mid And less than the white field threshold G max , and greater than the white field threshold G max This avoids the phenomenon of over-enhancement caused by stretching the image at the same ratio. It also prevents the original high-grayscale effective fluorescence signal from becoming large noise due to over-enhancement, affecting the monitoring effect of the fluorescence signal. It also further reduces the overexposure of some fluorescence signals in the target image, fully improving the contrast of the first image.
[0099] like Figure 9 As shown, as an optional implementation, in the embodiment of the present invention, the determination is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid ,include:
[0100] Determine the optimal threshold G t Is the second preset multiple within (G min , G max ) range, the optimal threshold G tis a threshold value obtained by iteratively calculating the grayscale values of pixels in the first image;
[0101] Among them, the optimal threshold G t The second preset multiple of the optimal threshold G t 1.5 times, that is, C1=G t *1.5, judge whether C1 is in (G min , G max ) range.
[0102] If the optimal threshold G t The second preset multiple is (G min , G max ) range, then the optimal threshold G t The value of the second preset multiple is used as the intermediate threshold G mid ; That is, C1 is used as the intermediate threshold G mid .
[0103] If the optimal threshold G t The second preset multiple is not in (G min , G max ) range, then the optimal threshold G is determined t Is it in (G min , G max )
[0104] If the optimal threshold G t In (G min , G max ) range, then the optimal threshold G t With the white field threshold G max The average value is taken as the intermediate threshold G mid That is, C2 is used as the intermediate threshold G mid , where C2=(G t +G max ) / 2.
[0105] If the optimal threshold G t Not in (G min , G max ) range, the black field threshold G min With the white field threshold G max The average value is taken as the intermediate threshold G mid ; That is, C3 is used as the intermediate threshold G mid , where C3=(G min +G max ) / 2.
[0106] In this embodiment, the range of the optimal threshold is fully considered, so that a suitable intermediate threshold is determined based on the optimal threshold, the threshold interval of the grayscale value is re-divided based on the intermediate threshold, and finally the target image is determined based on the threshold interval to avoid stretching the image at the same ratio, thereby avoiding over-enhancement.
[0107] like Figure 10 As shown, as an optional implementation, in the embodiment of the present invention, the optimal threshold G is determined by the following steps: t :
[0108] Set the initial threshold T;
[0109] Determine a grayscale value corresponding to a first pixel R1 greater than the initial threshold T and a grayscale value corresponding to a second pixel R2 less than or equal to the initial threshold T in the original grayscale data;
[0110] Calculating a first mean T1 of grayscale values corresponding to the first pixel R1 and a second mean T2 of grayscale values corresponding to the second pixel R2;
[0111] Calculating an average of the first mean value T1 and the second mean value T2 to obtain a third mean value T3;
[0112] Determine whether the difference between the third mean value T3 and the initial threshold value T is within a preset range;
[0113] If it is, then determine the initial threshold T as the optimal threshold G t .
[0114] If the difference between the third mean value T3 and the initial threshold value T is not within the preset range, the initial threshold value T is changed. The third mean value can be used as the initial threshold value T, and the above steps are re-executed to determine whether the new initial threshold value T is the optimal threshold value.
[0115] In this embodiment, an optimal threshold is determined through iterative calculation, and an intermediate threshold can be further determined based on the optimal threshold to avoid stretching the image at the same ratio, thereby avoiding over-enhancement.
[0116] As an optional implementation, in the embodiment of the present invention, the intermediate mapping gray value G is determined by the following steps: point :
[0117] Calculate the initial mapping grayscale value V using the first preset function mid , the first preset function is the white field threshold G max , black field threshold G min , the intermediate threshold G mid and a relationship function between the gray levels of the first image;
[0118] The initial mapping gray value V mid The third preset multiple is used as the intermediate mapping gray value G point In this embodiment, the third preset multiple may be 1.2.
[0119] As an optional implementation, in an embodiment of the present invention, the first preset function is formula (8):
[0120]
[0121] Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, V mid is the initial mapping grayscale value, and M is the grayscale level of the first image.
[0122] As an optional implementation, in the embodiment of the present invention, when determining the white field threshold G max With the black field threshold G min Afterwards, before stretching the first image, the following steps are further included:
[0123] Obtain a dark background image and calculate the average grayscale value G of each pixel in the dark background image aver ;
[0124] Calculating an analog amplification value amp, where the analog amplification value amp is a ratio of the grayscale level M of the first image to the maximum grayscale value Max of the first image;
[0125] According to the average value G of the gray value of each pixel of the dark background image aver and the analog amplification value amp, calculating the background value dark of the first image;
[0126] The value greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Determine, including:
[0127] The first image is smaller than or equal to the black field threshold G minThe grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min And the background value of the first image is determined to be greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max And the background value of the first image is determined to be greater than or equal to the white field threshold G max The grayscale value of the pixel of the first image is set to the second grayscale value to obtain the target image; the grayscale value of each pixel of the first image can be re-determined by formula (4) to obtain the target image. The image after processing and sharpening the fluorescent high grayscale image according to formula (4) is as follows Figure 6 shown.
[0128]
[0129] Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, G point is the intermediate mapping grayscale value, dark is the background value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0130] When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the grayscale values of the pixels in the first image that are less than or equal to the black field threshold are set to the first grayscale value, and the grayscale values of the pixels that are greater than the black field threshold are set according to the maximum grayscale value of the first image, the black field threshold G min The background value of the first image is determined to obtain the target image. The grayscale value of each pixel of the first image can be re-determined by formula (5) to obtain the target image. The image after processing and sharpening the fluorescent low grayscale image according to formula (5) is as follows: Figure 5 shown.
[0131]
[0132] Among them, G minis the black field threshold, dark is the background value of the first image, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0133] In practical applications, if the background of the first image is stretched at the same time, the image processing efficiency will be reduced, and the background of the target image output after processing will be over-stretched, resulting in visual interference.
[0134] In this embodiment, before stretching the first image, adaptive dark background processing can be performed to remove the background of the first image. Stretching is then performed only on the grayscale values between the black threshold and the white threshold. This avoids unnecessary stretching of the background of the first image and better balances the subsequent image stretching effect. In this embodiment, the background value "dark" of the first image is preferably only half the value, resulting in a better output target image.
[0135] As an optional implementation manner, in an embodiment of the present invention, the grayscale image processing method further includes: performing Laplace sharpening processing on the target image to obtain a second image;
[0136] The target image is superimposed on the second image, or superimposed on the product of the sharpening coefficient of the second image, to obtain the sharpened target image.
[0137] In order to address the fog noise that appears on the first image due to uneven lighting, thermal effects, etc., and to further optimize the display effect of the first image, after contrast stretching the first image, a dehazing operation can be performed through an image sharpening algorithm to enhance the edges and grayscale jump parts of the image, compensate for the contour of the image, and make the image clearer.
[0138] In this embodiment, the second-order differential Laplace sharpening algorithm can be used to highlight the details of the stretched target image. The Laplace operator of the two-dimensional function can be expressed as formula (6):
[0139]
[0140] You can select a filter template It is a filter that is isotropic for 45° rotation.
[0141] The target image g(x,y) and the second image after Laplace sharpening Superposition can not only preserve the image background information, but also sharpen and enhance the stretched target image. In order to optimize the image sharpening effect, an adjustable sharpening coefficient s can be used to combine it with the second image. After multiplication, the target image g(x,y) is superimposed to finally obtain the sharpened target image h(x,y). The calculation formula of the sharpened target image h(x,y) is as shown in the following formula (7):
[0142]
[0143] Among them, the value of the sharpening coefficient s should be reasonable. If the value of s is too large, the image contour will overshoot; if the value of s is too small, the sharpening effect of the image will not be obvious.
[0144] like Figure 11 As shown, as an optional implementation, in an embodiment of the present invention, the dark background removal described above can be performed on the first image, and then contrast stretching can be performed based on a threshold value to enhance the first image. The stretched image can then be sharpened to correct the stretched image, and finally a sharpened target image can be output. This not only improves image processing efficiency, increases the contrast of the first image, and avoids over-enhancement, but also enhances the edges of the first image, making the contours clearer.
[0145] In this embodiment, as an optional implementation, when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula (1):
[0146]
[0147] When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula (2):
[0148]
[0149] Among them, G max is the white field threshold, G min is the black field threshold, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0150] As an optional implementation, in an embodiment of the present invention, when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula (3):
[0151]
[0152] Among them, G max is the white field threshold, G min is the black field threshold, Gmid is the intermediate threshold, G point is the intermediate mapping grayscale value, M is the grayscale of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
[0153] Example 2
[0154] This embodiment provides a grayscale image processing device, which can be used to execute the grayscale image processing method in the above embodiment 1. The device can be set inside a server or other device, and the modules cooperate with each other to achieve grayscale image processing, such as Figure 12 As shown, the device includes:
[0155] An acquisition module 201 is configured to acquire original grayscale data of a first image, wherein the original grayscale data includes grayscale values corresponding to each pixel of the first image;
[0156] The elimination module 202 is configured to eliminate pixels of the first image based on a preset high truncation ratio, a preset low truncation ratio, and the original grayscale data, calculate the grayscale values of the remaining pixels of the first image, and determine the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image, and use the maximum grayscale value as the white field threshold G. max The minimum grayscale value is used as the black field threshold G min ;
[0157] The first generating module 203 is configured to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image. min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image;
[0158] The second generating module 204 is configured to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is less than or equal to the first preset multiple of the grayscale level of the first image. min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
[0159] In this embodiment, the two situations of the presence of a high effective fluorescence signal and the absence of a high effective fluorescence signal in the first image are fully considered. When a high effective fluorescence signal exists, the grayscale value of each pixel in the first image is re-determined according to three threshold intervals, which are respectively less than the black field threshold G min , greater than the black field threshold G min And less than the white field threshold G max and greater than the white field threshold G max , which can fully improve the contrast of the first image; when there is no high effective fluorescence signal, the gray value of each pixel of the first image is determined according to two threshold intervals, which are less than the black field threshold G min and greater than the black field threshold G min , and the maximum grayscale value Max of the first image is used as the white field threshold G max The calculation is performed to avoid the overexposure of part of the fluorescent signal due to overstretching of the first image, thereby improving the observation effect. In addition, in this embodiment, the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image are re-determined according to the preset high cutoff ratio and the preset low cutoff ratio, and the maximum grayscale value of the grayscale values of the remaining pixels is used as the white field threshold G max , the minimum gray value is used as the black field threshold G min , further based on the re-determined white field threshold G max With black field threshold G min Redetermining the grayscale value of each pixel in the first image reduces overexposure in the target image while increasing its overall brightness, thereby enhancing the first image. Furthermore, in this embodiment, there is no need to customize the grayscale value for stretching. The automatic color scale algorithm effectively determines the stretching threshold, reduces overexposure, and effectively enhances weak fluorescence signals in fluorescent grayscale images.
[0160] For a detailed description of the above-mentioned device part, please refer to the above-mentioned method embodiment, which will not be repeated here.
[0161] Example 3
[0162] This embodiment provides a computer device, such as Figure 13 As shown, the computer device includes a processor 301 and a memory 302, wherein the processor 301 and the memory 302 can be connected via a bus or other means. Figure 13 The bus connection is taken as an example.
[0163] The processor 301 may be a central processing unit (CPU). The processor 301 may also be other general-purpose processors, digital signal processors (DSP), graphics processing units (GPU), embedded neural network processors (NPU), or other dedicated deep learning coprocessors, application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0164] Memory 302, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the grayscale image processing method in the embodiments of the present invention and the corresponding program instructions / modules. Processor 301 executes the non-transitory software programs, instructions, and modules stored in memory 302 to perform various processor functions and data processing, thereby implementing the grayscale image processing method in the above-mentioned method embodiments.
[0165] The memory 302 may also include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created by the processor 301, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 302 may optionally include a memory remotely located relative to the processor 301, and these remote memories may be connected to the processor 301 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0166] The memory 302 stores one or more modules, which, when executed by the processor 301, perform the following operations: Figure 1 The grayscale image processing method in the illustrated embodiment.
[0167] For details of the above computer equipment, please refer to Figure 1 The corresponding descriptions and effects in the embodiments shown can be understood and will not be repeated here.
[0168] An embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions capable of executing the grayscale image processing method of any of the above embodiments. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); the storage medium may also include a combination of the above types of memory.
[0169] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will readily appreciate that other variations or modifications based on the above descriptions are possible. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.
Claims
1. A grayscale image processing method, characterized in that: The steps include: Acquire original grayscale data of a first image, where the original grayscale data includes a grayscale value corresponding to each pixel of the first image; Based on the preset high truncation ratio, the preset low truncation ratio and the original grayscale data, the pixels of the first image are eliminated, the grayscale values of the remaining pixels of the first image are counted, and the maximum grayscale value and the minimum grayscale value among the grayscale values of the remaining pixels of the first image are determined, and the maximum grayscale value is used as the white field threshold G max The minimum grayscale value is used as the black field threshold G min ; When the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the grayscale values of the first image that are less than or equal to the black field threshold G are min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image; When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the grayscale values of the first image that are less than or equal to the black field threshold G are min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
2. The grayscale image processing method according to claim 1, wherein: According to the white field threshold G max And the black field threshold G min Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel, including: Determine whether it is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid , and determine the intermediate threshold G mid The corresponding intermediate mapping gray value; Greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Sure.
3. The grayscale image processing method according to claim 2, wherein: The determination is greater than the black field threshold G min And is less than the white field threshold G max The intermediate threshold G mid ,include: Determine whether the second preset multiple of the optimal threshold is within (G min , G max ), the optimal threshold is a threshold obtained by iteratively calculating the grayscale values of pixels in the first image; If the second preset multiple of the optimal threshold is (G min , G max ), the value of the second preset multiple of the optimal threshold is used as the intermediate threshold G mid ; If the second preset multiple of the optimal threshold is not within (G min , G max ) range, it is determined whether the optimal threshold is within (G min , G max ) If the optimal threshold is (G min , G max ) range, then the optimal threshold and the white field threshold G max The average value is taken as the intermediate threshold G mid ; If the optimal threshold is not within (G min , G max ) range, the black field threshold G min With the white field threshold G max The average value is taken as the intermediate threshold G mid .
4. The grayscale image processing method according to claim 3, wherein: The optimal threshold is determined by the following steps: Set the initial threshold T; Determine a grayscale value corresponding to a first pixel R1 greater than the initial threshold T and a grayscale value corresponding to a second pixel R2 less than or equal to the initial threshold T in the original grayscale data; Calculating a first mean of the grayscale values corresponding to the first pixel R1 and a second mean of the grayscale values corresponding to the second pixel R2; Calculating an average of the first mean and the second mean to obtain a third mean; Determining whether a difference between the third mean and the initial threshold T is within a preset range; If so, determining the initial threshold T as the optimal threshold; Otherwise, the third mean is used as the initial threshold T, and the above steps are re-executed to determine whether the new initial threshold T is the optimal threshold.
5. The grayscale image processing method according to claim 2, wherein: The intermediate mapping grayscale value is determined by the following steps: Calculate the initial mapping grayscale value V using the first preset function mid , the first preset function is the white field threshold G max , black field threshold G min , the intermediate threshold G mid and a relationship function between the gray levels of the first image; The initial mapping gray value V mid A third preset multiple of is used as the intermediate mapping grayscale value.
6. The grayscale image processing method according to claim 5, characterized in that: The first preset function is: Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, V mid is the initial mapping grayscale value, and M is the grayscale level of the first image.
7. The grayscale image processing method according to claim 2, wherein: Also includes: Obtaining a dark background image, and calculating an average value of the grayscale value of each pixel of the dark background image; Calculating an analog amplification value, where the analog amplification value is a ratio of the grayscale of the first image to the maximum grayscale value Max of the first image; Calculating a background value of the first image according to an average value of the grayscale values of each pixel of the dark background image and the simulated amplification value; The value greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min Determine that it is greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max Determine, including: Greater than the black field threshold G min and is less than or equal to the intermediate threshold G mid The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the black field threshold G min And the background value of the first image is determined to be greater than the intermediate threshold G mid And is less than the white field threshold G max The grayscale value of the pixel is determined according to the intermediate mapping grayscale value, the intermediate threshold G mid , the white field threshold G max And the background value of the first image is determined.
8. The grayscale image processing method according to claim 1, wherein: Also includes: Performing Laplace sharpening on the target image to obtain a second image; The target image is superimposed on the second image, or superimposed on the product of the sharpening coefficient of the second image, to obtain the sharpened target image.
9. The grayscale image processing method according to claim 1, wherein: When the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula: When the maximum grayscale value of the first image is less than or equal to a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula: Among them, G max is the white field threshold, G min is the black field threshold, Max is the maximum grayscale value of the first image, M is the grayscale level of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
10. The grayscale image processing method according to claim 2, wherein: When the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image, the target image is determined by the following formula: Among them, G max is the white field threshold, G min is the black field threshold, G mid is the intermediate threshold, G point is the intermediate mapping grayscale value, M is the grayscale of the first image, f(x, y) is the grayscale value corresponding to the pixel of the first image, and g(x, y) is the grayscale value corresponding to the pixel of the target image.
11. A grayscale image processing device, characterized in that: include: an acquisition module, configured to acquire original grayscale data of a first image, wherein the original grayscale data includes a grayscale value corresponding to each pixel of the first image; A culling module is configured to cull pixels of the first image based on a preset high truncation ratio, a preset low truncation ratio, and the original grayscale data, calculate the grayscale values of the remaining pixels of the first image, and determine the maximum grayscale value and the minimum grayscale value of the grayscale values of the remaining pixels of the first image, and use the maximum grayscale value as the white field threshold G max The minimum grayscale value is used as the black field threshold G min ; The first generating module is used to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is greater than a first preset multiple of the grayscale level of the first image min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min And is less than the white field threshold G max The grayscale value of the pixel is determined according to the white field threshold G max And the black field threshold G min Determine whether it is greater than or equal to the white field threshold G max The grayscale value of the pixel is set to the second grayscale value to obtain the target image; The second generating module is used to generate the grayscale value of the first image that is less than or equal to the black field threshold G in the first image when the maximum grayscale value of the first image is less than or equal to the first preset multiple of the grayscale level of the first image. min The grayscale value of the pixel is set to the first grayscale value, which is greater than the black field threshold G min The grayscale value of the pixel is determined according to the maximum grayscale value of the first image and the black field threshold G min OK, get the target image.
12. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the grayscale image processing method according to any one of claims 1 to 10 by executing the computer instructions.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the grayscale image processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and readable storage medium
CN109903294A
Image display method and device, display equipment, projection equipment and storage medium
CN115527474A