Image processing method and device and electronic equipment
By using gradient maps and tendency indicators to process the integer bit values of pixel points in image processing, the tomography and layering problems caused by accuracy loss in image processing are solved, and the image quality is improved.
Patent Information
- Application Number
- CN202411054651.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-01
AI Technical Summary
The conversion of floating point numbers and integer numbers during image processing results in accuracy loss, resulting in image tomography and stratification problems.
By obtaining the gradient map of the image, the integer and decimal values of the pixel points are determined, and the tendency index is calculated based on the gradient value, the integer value is refined to reduce accuracy loss, and a degraded layered image is generated.
It effectively weakens the image tomography and layering problems caused by accuracy loss, and improves the quality and fineness of the image.
Smart Images

Figure CN119031250A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and specifically relates to an image processing method, device and electronic equipment. Background Art
[0002] When using electronic devices to process images, there will be conversion between floating point numbers and integers, and this loss of precision is unavoidable. For example, when using electronic devices to shoot a subject, a color image presented in an album is obtained. The shooting process is that the electronic device first collects the raw image, and then performs brightness processing, color processing, noise processing, etc., and finally presents a color album image. The raw image here is a 16-bit deep image, and the final album image is an 8-bit deep image. This process involves the conversion between floating point numbers and integers, which will cause a loss of precision.
[0003] The above-mentioned precision loss is caused by the use of rounding to process the raw image during the image shooting process. This processing method will make the pixel values of adjacent pixels in the raw image become the same pixel value. The color album image generated in this way is prone to faults and stratification problems. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an image processing method, device and electronic device, which can reduce the fault and stratification problems caused by the loss of accuracy during image processing.
[0005] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:
[0006] Obtaining a gradient map corresponding to a first image, wherein the bit depth of the first image is a first bit depth;
[0007] Determining integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image to a pixel of a second bit depth, wherein the second bit depth is lower than the first bit depth;
[0008] Determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map;
[0009] Determining, based on the tendency index and the integer bit value corresponding to each pixel point, a target pixel value of each pixel point in the first image converted into a pixel point of the second bit depth;
[0010] A second image is generated according to the target pixel value of each pixel point of the second bit depth.
[0011] In a second aspect, an embodiment of the present application provides an image processing device, the device comprising:
[0012] A first acquisition module, used to acquire a gradient map corresponding to a first image, wherein the bit depth of the first image is a first bit depth;
[0013] A first determining module, configured to determine integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image to a pixel of a second bit depth, wherein the second bit depth is lower than the first bit depth;
[0014] A second determination module is used to determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map;
[0015] A third determination module is used to determine a target pixel value of each pixel in the first image converted into a pixel of the second bit depth based on the tendency index and the integer bit value corresponding to each pixel;
[0016] The fourth determination module is used to generate a second image according to the target pixel value of each pixel point of the second bit depth.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0018] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0019] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0020] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0021] In an embodiment of the present application, when processing an image, reference is made to the gradient value of each pixel in the first image and the decimal value of each pixel when converted to a pixel of the second bit depth, and a tendency index is obtained to characterize that when the pixel is converted to a pixel of the second bit depth, its pixel value takes an integer value. The tendency index is used to perform fine processing on the integer value of the pixel, so that the target pixel value of the pixel when converted to a pixel of the second bit depth can be accurately obtained, thereby obtaining a second image with faded layers. Compared with the prior art of processing the pixels in the first image by rounding off, the solution of the embodiment of the present application effectively reduces the image fault and layering problems caused by the loss of precision. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flowchart of an image processing method provided by some embodiments of the present application;
[0023] FIG. 2( a ) is a schematic diagram of edge features of a vertical line edge provided in some embodiments of the present application;
[0024] FIG2( b ) is a schematic diagram of edge features of the vertex edge of a vertical line band provided by some embodiments of the present application;
[0025] FIG2( c ) is a schematic diagram of edge features of a slanted edge provided in some embodiments of the present application;
[0026] FIG3( a) is a schematic diagram of a gradient map of a 16-bit-depth image provided by some embodiments of the present application;
[0027] FIG3( b ) is a gradient map obtained by processing FIG3( a ) using the rounding method in the prior art, provided in some embodiments of the present application;
[0028] FIG3(c) is a gradient map obtained by processing FIG3(a) using the solution provided in some embodiments of the present application;
[0029] Figure 4 is a schematic diagram of the structure of an image processing device shown in some embodiments of the present application;
[0030] Figure 5 is a schematic diagram of the structure of an electronic device shown in some embodiments of the present application;
[0031] Figure 6 It is a schematic diagram of the hardware structure of an electronic device shown in some embodiments of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0033] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0034] As described in the background technology section, using rounding to process an image will cause loss of image precision, and further cause the image to be prone to faults and stratification. In order to solve the above problems, the embodiments of the present application provide an image processing method, device and electronic device. When processing an image, the gradient value of each pixel in the first image and the decimal value of each pixel when converted to a second bit-depth pixel are referenced, and a tendency index for characterizing that the pixel value is an integer value when converted to a second bit-depth pixel is obtained. The tendency index is used to perform fine processing on the integer value of the pixel, so that the target pixel value of the second bit-depth pixel converted by the pixel can be accurately obtained, and then a second image with faded stratification is obtained. Compared with the prior art of processing the pixels in the first image by rounding, the solution of the embodiments of the present application effectively reduces the image faults and stratification problems caused by loss of precision.
[0035] The technical solution of the embodiments of the present application can be applied to scenarios such as image storage and display, for example, using an electronic device to photograph a subject and obtaining a color image presented in an album.
[0036] The image processing method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0037] Figure 1 is a flowchart of an image processing method provided in an embodiment of the present application,
[0038] like Figure 1 As shown, the image processing method provided in the embodiment of the present application may include steps 110 to 150.
[0039] Step 110: Obtain a gradient map corresponding to the first image.
[0040] Among them, the first image can be a raw image captured by the electronic device, or it can be a color image presented in an album, which is not limited in the embodiments of the present application.
[0041] It should be noted that the bit depth of the first image is the first bit depth.
[0042] It should be noted that, when the first image is a raw image captured by the electronic device, the second image generated in step 150 is an image presented in the album after the raw image is processed. When the first image is a color image presented in the album, the second image generated in step 150 is a color image of the second bit depth presented in the album, where the second bit depth is lower than the first bit depth.
[0043] In some embodiments of the present application, there are two ways to obtain the gradient map of the first image:
[0044] Acquisition method 1: When the device path of the electronic device is not restricted, that is, the device path of the electronic device supports transmitting the gradient map to the algorithm corresponding to the embodiment of the present application, the gradient map of the first image can be directly acquired from the device path of the electronic device. This is because the device path of the electronic device will have its corresponding gradient map when sharpening the image, so the gradient map of the first image can be directly acquired from the device path of the electronic device.
[0045] Acquisition method two: when the device path of the electronic device is restricted, that is, the device path of the electronic device does not support the transmission of the gradient map to the algorithm corresponding to the embodiment of the present application, the first image can be processed by the Sobel matrix to obtain the gradient map of the first image.
[0046] It should be noted that the specific expression of the Sobel matrix is shown in the following formula (1):
[0047]
[0048] The second method of obtaining the gradient map of the first image is described in detail below. That is, obtaining the gradient map of the first image may specifically include:
[0049] Using the first sub-matrix in the Sobel matrix to process each pixel in the first image, obtaining second gradient information of each pixel in the first direction;
[0050] Using the second sub-matrix in the Sobel matrix to process each pixel in the first image, obtaining third gradient information of each pixel in the second direction;
[0051] A gradient map of the first image is obtained according to the second gradient information and the third gradient information of the pixel point.
[0052] The first sub-matrix may be a sub-matrix in the Sobel matrix, for example,
[0053] The second sub-matrix may be another sub-matrix in the Sobel matrix except the first sub-matrix. For example, the second sub-matrix may be
[0054] The first direction may be the direction in which the first sub-matrix processes each pixel in the first image. The second direction may be the direction in which the second sub-matrix processes each pixel in the first image.
[0055] In some embodiments of the present application, the position of a pixel in the first image can be expressed in the form of coordinates. For example, the position of a pixel in the first image is (x, y), where the first direction may be the x direction and the second direction may be the y direction.
[0056] The second gradient information may be the gradient information of each pixel point in the first direction. The third gradient information may be the gradient information of each pixel point in the second direction.
[0057] In some embodiments of the present application, for each pixel in the first image, the first sub-matrix in the Sobel matrix can be used to process the pixel to obtain second gradient information of the pixel in the first direction, and then the second sub-matrix in the Sobel matrix can be used to process the pixel to obtain third gradient information of the pixel in the second direction, and then the second gradient information and the third gradient information of the pixel are weightedly calculated to obtain the gradient map of the first image.
[0058] It should be noted that in addition to using the Sobel matrix to process each pixel in the first image to obtain the gradient map corresponding to the first image, other methods can be used to process each pixel in the first image to obtain the gradient map corresponding to the first image, such as the Canny operator. The specific method used to process each pixel in the first image to obtain the gradient map corresponding to the first image can be selected according to user needs and is not limited in the embodiments of the present application.
[0059] It should be noted that after the first image is processed according to the Sobel matrix to obtain the gradient map corresponding to the first image, each pixel point on the first image is in a one-to-one correspondence with each pixel point on the gradient map, that is, a pixel point on the first image always has a corresponding pixel point on the gradient map.
[0060] In an embodiment of the present application, for each pixel in the first image, the pixel is processed by using the first submatrix in the Sobel matrix to obtain the second gradient information of the pixel in the first direction, and then the pixel is processed by using the second submatrix in the Sobel matrix to obtain the third gradient information of the pixel in the second direction, and then the gradient map of the first image can be obtained based on the second gradient information and the third gradient information of each pixel in the first image. In this way, by quantizing the gradient information of each pixel in the first image, the gradient map of the first image can be accurately obtained.
[0061] Step 120: Determine integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image into a pixel of the second bit depth.
[0062] The second bit depth may be a bit depth different from the first bit depth. Specifically, the second bit depth may be lower than the first bit depth.
[0063] In some embodiments of the present application, for converting each pixel in the first image into a pixel of the second bit depth, the pixel value conversion formula of each pixel in the first image can be shown as the following formula (2):
[0064]
[0065] Among them, value 第一位深 is the pixel value of the first pixel depth, value 第二位深 is the pixel value corresponding to the second bit depth, A is the maximum value of the pixel value range of the pixel point of the first bit depth, and B is the maximum value of the pixel value range of the pixel point of the second bit depth.
[0066] In an example, taking the first bit depth as 16 bits and the second bit depth as 8 bits, A=65535 and B=255 in the above formula (2), that is, the pixel value range of the pixel point in the 16-bit image is [0-65535], and the pixel value range of the pixel point in the 8-bit image is [0-255].
[0067] In some embodiments of the present application, each pixel point of the first image is calculated according to the above formula (2), and each pixel point will generate integer digits and decimal digits.
[0068] Step 130: Determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map.
[0069] Among them, for each pixel point in the first image, the tendency index corresponding to the pixel point can be used to characterize the tendency of rounding the decimal value of the pixel point when converting it into a pixel point of the second bit depth. The rounding here can be rounding up or rounding down, and whether to round up or round down can be determined according to the specific situation.
[0070] In some embodiments of the present application, in order to accurately determine the tendency index of rounding the decimal value corresponding to each pixel point, step 130 may specifically include:
[0071] Determine the gradient degree of each pixel point according to the gradient value of each pixel point in the gradient map and the reference threshold;
[0072] According to the decimal value and gradient degree corresponding to each pixel point, a tendency index for rounding the decimal value corresponding to each pixel point is determined.
[0073] The reference threshold may be a threshold corresponding to the gradient value of each pixel in the gradient map. The method for determining the reference threshold will be described in detail in the following embodiments.
[0074] The gradient degree of each pixel point may be used to characterize the gradient degree of each pixel point.
[0075] In some embodiments of the present application, the gradient degree of a pixel point can take a value of [0,1]. When the gradient degree of a pixel point is 0, it means that the pixel point has no gradient, that is, the pixel point is a pixel point in a flat area. When the gradient degree of a pixel point is 1, it indicates that the pixel point is a pixel point on the edge.
[0076] In some embodiments of the present application, since each pixel point in the gradient map corresponds one-to-one to each pixel point in the first image, the gradient degree of each pixel point can be determined based on the gradient value of each pixel point in the gradient map and the reference threshold, and then the tendency index of rounding the decimal value corresponding to each pixel point can be determined based on the decimal value and gradient degree corresponding to each pixel point.
[0077] In some embodiments of the present application, for each pixel in the first image, according to the decimal value corresponding to the pixel and the gradient degree corresponding to the gradient map, the tendency index of rounding the decimal value corresponding to the pixel can be determined according to the following formula (3):
[0078] f final =(abs(f gra -0.5)×(f fra -0.5)+0.25)×2 (3)
[0079] In the above formula (3), for each pixel in the first image, f final is the tendency index corresponding to the pixel point, f grais the gradient degree corresponding to the pixel point, f fra is the decimal place value of the pixel when it is converted, and abs(·) is the absolute value.
[0080] In some embodiments of the present application, the calculation of the tendency index refers to the gradient degree and decimal value of the pixel point, which can reduce the layering problem. For the flat area in the first image, if the pixel point is a pixel point in the flat area, the gradient degree f gra Approaching 0, abs(f gra -0.5) will be larger, f fra When f is close to 0 (or 1), final will be closer to 0 (or 1), which in turn increases the tendency of rounding the decimal point value of the pixel. fra When it is close to 0, f final will be closer to 0, which intensifies the tendency of rounding down the decimal point value of the pixel. fra When f is close to 1, final It will be closer to 1, which intensifies the tendency of rounding up the decimal point value of the pixel.
[0081] In the embodiments of the present application, compared with the prior art of directly rounding off decimal values, the present application determines the tendency index of rounding off the decimal values corresponding to each pixel point by referring to the gradient degree of each pixel point, so that the value tendency index can be used to subsequently refine the integer value of the pixel point, thereby reducing the image fault and stratification problems caused by the loss of precision.
[0082] In some embodiments of the present application, in order to accurately determine the gradient degree of each pixel point, determining the gradient degree of each pixel point according to the gradient value of each pixel point in the gradient map and the reference threshold value may specifically include:
[0083] The ratio of the pixel value of each pixel point to the reference threshold is determined as the gradient value of each pixel point.
[0084] In some embodiments of the present application, for each pixel point in the gradient map, the ratio of the pixel value of the pixel point to its reference threshold value can be determined as the gradient degree of the pixel point.
[0085] In an embodiment of the present application, for each pixel point in the gradient map, the gradient degree of the pixel point is determined by the ratio of the pixel value of the pixel point to the reference threshold. In this way, the gradient degree of the pixel point can be quantified to facilitate more intuitive determination of the gradient degree of each pixel point.
[0086] In some embodiments of the present application, before determining the gradient degree of each pixel point according to the gradient value of each pixel point in the gradient map and the reference threshold, the method involved above may further include:
[0087] Get the target edge feature type corresponding to each pixel point in the gradient image;
[0088] Using the Sobel matrix to process the reference image of each target edge feature type, to obtain first gradient information corresponding to the reference image of each target edge feature type;
[0089] The first gradient information corresponding to the first target edge feature type is used as a reference threshold corresponding to the first pixel point in the gradient map.
[0090] The target edge feature type corresponding to each pixel point may be the edge feature type to which each pixel point belongs.
[0091] In some embodiments of the present application, edge feature types may include: a vertical line edge feature type, a vertical line with vertices edge feature type, and a diagonal line edge feature type.
[0092] The reference image may be a standard image of different target edge feature types. The reference image may be a raw image or a color image presented in an album, which is not limited in the embodiments of the present application.
[0093] In an example, Figure 2(a) is a schematic diagram of edge features of a reference image with a vertical line edge feature type, Figure 2(b) is a schematic diagram of edge features of a reference image with a vertical line edge feature type with vertices, and Figure 2(c) is a schematic diagram of edge features of a reference image with a diagonal line edge feature type. The reference images represented by Figures 2(a), 2(b) and 2(c) are all 8-bit deep images.
[0094] The first gradient information may be gradient information corresponding to the reference images of each target edge feature type obtained by processing the reference images of each target edge feature type using a Sobel matrix.
[0095] The first target edge feature type may be any one of the target edge feature types.
[0096] The first pixel point may be a pixel point whose edge feature type in the gradient image is the first target edge feature type.
[0097] In some embodiments of the present application, the edge features of each pixel point in the gradient map of the first image can be first detected by an edge type detection algorithm to determine the target edge feature type of each pixel point, and then the reference image of each target edge feature type can be processed using the Sobel matrix to obtain the first gradient information corresponding to the reference image of each edge feature type, and then the first gradient information is used as the reference threshold for each pixel point in the gradient map whose edge feature type is the same as that of the reference image.
[0098] The method for determining the first gradient information mentioned above may be a method for determining with reference to the gradient map of the first image, that is, the first gradient information here may be firstly processing the first direction of the reference image using the first submatrix in the Sobel matrix to obtain the gradient information in the first direction, and then processing the second direction of the reference image using the second submatrix in the Sobel matrix to obtain the gradient information in the second direction, and then performing weighted calculation on the gradient information in the first direction and the gradient information in the second direction to obtain the first gradient information.
[0099] It should be noted that detecting the edge features of each pixel in the gradient image of the first image by using an edge type detection algorithm to determine the target edge feature type of each pixel belongs to the prior art and will not be described in detail here.
[0100] Continuing to refer to the above example, the output values of the gradient calculated using the Sobel matrix for the reference image corresponding to the vertical line edge feature type in Figure 2(a), the reference image corresponding to the vertical line edge feature type with vertices in Figure 2(b), and the reference image corresponding to the diagonal line edge feature type in Figure 2(c) are 4, 1, and 8, respectively. It can be determined that the reference threshold of the pixel points whose edge feature type in the gradient map of the first image is the vertical line edge feature type is 4, the reference threshold of the pixel points whose edge feature type in the gradient map of the first image is the vertical line edge with vertices is 1, and the reference threshold of the pixel points whose edge feature type in the gradient map of the first image is the diagonal line edge feature type is 8.
[0101] It should be noted that the first gradient information corresponding to the reference image of each target edge feature type can be used as the minimum value of the reference threshold, that is, if the pixel value of a pixel point of a certain edge feature type is greater than its corresponding reference threshold, the pixel point is determined to be an edge pixel point; if the pixel value of the pixel point is less than its corresponding reference threshold, the pixel point is determined to be a pixel point in the flat area.
[0102] Continuing to refer to the above example, if the pixel value (i.e., gradient value) of a pixel point of a vertical line edge feature type in the gradient map of the first image is 9, and the pixel value is greater than its corresponding reference threshold of 4, then the pixel point is determined to be an edge pixel point; if the pixel value of the pixel point is 2, and the pixel value is less than its corresponding reference threshold of 4, then the pixel point is determined to be a pixel point in the flat area.
[0103] In some embodiments of the present application, the bit depth of the reference image can be selected according to user needs, but when determining the reference threshold, the first gradient information of the reference image needs to be converted into the first gradient information corresponding to the bit depth of the first image. For example, if the reference image is an 8-bit image and the first image is a 16-bit image, then the gradient map corresponding to the first image is also a 16-bit image. The first gradient information of the reference image after Sobel matrix processing is 10, which is 8-bit gradient information. It needs to be converted into 16-bit gradient information. The converted 16-bit gradient information is the reference threshold of the pixel points in the gradient image corresponding to the edge feature type of the reference image.
[0104] In an embodiment of the present application, by determining the target edge feature type of each pixel point in the gradient map, and then determining the reference threshold of each pixel point in the gradient map based on the first gradient information of the reference image of each target edge feature type after gradient calculation, the corresponding reference threshold is determined for each pixel point, and then corresponding subsequent operations can be performed for the reference threshold of each pixel point, thereby improving the fineness of the processing of each pixel point, thereby improving the fineness of the image quality of the second image, and reducing the stratification problem of the second image.
[0105] In some embodiments of the present application, in order to improve the generation efficiency of the second image, when setting the reference threshold corresponding to each pixel point, it is also possible not to set the reference threshold for each pixel point in the above manner, that is, the reference threshold corresponding to each pixel point in the gradient map can be set to the same reference threshold, which can reduce power consumption and improve the generation efficiency of the second image. Whether the reference threshold corresponding to each pixel point is the same can be selected according to the actual needs of the user, and is not limited in the embodiments of the present application.
[0106] It should be noted that since f in the above formula (3) gra The value range of is [0,1], so the ratio of the gradient value of a pixel in the gradient map to its reference threshold is greater than f gra When the upper limit of the value range is reached, the gradient value corresponding to the pixel point is set to f gra The upper limit of the value range of f, the ratio of the gradient value of a pixel in the gradient map to its reference threshold is less than f gra When the value range is the lower limit, the gradient value corresponding to the pixel point is taken as f gra The lower limit of the value range, the ratio of the gradient value of a pixel in the gradient map to its reference threshold is located at f gra When the value is within the range of , the gradient degree corresponding to the pixel point is taken as the ratio of the gradient value of the pixel point to its reference threshold.
[0107] In one example, if the ratio of the gradient value of a pixel in the gradient map to its reference threshold is 3, which is greater than f gra The upper limit of the value range is 1, then the gradient value of the pixel is 1. If the ratio of the gradient value of a pixel in the gradient map to its reference threshold is -2, which is less than f gra The lower limit of the value range is 0, then the gradient value of the pixel is 0. If the ratio of the gradient value of a pixel in the gradient map to its reference threshold is 0.4, it is located at f gra If the value of is within the range of , the gradient value of the pixel is taken as 0.4.
[0108] Step 140: Determine a target pixel value for each pixel in the first image converted into a pixel of the second bit depth based on the tendency index and the integer bit value corresponding to each pixel.
[0109] Among them, for a certain pixel point in the first image, the target pixel value converted into the pixel point of the second bit depth may be the pixel value of the pixel point in the image of the second bit depth after the pixel point is converted into the pixel point of the second bit depth.
[0110] In some embodiments of the present application, for each pixel in the first image, the target pixel value of the pixel in the image of the second bit depth after being converted into a pixel of the second bit depth can be determined based on the tendency index and integer bit value corresponding to the pixel.
[0111] In some embodiments of the present application, in order to accurately determine the target pixel value of the pixel of the second bit depth converted from each pixel in the first image, step 140 may specifically include:
[0112] Use random functions to randomly generate random values;
[0113] Determine the correction value corresponding to each pixel point according to the random value, the tendency index corresponding to each pixel point and the maximum value of the random value range randomly generated by the random function;
[0114] The integer bit value corresponding to each pixel point is corrected based on the correction value of each pixel point to obtain the target pixel value of each pixel point converted into a pixel point of the second bit depth.
[0115] The random value may be a value randomly generated by a random function.
[0116] The maximum value of the random value range randomly generated by the random function may be the maximum value in the random value range randomly generated by the random function.
[0117] In an example, if the random value range generated by the random function is [0,8], the maximum value of the random value range randomly generated by the random function is 8; if the random value range generated by the random function is [0,300], the maximum value of the random value range randomly generated by the random function is 300.
[0118] For each pixel in the first image, the correction value corresponding to the pixel may be a value obtained by correcting the integer bit value corresponding to the pixel.
[0119] In some embodiments of the present application, for a certain pixel point in the first image, a random value can be randomly generated using a random function, and then a correction value corresponding to the pixel point is determined based on the random value, the tendency index corresponding to the pixel point, and the maximum value of the random value range randomly generated by the random function. The correction value of the pixel point is used to correct the integer bit value corresponding to the pixel point to obtain the target pixel value of the pixel point converted into a pixel point of the second bit depth.
[0120] In some embodiments of the present application, according to the random value, the tendency index corresponding to each pixel point and the maximum value of the random value range randomly generated by the random function, the correction value corresponding to each pixel point can be obtained according to the following formula (4):
[0121] diff = rand(·) <f final ×rand_max? 1:0 (4)
[0122] In the above formula (4), rand(·) is a random value generated by a random function, rand_max is the maximum value of the random value range randomly generated by the random function, and diff is a correction value.
[0123] The meaning of the above formula (4) is: if rand(·) <f final ×rand_max, then the value of diff is 1, otherwise the value of diff is 0.
[0124] In some embodiments of the present application, it can be seen from the above formula (4) that when f final When it approaches 0 (or 1), the probability that diff is also 0 (or 1) approaches 1. final When it approaches 0.5, f gra approaches 0.5 (0 for a completely flat surface and 1 for an edge), or f fra Approaching 0.5, rounding off may result in stratification. final When it approaches 0.5, the probability of diff being 0 or 1 is the same.
[0125] In an embodiment of the present application, for each pixel point in the first image, a random value is randomly generated by using a random function, and then the correction value corresponding to the pixel point can be determined according to the random value, the tendency index corresponding to the pixel point and the maximum value of the random value range randomly generated by the random function. In this way, the correction value of the pixel point can be used to correct the integer value corresponding to the pixel point, and then the target pixel value of the pixel point converted into a pixel point of the second bit depth can be accurately obtained. Compared with the prior art that directly rounds the decimal value, the solution of the embodiment of the present application uses the tendency index to determine the tendency of rounding the decimal value, and then uses the tendency to correct the integer value, thereby reducing the image stratification problem caused by the loss of precision.
[0126] In some embodiments of the present application, in order to further reduce the image layering problem caused by the loss of precision, the integer bit value corresponding to each pixel point is corrected based on the correction value of each pixel point to obtain the target pixel value of each pixel point converted into a pixel point of the second bit depth, which may specifically include:
[0127] The sum of the correction value of each pixel and the integer bit value corresponding to each pixel is determined as the target pixel value of each pixel converted into a pixel of the second bit depth.
[0128] In some embodiments of the present application, for each pixel in the first image, the sum of the correction value of the pixel and the integer bit value corresponding to the pixel can be determined as the target pixel value of the pixel of the second bit depth converted by the pixel, that is, for each pixel in the first image, according to the correction value of the pixel and the integer bit value corresponding to the pixel, the target pixel value of the pixel of the second bit depth converted by the pixel is obtained according to the following formula (5):
[0129] value int2 =i+diff (5)
[0130] In the above formula (5), for each pixel in the first image, value int2 is the target pixel value of the pixel of the second bit depth converted from the pixel, and i is the integer bit value corresponding to the pixel.
[0131] In an embodiment of the present application, for each pixel in the first image, the target pixel value of the pixel of the second bit depth converted by the pixel can be determined by summing the correction value of the pixel and the integer bit value corresponding to the pixel. In this way, the target pixel value can be accurately determined, and a second image with faded layers can be obtained, thereby reducing the image stratification problem caused by the loss of precision.
[0132] Step 150: Generate a second image according to the target pixel value of each pixel point of the second bit depth.
[0133] In some embodiments of the present application, a second image of the second bit depth may be generated according to the target pixel value of each pixel point of the second bit depth of the conversion layer.
[0134] In one example, refer to Figures 3(a), 3(b) and 3(c), wherein Figure 3(a) is a schematic diagram of a gradient map of a 16-bit deep image, and Figure 3(b) is a gradient map obtained by processing Figure 3(a) using the rounding method in the prior art. It can be seen from Figure 3(b) that the image processed by the rounding method in the prior art has a layering problem, namely, the white fault selected by the box 31 in Figure 3(b). Figure 3(c) is a gradient map obtained by processing Figure 3(a) using the solution provided in an embodiment of the present application. It can be seen from Figure 3(c) that the image processed by the solution provided in an embodiment of the present application simplifies the layering problem of the image.
[0135] The image processing method provided in the embodiment of the present application can be executed by an image processing device. In the embodiment of the present application, an image processing device executing the image processing method is taken as an example to illustrate the image processing device provided in the embodiment of the present application.
[0136] Figure 4 The figure is a schematic diagram showing the structure of an image processing device according to an exemplary embodiment.
[0137] like Figure 4 As shown, the image processing device 400 may include:
[0138] A first acquisition module 410 is used to acquire a gradient map corresponding to a first image, wherein the bit depth of the first image is a first bit depth;
[0139] A first determining module 420, configured to determine integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image to a pixel of a second bit depth, wherein the second bit depth is lower than the first bit depth;
[0140] A second determination module 430 is used to determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map;
[0141] A third determination module 440 is used to determine a target pixel value of each pixel in the first image converted into a pixel of the second bit depth based on the tendency index and the integer bit value corresponding to each pixel;
[0142] The fourth determination module 450 is configured to generate a second image according to the target pixel value of each pixel point of the second bit depth.
[0143] In an embodiment of the present application, when processing an image, reference is made to the gradient value of each pixel in the first image and the decimal value of each pixel when converted to a second-bit-depth pixel, and a tendency index is obtained to characterize that when the pixel is converted to a second-bit-depth pixel, its pixel value takes an integer value. The tendency index is used to perform fine processing on the integer value of the pixel, so that the target pixel value of the second-bit-depth pixel converted by the pixel can be accurately obtained, and then a second image with faded layers can be obtained. Compared with the prior art of processing the pixels in the first image by rounding off, the solution of the embodiment of the present application effectively reduces the image fault and layering problems caused by the loss of precision.
[0144] In some embodiments of the present application, the second determining module 430 may specifically include:
[0145] A first determining unit, configured to determine the gradient degree of each pixel point in the gradient map according to the gradient value of each pixel point and a reference threshold;
[0146] The second determination unit is used to determine the tendency index of rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient degree.
[0147] In some embodiments of the present application, the first determining unit is specifically configured to:
[0148] The ratio of the pixel value of each pixel point to the reference threshold is determined as the gradient degree of each pixel point.
[0149] In some embodiments of the present application, the second determining module 430 may further include:
[0150] A first acquisition unit is used to acquire the target edge feature type corresponding to each pixel point in the gradient map;
[0151] A third determining unit is used to process the reference image of each target edge feature type using a Sobel matrix to obtain first gradient information corresponding to the reference image of each target edge feature type;
[0152] A fourth determination unit is used to use the first gradient information corresponding to a first target edge feature type as a reference threshold corresponding to a first pixel point in the gradient map, wherein the first target edge feature type is any one of the target edge feature types, and the first pixel point is a pixel point in the gradient map whose edge feature type is the first target edge feature type.
[0153] In some embodiments of the present application, the first acquisition module 410 is specifically used to:
[0154] Processing each pixel in the first image using a first submatrix in a Sobel matrix to obtain second gradient information of each pixel in a first direction;
[0155] Processing each pixel in the first image using a second submatrix in a Sobel matrix to obtain third gradient information of each pixel in a second direction;
[0156] A gradient map of the first image is obtained according to the second gradient information and the third gradient information of each pixel.
[0157] In some embodiments of the present application, the third determination module 440 includes:
[0158] A fifth determining unit, configured to randomly generate a random value using a random function;
[0159] a sixth determining unit, configured to determine a correction value corresponding to each pixel point according to the random value, the tendency index corresponding to each pixel point, and a maximum value of a random value range randomly generated by the random function;
[0160] A seventh determination unit is used to correct the integer bit value corresponding to each pixel point based on the correction value of each pixel point to obtain a target pixel value of each pixel point converted into a pixel point of the second bit depth.
[0161] In some embodiments of the present application, the seventh determining unit is specifically configured to:
[0162] The sum of the correction value of each pixel point and the integer bit value corresponding to each pixel point is determined as the target pixel value of each pixel point converted into the pixel point of the second bit depth.
[0163] The image processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmentedreality, AR) / virtual reality (virtualreality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0164] The image processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0165] The image processing device provided in the embodiment of the present application can achieve Figure 1 The various processes implemented in the method embodiment achieve the same technical effect and will not be described again here to avoid repetition.
[0166] Alternatively, if Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores programs or instructions that can be executed on the processor 501, and when the program or instructions are executed by the processor 501, the various steps of the above-mentioned image processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0167] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0168] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0169] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, and a processor 610.
[0170] Those skilled in the art will appreciate that the electronic device 600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0171] Among them, the processor 610 is used to obtain a gradient map corresponding to a first image, wherein the bit depth of the first image is the first bit depth; determine the integer and decimal values of the pixel values of each pixel in the first image when converting each pixel in the first image to a pixel of a second bit depth, the second bit depth being lower than the first bit depth; determine a tendency index for rounding the decimal values corresponding to each pixel according to the decimal values corresponding to each pixel and the gradient values corresponding to the gradient map; determine a target pixel value for converting each pixel in the first image to a pixel of the second bit depth based on the tendency index and the integer value corresponding to each pixel; and generate a second image according to the target pixel value of each pixel of the second bit depth.
[0172] In this way, when processing the image, the gradient value of each pixel in the first image and the decimal value of each pixel when converted to the second bit-depth pixel are referred to, and a tendency index is obtained to characterize that the pixel value is an integer value when converted to the second bit-depth pixel. The integer value of the pixel is refined using the tendency index, so that the target pixel value of the second bit-depth pixel converted by the pixel can be accurately obtained, and then a second image with faded layers can be obtained. Compared with the prior art of processing the pixels in the first image by rounding off, the solution of the embodiment of the present application effectively reduces the image fault and layering problems caused by the loss of precision.
[0173] In some embodiments, the processor 610 is further used to determine the gradient degree of each pixel point in the gradient map based on the gradient value of each pixel point and the reference threshold; and to determine a tendency index for rounding the decimal value corresponding to each pixel point based on the decimal value corresponding to each pixel point and the gradient degree.
[0174] In this way, compared with the prior art of directly rounding decimal values, the present application determines the tendency index of rounding the decimal values corresponding to each pixel point by referring to the gradient degree of each pixel point. In this way, the value tendency index can be used to refine the integer value of the pixel point subsequently, thereby reducing the image fault and stratification problems caused by the loss of precision.
[0175] In some embodiments, the processor 610 is further configured to determine the ratio of the pixel value of each pixel point to a reference threshold as the gradient degree of each pixel point.
[0176] In this way, for each pixel point in the gradient map, the gradient degree of the pixel point is determined by the ratio of the pixel value of the pixel point to the reference threshold. In this way, the gradient degree of the pixel point can be quantified to facilitate more intuitive determination of the gradient degree of each pixel point.
[0177] In some embodiments, the processor 610 is further used to obtain the target edge feature type corresponding to each pixel point in the gradient map; use the Sobel matrix to process the reference image of each target edge feature type to obtain the first gradient information corresponding to the reference image of each target edge feature type; use the first gradient information corresponding to the first target edge feature type as the reference threshold corresponding to the first pixel point in the gradient map, wherein the first target edge feature type is any one of the target edge feature types, and the first pixel point is a pixel point in the gradient map whose edge feature type is the first target edge feature type.
[0178] In this way, by determining the target edge feature type of each pixel point in the gradient map, and then determining the reference threshold of each pixel point in the gradient map according to the first gradient information of the reference image of each target edge feature type after gradient calculation, the corresponding reference threshold is determined for each pixel point, and then the corresponding subsequent operations can be performed for the reference threshold of each pixel point, thereby improving the fineness of the processing of each pixel point, thereby improving the fineness of the image quality of the second image, and reducing the stratification problem of the second image.
[0179] In some embodiments, the processor 610 is further used to process each pixel in the first image using the first sub-matrix in the Sobel matrix to obtain second gradient information of each pixel in the first direction; process each pixel in the first image using the second sub-matrix in the Sobel matrix to obtain third gradient information of each pixel in the second direction; and obtain a gradient map of the first image based on the second gradient information and the third gradient information of each pixel.
[0180] In this way, for each pixel in the first image, the first submatrix in the Sobel matrix is used to process the pixel to obtain the second gradient information of the pixel in the first direction, and then the second submatrix in the Sobel matrix is used to process the pixel to obtain the third gradient information of the pixel in the second direction, and then according to the second gradient information and the third gradient information of each pixel, the gradient map of the first image can be obtained. In this way, by quantizing the gradient information of each pixel in the first image, the gradient map of the first image can be accurately obtained.
[0181] In some embodiments, the processor 610 is also used to randomly generate a random value using a random function; determine the correction value corresponding to each pixel point based on the random value, the tendency index corresponding to each pixel point and the maximum value of the random value range randomly generated by the random function; correct the integer bit value corresponding to each pixel point based on the correction value of each pixel point to obtain the target pixel value of each pixel point converted into the pixel point of the second bit depth.
[0182] In this way, for each pixel in the first image, a random value is randomly generated by using a random function, and then the correction value corresponding to the pixel can be determined according to the random value, the tendency index corresponding to the pixel and the maximum value of the random value range randomly generated by the random function. In this way, the correction value of the pixel can be used to correct the integer value corresponding to the pixel, and then the target pixel value of the pixel of the second bit depth converted by the pixel can be accurately obtained. Compared with the prior art that directly rounds the decimal value, the solution of the embodiment of the present application uses the tendency index to determine the tendency of rounding the decimal value, and then uses the tendency to correct the integer value, thereby reducing the image stratification problem caused by the loss of precision.
[0183] In some embodiments, the processor 610 is further configured to determine the sum of the correction value of each pixel point and the integer bit value corresponding to each pixel point as the target pixel value of each pixel point converted into the pixel point of the second bit depth.
[0184] In this way, for each pixel in the first image, the target pixel value of the pixel of the second bit depth converted by the pixel can be determined by summing the correction value of the pixel and the integer bit value corresponding to the pixel. In this way, the target pixel value can be accurately determined, and a second image with faded layers can be obtained, thereby reducing the image stratification problem caused by the loss of precision.
[0185] It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (Graphics Processing Unit, GPU) 6041 and a microphone 6042, and the graphics processor 5041 processes the image data of the static picture or video obtained by the image capture device (such as a color camera) in the video capture mode or the image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0186] The memory 609 can be used to store software programs and various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 609 may include a volatile memory or a non-volatile memory, or the memory 609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0187] The processor 610 may include one or more processing units; optionally, the processor 610 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 610.
[0188] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0189] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0190] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0191] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0192] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0193] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0194] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0195] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image processing method, characterized in that: The method comprises: Obtaining a gradient map corresponding to a first image, wherein the bit depth of the first image is a first bit depth; Determining integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image to a pixel of a second bit depth, wherein the second bit depth is lower than the first bit depth; Determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map; Determining, based on the tendency index and the integer bit value corresponding to each pixel point, a target pixel value of each pixel point in the first image converted into a pixel point of the second bit depth; A second image is generated according to the target pixel value of each pixel point of the second bit depth.
2. The method according to claim 1, characterized in that The step of determining the tendency index of rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map includes: Determine the gradient degree of each pixel point according to the gradient value of each pixel point in the gradient map and a reference threshold; According to the decimal value corresponding to each pixel point and the gradient degree, a tendency index for rounding the decimal value corresponding to each pixel point is determined.
3. The method according to claim 2, characterized in that Determining the gradient degree of each pixel point according to the gradient value of each pixel point in the gradient map and a reference threshold value includes: The ratio of the gradient value of each pixel point to the reference threshold is determined as the gradient degree of each pixel point.
4. The method according to claim 2, characterized in that: Before determining the gradient degree of the pixel point according to the gradient value of each pixel point in the gradient map and the reference threshold, the method further includes: Obtaining the target edge feature type corresponding to each pixel point in the gradient map; Using a Sobel matrix to process the reference image of each target edge feature type, to obtain first gradient information corresponding to the reference image of each target edge feature type; The first gradient information corresponding to the first target edge feature type is used as a reference threshold corresponding to the first pixel point in the gradient map, wherein the first target edge feature type is any one of the target edge feature types, and the first pixel point is a pixel point in the gradient map whose edge feature type is the first target edge feature type.
5. The method according to claim 1, characterized in that The step of obtaining a gradient map corresponding to the first image includes: Processing each pixel in the first image using a first submatrix in a Sobel matrix to obtain second gradient information of each pixel in a first direction; Processing each pixel in the first image using a second submatrix in a Sobel matrix to obtain third gradient information of each pixel in a second direction; A gradient map corresponding to the first image is obtained according to the second gradient information and the third gradient information of each pixel point.
6. The method according to claim 1, characterized in that The step of determining a target pixel value of each pixel in the first image converted into a pixel of the second bit depth based on the tendency index and the integer bit value corresponding to each pixel, comprises: Use random functions to randomly generate random values; Determine the correction value corresponding to each pixel point according to the random value, the tendency index corresponding to each pixel point and the maximum value of the random value range randomly generated by the random function; The integer bit values corresponding to the pixels are corrected based on the correction values of the pixels to obtain target pixel values of the pixels converted into the pixels of the second bit depth.
7. The method according to claim 6, characterized in that The correcting the integer bit value corresponding to each pixel point based on the correction value of each pixel point to obtain the target pixel value of each pixel point converted into the pixel point of the second bit depth includes: The sum of the correction value of each pixel and the integer bit value corresponding to each pixel is determined as the target pixel value of the pixel converted into the pixel of the second bit depth.
8. An image processing device, characterized in that: The device comprises: A first acquisition module, used to acquire a gradient map corresponding to a first image, wherein the bit depth of the first image is a first bit depth; A first determining module, configured to determine integer bit values and decimal bit values of pixel values of each pixel in the first image converted when converting each pixel in the first image to a pixel of a second bit depth, wherein the second bit depth is lower than the first bit depth; A second determination module is used to determine a tendency index for rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient value corresponding to the gradient map; A third determination module is used to determine a target pixel value of each pixel in the first image converted into a pixel of the second bit depth based on the tendency index and the integer bit value corresponding to each pixel; The fourth determination module is used to generate a second image according to the target pixel value of each pixel point of the second bit depth.
9. The device according to claim 8, characterized in that The second determining module includes: A first determining unit, configured to determine the gradient degree of each pixel point in the gradient map according to the gradient value of each pixel point and a reference threshold; The second determination unit is used to determine the tendency index of rounding the decimal value corresponding to each pixel point according to the decimal value corresponding to each pixel point and the gradient degree.
10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
FPGA-based linear feature extraction system
CN106504182A
Image processing method and device and electronic equipment
CN109961444A
Image edge detection and tracking method
CN116109661A
Floating-point complementary depth buffer
US6285779B1
