Image processing method, device, electronic device and storage medium
By dividing the target area in image processing and adjusting the filter weight adaptively, the problem of low image processing quality caused by manual selection of fixed filter weights is solved, and more efficient image sharpening effect and quality improvement is achieved.
Patent Information
- Application Number
- CN202210277863.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-03-21
AI Technical Summary
In the prior art, in image sharpening processing, manual selection of fixed filter weights leads to a large workload and a unified sharpening effect, resulting in a lower image processing quality.
By obtaining the area parameters of multiple target areas in the original image, dividing them into the first sub-region and the second sub-region, determining the filter weight according to the area parameters, and weighting fusion is performed based on the filter weight and frequency band information, and adjusting the filter weight adaptively to Improve image processing quality.
The quality of image processing is improved, the convergence of sharpening effects is avoided, the clarity and edge characteristics of the image are enhanced, and the workload of manual weight adjustment is reduced.
Smart Images

Figure CN114612337B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art
[0002] As the number of user experiences in the short video industry continues to increase, more and more users are transforming from video viewers to creators. However, these creators may not have professional shooting equipment when creating, so the clarity of the videos they produce is very poor. In order to make the produced video more realistic and natural, the images in the video can generally be sharpened. Sharpening can refer to obtaining low-frequency information and high-frequency information of the image through a filter, adjusting the high-frequency information using preset filter weights, and superimposing the adjusted high-frequency information on the low-frequency information to obtain a superimposed image. The superimposed image is the sharpened image.
[0003] Normally, when sharpening an image, a manually selected fixed filter weight is generally used to adjust the high-frequency information of the image, and then the adjusted high-frequency information is superimposed on the low-frequency information to obtain a sharpened image. However, the workload required to manually select fixed filter weights is very large, and if the same fixed filter weight is used in all areas of the image, the sharpening effect tends to be uniform, resulting in poor image sharpening effect, and then resulting in low quality of image processing. Summary of the invention
[0004] The present disclosure provides an image processing method, an apparatus, an electronic device and a storage medium for improving the quality of image processing.
[0005] The technical solution of the embodiment of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, an image processing method is provided. The method may include:
[0007] Acquire a region parameter of a first sub-region and a region parameter of a second sub-region in each target region, and frequency band information of each target region in a plurality of target regions in the original image; the first sub-region and the second sub-region are two intersecting sub-regions divided by the target region according to a preset rule;
[0008] For each target area, determining a filtering weight of the target area according to an area parameter of the first sub-area and an area parameter of the second sub-area;
[0009] According to the filter weights and frequency band information of multiple target areas, a target image is obtained after the original image is processed.
[0010] Optionally, the region parameters include: pixel average, pixel variance and pixel intensity; acquiring the region parameters of the first sub-region and the second sub-region in each of the multiple target regions in the original image includes:
[0011] Obtaining pixel values of all pixels in the target sub-region, and determining the ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region as the pixel average value of the target sub-region; the target sub-region is the first sub-region or the second sub-region;
[0012] Determine the pixel variance of the target sub-region according to the pixel average value of the target sub-region;
[0013] The pixel average of the target sub-region is determined as the pixel intensity of the target sub-region.
[0014] Optionally, determining the filtering weight of the target area according to the area parameter of the first sub-area and the area parameter of the second sub-area includes:
[0015] When the area parameter of the first sub-area and the area parameter of the second sub-area meet the preset conditions, determining the filtering weight of the target area to be the first weight; the preset conditions include: the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area is greater than the first preset difference, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area is greater than zero and less than the second preset difference;
[0016] When the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition, the filtering weight of the target area is determined to be a second weight; and the second weight is smaller than the first weight.
[0017] Optionally, the filtering weight of the target area is positively correlated with the target value; the target value is the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area.
[0018] Optionally, the preset rules include: the pixel average value of the target area is equal to the sum of the first value and the second value; the first value is half of the pixel average value of the first sub-area; the second value is half of the pixel average value of the second sub-area.
[0019] Optionally, the frequency band information includes high frequency information and low frequency information; obtaining a target image after the original image is processed according to the filter weights and the frequency band information of the multiple target areas includes:
[0020] For each target area, weighted fusion is performed according to the filter weight of the target area and the high-frequency information of the target area, and the fused result is fused with the low-frequency information of the target area to obtain a processed regional image of the target area;
[0021] The regional images of multiple target areas are fused to obtain a target image.
[0022] Optionally, obtain frequency band information for each target area, including:
[0023] For each target area, a preset filter is called to filter the target area to obtain low-frequency information of the target area;
[0024] The high-frequency information of the target area is determined according to the difference between the image information of the target area and the low-frequency information of the target area.
[0025] According to a second aspect of an embodiment of the present disclosure, an image processing device is provided. The device may include: an acquisition unit and a processing unit;
[0026] An acquisition unit, used to acquire, in each of the multiple target regions in the original image, region parameters of a first sub-region and a second sub-region, and frequency band information of each target region; the first sub-region and the second sub-region are two intersecting sub-regions divided by the target region according to a preset rule;
[0027] A processing unit, configured to determine, for each target region, a filtering weight of the target region according to a region parameter of the first sub-region and a region parameter of the second sub-region;
[0028] The processing unit is also used to obtain a target image after the original image is processed according to the filter weights and frequency band information of the multiple target areas.
[0029] Optionally, the regional parameters include: pixel average, pixel variance and pixel intensity; the processing unit is specifically used for:
[0030] Obtaining pixel values of all pixels in the target sub-region, and determining the ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region as the pixel average value of the target sub-region; the target sub-region is the first sub-region or the second sub-region;
[0031] Determine the pixel variance of the target sub-region according to the pixel average value of the target sub-region;
[0032] The pixel average of the target sub-region is determined as the pixel intensity of the target sub-region.
[0033] Optionally, a processing unit is used to:
[0034] When the area parameter of the first sub-area and the area parameter of the second sub-area meet the preset conditions, determining the filtering weight of the target area to be the first weight; the preset conditions include: the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area is greater than the first preset difference, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area is greater than zero and less than the second preset difference;
[0035] When the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition, the filtering weight of the target area is determined to be a second weight; and the second weight is smaller than the first weight.
[0036] Optionally, the filtering weight of the target area is positively correlated with the target value; the target value is the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area.
[0037] Optionally, the preset rules include: the pixel average value of the target area is equal to the sum of the first value and the second value; the first value is half of the pixel average value of the first sub-area; the second value is half of the pixel average value of the second sub-area.
[0038] Optionally, the frequency band information includes high frequency information and low frequency information; the processing unit is specifically configured to:
[0039] For each target area, weighted fusion is performed according to the filter weight of the target area and the high-frequency information of the target area, and the fused result is fused with the low-frequency information of the target area to obtain a processed regional image of the target area;
[0040] The regional images of multiple target areas are fused to obtain a target image.
[0041] Optionally, obtain the unit, specifically used to:
[0042] For each target area, a preset filter is called to filter the target area to obtain low-frequency information of the target area;
[0043] The high-frequency information of the target area is determined according to the difference between the image information of the target area and the low-frequency information of the target area.
[0044] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, which may include: a processor and a memory for storing processor executable instructions; wherein the processor is used to execute the instructions to implement any one of the optional image processing methods in the above-mentioned first aspect.
[0045] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which instructions are stored. When the instructions in the computer-readable storage medium are executed by an electronic device, the electronic device is enabled to execute any one of the optional image processing methods in the first aspect above.
[0046] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes any optional image processing method as described in the first aspect.
[0047] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0048] Based on any of the above aspects, in the present disclosure, after obtaining the area parameters of the first sub-area and the second sub-area in each of the multiple target areas in the original image, as well as the frequency band information of each target area, the filter weights corresponding to each target area can be determined according to the area parameters of the first sub-area and the second sub-area, and the target image after the original image processing is obtained according to the filter weights and frequency band information of the multiple target areas. Since the filter weights correspond one-to-one to the area parameters of the sub-areas of the multiple target areas of the original image, the present application can determine whether there are edge features in the target area according to the area parameters of the sub-areas of the target area of the original image, and then adaptively adjust the corresponding filter weights. Therefore, compared with the method of manually specifying fixed filter weights, the present application can improve the quality of image processing.
[0049] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0051] Figure 1 A schematic diagram of an original image provided by an embodiment of the present disclosure is shown;
[0052] Figure 2 A schematic diagram showing another original image provided by an embodiment of the present disclosure is shown;
[0053] Figure 3 A schematic diagram of a flow chart of an image processing method provided by an embodiment of the present disclosure is shown;
[0054] Figure 4A schematic diagram of the structure of an image processing provided by an embodiment of the present disclosure is shown;
[0055] Figure 5 A schematic diagram of a processing image of a filter kernel provided by an embodiment of the present disclosure is shown;
[0056] Figure 6 A schematic diagram showing a flow chart of another image processing method provided by an embodiment of the present disclosure;
[0057] Figure 7 A schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure is shown;
[0058] Figure 8 A schematic structural diagram of another image processing device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0059] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0060] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0061] It should also be understood that the term “comprising” indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements and / or components.
[0062] It should be noted that the user information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to image data) involved in this disclosure may be data authorized by the user or fully authorized by all parties.
[0063] Before introducing the embodiments of the present application, the terms involved in the embodiments of the present application are first explained.
[0064] Image sharpening: Image sharpening is to highlight the edges, contours or features of certain target elements on the image. For example, in order to compensate for the contours of the image, enhance the edges and grayscale jumps of the image, and make the image clear, the image can be sharpened.
[0065] Among them, enhancing the edge and grayscale jump part of the image may refer to enhancing the high-frequency information (also called high-frequency component) of the image. Sharpening the image may refer to superimposing the enhanced high-frequency information of the image with the low-frequency information (also called low-frequency component) of the image.
[0066] In a possible implementation, low-frequency information of the original image can be extracted by low-frequency filtering, and then the low-frequency information is subtracted from the original image to obtain high-frequency information. Then, the high-frequency information is superimposed on the original image to achieve image enhancement.
[0067] Low-frequency filtering: refers to filtering out high-frequency information in an image through a low-frequency filter, thereby extracting low-frequency information of the image. For example, a low-frequency filter may include a mean filter (also called a mean convolver), a Gaussian convolution filter (also called a Gaussian filter), and the like.
[0068] Filter: can be used to filter an image. A filter can include a filter kernel (also called a convolution kernel). A filter can be configured with a filter kernel and a smoothing parameter. Different filters can have different filter kernel sizes and different smoothing parameters.
[0069] Among them, the size of the filter kernel may refer to the length × width of the filter kernel. For example, the size of the filter kernel may include 3×3, 5×5, 7×7, 11×11, 12×12, etc. The size of the filter kernel may be determined by the filter radius. The size of the filter kernel may refer to the width of a filter radius extending in the four directions of the top, bottom, left, and right of the pixel to be processed, with the pixel to be processed as the center. For example, if the filter radius is r, and the length and width of the filter kernel are k, then k=2r+1. For another example, if the filter radius is 1, the size of the filter kernel is 3×3; if the filter radius is 2, the size of the filter kernel is 5×5.
[0070] It should be noted that, in the embodiment of the present application, the filter kernel may include a numerical matrix composed of multiple filter weight values. Each numerical value in the numerical matrix corresponds to a pixel point of the original image. For example, when the size of the filter kernel is 12×12, the number of pixels corresponding to the filter kernel may be 144.
[0071] Among them, the smoothing parameter of the filter can be used to characterize the ability of the filter to filter low-frequency information. The smaller the smoothing parameter of the filter, the weaker the filtering ability, and the closer the filtered image is to the original image.
[0072] Specifically, the filter may perform sharpening processing on the image based on an image augmentation algorithm.
[0073] Image enhancement algorithm: can be used to adjust the brightness, contrast, saturation, hue, etc. of an image, increase its clarity, reduce noise, etc. For example, an image enhancement algorithm may include an edge sharpening algorithm.
[0074] Among them, the edge sharpening algorithm can be referred to as the sharpening algorithm for short. It is to decompose the image into high-frequency information and low-frequency information, and then manually select a set of high-frequency filter weights to superimpose the high-frequency information on the low-frequency information, so as to achieve image sharpening. The performance of the edge sharpening algorithm mainly depends on the design of the filter. Reasonable filter design will bring rich edge information without excessively sharpening noise, such as edge white edges, background noise, etc.
[0075] In the related art, different scale image decomposition methods are usually used to decompose the image through multiple filters of different scales, and then the obtained high-frequency information is superimposed on the original image to obtain the processed image result.
[0076] Specifically, the process of decomposing an image through multiple filters of different scales can be: Bn = Kn (X), where Kn is the filter kernel of the filter, for example, the filter kernel can include guided filter (Guided filter), Gaussian filter, bilateral filter, etc. Bn is the low-frequency information of the image, X is the input original image, which is an RGB three-channel image. The high-frequency information (Dn) corresponding to the image can be: Dn = X-Bn.
[0077] Next, when the obtained high-frequency information is superimposed on the original image, and the processed image result is obtained, the filter weight of the high-frequency information can be set manually. For example, taking the low-frequency information obtained by the edge sharpening algorithm through filters of three different sizes as an example, the low-frequency information corresponding to each size is B1, B2, B3, and the corresponding high-frequency information is D1, D2, D3. The high-frequency filter weight corresponding to each high-frequency information is manually adjusted, and the adjusted high-frequency filter weights are w1, w2, and w3. Finally, the high-frequency information is multiplied by the corresponding high-frequency filter weight and then superimposed with the low-frequency information. The superposition process can be: Y = w1*D1+w2*D2+w3*D3+B1, where Y is the result of image processing.
[0078] This method usually uses a Gaussian kernel as Kn. Gaussian filtering is a linear smoothing filter that uses the same statistical characteristics to filter different areas of the image. Usually, the distribution state of this Gaussian kernel is related to the radius, mean, and variance. When the mean and variance are constant, changing the radius will increase the sampling range of the Gaussian kernel and make the local sampling range of the image wider. Although the Gaussian kernel is distributed according to statistical characteristics, its statistical characteristics have nothing to do with the image itself, but are related to the specified variance and mean. The variance in the Gaussian kernel determines the smoothing of the image. The larger the variance, the wider the frequency band of the Gaussian kernel, and the smoother the result after sampling. However, excessive smoothing will cause the low-frequency information to be very flat, which means that the high-frequency information is full of noise, so the image noise will be seriously amplified after multi-scale superposition.
[0079] In one example, different regions of the original image have different sharpening requirements. For example, for an image with less texture, such as Figure 1 The area 1 shown includes an image of the sky. Since the image is relatively smooth, it does not need to be over-sharpened. Therefore, a smaller high-frequency filter weight needs to be selected for the image. For another example, for an image with rich texture, such as Figure 1 The region 2 shown includes an image of a brick wall. In order to increase the texture in the image, the image needs to be appropriately sharpened. Therefore, a larger high-frequency filter weight needs to be selected for the image.
[0080] In the related art, if each area of the image is processed by manually specifying fixed high-frequency filter weights, the overall sharpening effect of the image will be convergent, that is, the sharpening degree of each area of the image is the same. However, the image includes multiple different scenes, and the sharpening requirements of each scene are different. If the image is sharpened by manually specifying fixed high-frequency filter weights, it is obvious that the optimal sharpening effect cannot be achieved.
[0081] like Figure 2 As shown in the figure, although the image of the brick wall in area 2 is sharpened, there is an obvious white edge at the edge. This is because the Gaussian kernel has the same weight for all areas, so the edge is over-emphasized.
[0082] In view of this, the embodiment of the present disclosure provides an image processing method, after obtaining the area parameters of the first sub-region and the second sub-region in each target region in the multiple target regions in the original image, as well as the frequency band information of each target region, the filter weights corresponding to each target region can be determined according to the area parameters of the first sub-region and the second sub-region, and the target image after the original image is processed can be obtained according to the filter weights and frequency band information of the multiple target regions. Since the filter weights correspond to the area parameters of the sub-regions of the multiple target regions of the original image one by one, the present application can determine whether there are edge features in the target region according to the area parameters of the sub-regions of the target region of the original image, and then adaptively adjust the corresponding filter weights. Therefore, compared with the method of manually specifying fixed filter weights, the present application can improve the quality of image processing.
[0083] The image processing method, device, electronic device and storage medium provided by the embodiments of the present disclosure are applied to the scene of sharpening an image. When the electronic device responds to the image processing request, the image can be sharpened according to the method provided by the embodiments of the present disclosure. The image processing request can be used to instruct to sharpen the image.
[0084] The following is an exemplary description of the image processing method provided by the embodiment of the present disclosure in conjunction with the accompanying drawings:
[0085] Exemplarily, the electronic device that executes the image processing method provided by the embodiments of the present disclosure may be a mobile phone, a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (PDA), an augmented reality (AR)\virtual reality (VR) device, and other devices that can install and use content community applications (such as multimedia applications, etc.).
[0086] As another example, the electronic device that executes the image processing method provided in the embodiment of the present disclosure may also be a server or other device. The server may also perform sharpening processing on the image. That is, the image processing method provided in the embodiment of the present application may also be executed.
[0087] The server may be a single server, or a server cluster consisting of multiple servers. In some implementations, the server cluster may also be a distributed cluster.
[0088] In the embodiment of the present application, the server may include multiple application service platforms, each application service platform uniquely corresponds to an application, and the application is installed on the terminal device. The server is mainly used to store relevant business data of the application.
[0089] The present disclosure does not impose any special restrictions on the specific form of the electronic device, which can interact with the user through one or more methods such as a keyboard, a touch pad, a touch screen, a remote controller, voice interaction, or a handwriting device.
[0090] like Figure 3 As shown, the image processing method provided by the embodiment of the present disclosure may include S301-S303.
[0091] S301: The electronic device obtains, in a plurality of target areas in an original image, area parameters of a first sub-area and area parameters of a second sub-area in each target area, and frequency band information of each target area.
[0092] The first sub-region and the second sub-region are two intersecting sub-regions obtained by dividing the target region according to a preset rule.
[0093] Optionally, the preset rule may include: the pixel average value of the target area is equal to the sum of the first value and the second value; the first value is half of the pixel average value of the first sub-area; the second value is half of the pixel average value of the second sub-area. In other words, the pixel average value E[X] of the target area, the pixel average value E[Xa] of the first sub-area, and the pixel average value E[Xb] of the second sub-area may satisfy the following formula:
[0094] E[X]=E[Xa] / 2+E[Xb] / 2.
[0095] In this way, a specific implementation method for dividing the first sub-region and the second sub-region can be given through the pixel average value of the target region, the pixel average value of the first sub-region and the pixel average value of the second sub-region, thereby ensuring that the regional parameters of the two sub-regions can be accurately obtained later.
[0096] For example, Figure 4 As shown, a small grid is 1 pixel. The electronic device can divide the original image 401 (an image composed of 11*17 pixels in height and width) into two target areas: a target area 402 (an area composed of 11*8 pixels in height and width) and a target area 403 (an area composed of 11*9 pixels in height and width). The target area 402 includes a first sub-area 404 (an area composed of 7*8 pixels in height and width) and a second sub-area 405 (an area composed of 8*8 pixels in height and width). The first sub-area 404 and the second sub-area 405 include an intersecting area 406.
[0097] Optionally, the preset rule may further include: randomly dividing the target area into two intersecting sub-areas, that is, the first sub-area and the second sub-area may have an intersecting portion.
[0098] In one practicable manner, when the electronic device is a server, the server may perform image processing operations on the original image after receiving an image processing request (including the original image) from the mobile device. For example, the above S301 may be started.
[0099] The image processing request may be used to instruct to perform sharpening processing on the original image. The image processing request may include image data of the original image.
[0100] In another possible implementation, when the electronic device is a mobile device, the mobile device may perform a sharpening operation on the original image in response to an image processing operation performed by a user. For example, the above S301 may be started.
[0101] Optionally, when acquiring the area parameters of the first sub-area and the second sub-area in each target area, as well as the frequency band information of each target area in multiple target areas in the original image, the electronic device can use a preset filter to filter the sub-areas in each target area to obtain the area parameters of the first sub-area and the second sub-area in each target area, as well as the frequency band information of each target area.
[0102] The preset filter may be set as required, for example, a box filter, a guided filter, a bilateral filter, etc., without limitation.
[0103] Optionally, the region parameters include: pixel average, pixel variance and pixel intensity. The method for the electronic device to obtain the region parameters of the first sub-region and the second sub-region in each of the multiple target regions in the original image specifically includes:
[0104] The pixel values of all pixels in the target sub-region are obtained, and the ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region is determined as the pixel average value of the target sub-region.
[0105] The target sub-region is the first sub-region or the second sub-region.
[0106] Optionally, when the electronic device obtains the pixel values of all pixels in the target sub-area, it can call a preset filter to slide on the original image according to a preset step size, thereby obtaining the pixel values of all pixels in each target sub-area in each target area in the original image.
[0107] For example, Figure 5 As shown, the preset filter may be provided with a filter kernel, and the filter kernel may slide on the original image according to a preset step size. Figure 5 In FIG. 1 , the arrow indicates the sliding direction of the preset filter, and 11 indicates the size of the filter kernel. The filter kernel may include multiple sub-filter kernels. When the filter kernel moves to a target area of the original image, the pixel values of all pixels in the target area can be obtained.
[0108] The size of the filter kernel can be set as needed, for example, 12×12, or other sizes without limitation. The preset step size can be set as needed, for example, one or more pixels without limitation.
[0109] The electronic device determines the pixel variance of the target sub-region according to the pixel average value of the target sub-region.
[0110] Among them, the pixel mean value E[M] of the target sub-region and the pixel variance Var[M] of the target sub-region satisfy the following formula:
[0111] Var(M)=E[M^2]–(E[M])^2.
[0112] In this way, after obtaining the pixel average value and the pixel variance of the target sub-area, the electronic device can determine the correspondence between the pixel variance and the pixel average value of the target area and the pixel variance and the pixel average value of the first sub-area, and the pixel variance and the pixel average value of the second sub-area based on the pixel average value and the pixel variance of the target sub-area.
[0113] The pixel variance Var(X) and pixel average E[X] of the target area, the pixel variance Var(Xa) and pixel average E[Xa] of the first sub-area, and the pixel variance Var(Xb) and pixel average E[Xb] of the second sub-area satisfy the following formula:
[0114] Var(X)=E[X^2]–(E[X])^2
[0115] =E[Xa^2] / 2+E[Xb^2] / 2–(E[Xa] / 2+E[Xb] / 2)^2
[0116] =Var(Va) / 2+Var(Xb) / 2+(E[Xa]–E[Xb])^2 / 4.
[0117] The electronic device determines an average pixel value of the target sub-region as the pixel intensity of the target sub-region.
[0118] In this way, the electronic device can accurately obtain regional parameters including pixel average, pixel variance and pixel intensity, and provide a specific implementation method for obtaining regional parameters, thereby ensuring that the filtering weight of each target area can be adaptively determined based on the regional parameters.
[0119] Optionally, when the original image is an RGB image, when the electronic device determines the pixel intensity of the target sub-region, it can also map the original image from the RGB color space to the lab brightness space, thereby determining the brightness average of the target sub-region as the pixel intensity of the target sub-region.
[0120] S302: The electronic device determines, for each target area, a filtering weight of the target area according to an area parameter of the first sub-area and an area parameter of the second sub-area.
[0121] Specifically, after obtaining the area parameters of the first sub-area and the second sub-area in each target area, the electronic device can determine whether there is an obvious edge feature in the corresponding target area according to the area parameters of the first sub-area and the second sub-area in each target area. If there is an obvious edge feature in the target area, the filter weight of the target area can be set to a larger value. Correspondingly, if there is no obvious edge feature in the target area, the filter weight of the target area can be set to a smaller value.
[0122] Optionally, the filter weight of the target area is positively correlated with the target value.
[0123] The target value is the absolute value of the difference between the pixel variance of the first sub-region and the pixel variance of the second sub-region, or the absolute value of the difference between the pixel intensity of the first sub-region and the pixel intensity of the second sub-region. In this way, the electronic device can adaptively adjust the corresponding filter weights. Therefore, compared with the method of manually specifying fixed filter weights, the present application can improve the quality of image processing.
[0124] Optionally, when the area parameter of the first sub-area and the area parameter of the second sub-area meet a preset condition, the electronic device determines that the filtering weight of the target area is the first weight.
[0125] The preset conditions include: the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area is greater than a first preset difference, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area is greater than zero and less than a second preset difference.
[0126] Specifically, from the correspondence between the pixel variance and pixel average of the target area, the pixel variance and pixel average of the first sub-area, and the pixel variance and pixel average of the second sub-area, when the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area is greater than the first preset difference, it means that the pixel variance of the target area is large. In other words, the target area may include obvious edge features. In this case, the electronic device can determine the filtering weight of the target area as the first weight, so as to ensure that the sharpening effect of the target area is maximized.
[0127] When the absolute value of the difference between the pixel intensity of the first sub-region and the pixel intensity of the second sub-region is greater than zero and less than the second preset difference, it means that the pixels of the first sub-region are relatively close to the pixels of the second sub-region, but different. In this case, the target region may also include obvious edge features. Therefore, the electronic device can determine the filtering weight of the target region as the first weight, so as to ensure that the sharpening effect of the target region is maximized.
[0128] It should be noted that when the electronic device determines that the filtering weight of the target area is the first weight, it needs to be set accordingly according to the filtering weights of all target areas in the original image, so as to avoid excessive sharpening of the target area when the filtering weight of the target area is determined to be too large as the first weight.
[0129] Optionally, the preset condition may also include other conditions for indicating that the target area contains edge features, which is not limited in the present application.
[0130] When the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition, the filtering weight of the target area is determined to be the second weight.
[0131] The second weight is smaller than the first weight.
[0132] Specifically, when the area parameters of the first sub-area and the area parameters of the second sub-area do not meet the preset conditions, it means that the target area may not include obvious edge features, that is, the target area may include smooth features. In this case, the electronic device can determine the filtering weight of the target area as a second weight that is smaller than the first weight, thereby ensuring that the sharpening effect of the target area is minimized.
[0133] It should be noted that when the electronic device determines that the filtering weight of the target area is the second weight, it is also necessary to make a corresponding setting based on the filtering weights of all target areas in the original image, so as to avoid the situation where the filtering weight of the target area is determined to be too small as the first weight, resulting in no sharpening processing of the target area.
[0134] From the above, it can be seen that since the region parameter can reflect whether the region contains edge features, the filter weight of the target region can be accurately determined according to the difference in variance or pixel intensity of the region, thereby improving the quality of image processing.
[0135] S303: The electronic device obtains a target image after processing the original image according to the filter weights and frequency band information of the multiple target areas.
[0136] Optionally, the frequency band information includes high frequency information and low frequency information.
[0137] The method for an electronic device to obtain a target image after processing an original image according to filter weights and frequency band information of multiple target areas specifically includes:
[0138] For each target area, weighted fusion is performed according to the filter weight of the target area and the high-frequency information of the target area, and the fused result is fused with the low-frequency information of the target area to obtain a processed regional image of the target area.
[0139] The regional images of multiple target areas are fused to obtain a target image.
[0140] In this way, the electronic device can determine the corresponding filter weights by region. Since different target regions may correspond to different filter weights, different target regions on the same original image can determine the filter weights that match the regional parameters of the target region, and then the original image can be sharpened by region, which improves the quality of image processing and avoids the overall sharpening convergence of the original image.
[0141] For example, the electronic device may determine the target image according to the following formula.
[0142]
[0143] Where I′ represents the target image, RB k represents the low-frequency information of the kth target area, w k represents the filter weight of the kth target area, RD k represents the high frequency information of the kth target area. N represents the number of target areas included in the original image. N is a positive integer.
[0144] The technical solution provided by the above embodiment can at least bring the following beneficial effects: From S301-S303, it can be known that after obtaining the area parameters of the first sub-area and the second sub-area in each target area, as well as the frequency band information of each target area, in the multiple target areas in the original image, the filter weights corresponding to each target area can be determined according to the area parameters of the first sub-area and the second sub-area, and the target image after the original image processing is obtained according to the filter weights and frequency band information of the multiple target areas. Since the filter weights correspond to the area parameters of the sub-areas of the multiple target areas of the original image one by one, the present application can determine whether there are edge features in the target area according to the area parameters of the sub-areas of the target area of the original image, and then adaptively adjust the corresponding filter weights. Therefore, compared with the method of manually specifying fixed filter weights, the present application can improve the quality of image processing.
[0145] Combination Figure 3 ,like Figure 6 As shown, in the above S301, the method for the electronic device to obtain the frequency band information of each target area specifically includes:
[0146] S601: The electronic device calls a preset filter to perform filtering processing on each target area to obtain low-frequency information of the target area.
[0147] The preset filter may include a filter kernel, which may be used to filter the image to obtain low-frequency information of the image. For example, the filter kernel is a low-frequency filter kernel. The smoothing parameter of the filter kernel may be set as required, for example, it may be 0.0001, without limitation.
[0148] In one example, when the electronic device uses a filter kernel of a preset filter to slide to a target area on an original image, the electronic device can use the filter kernel to filter the target area to obtain low-frequency information of the target area.
[0149] S602: The electronic device determines high-frequency information of the target area according to a difference between the image information of the target area and the low-frequency information of the target area.
[0150] The image information of the target area can be used to characterize the image content of the target area, such as brightness information or grayscale value information of the image in the target area. For example, the image information of the target area may include low-frequency information and high-frequency information of the target area. After determining the low-frequency information, the electronic device can subtract the low-frequency information of the target area from the image information of the target area to obtain the high-frequency information of the target area.
[0151] In this way, through steps S601-S602, the electronic device can obtain low-frequency information and high-frequency information of a target area.
[0152] It should be noted that the electronic device can control the preset filter to slide on the original image, thereby traversing each target area of the original image, and repeatedly executing the above S601 and S602 to obtain low-frequency information and high-frequency information corresponding to each target area.
[0153] The technical solution provided by the above embodiment can at least bring the following beneficial effects: As can be seen from S601 and S602, the electronic device can use the filter kernel to obtain the low-frequency information of the target area, and determine the high-frequency information of the target area according to the difference between the image information of the target area and the low-frequency information of the target area. In this way, the electronic device can quickly and accurately determine the low-frequency information and high-frequency information of the target area, so that the target image can be accurately obtained according to the filter weight corresponding to each target area and the obtained frequency band information, thereby improving the quality of image processing.
[0154] It is understandable that, in actual implementation, the electronic device described in the embodiment of the present disclosure may include one or more hardware structures and / or software modules for implementing the aforementioned corresponding image processing method, and these execution hardware structures and / or software modules may constitute an electronic device. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiment disclosed herein, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present disclosure.
[0155] Based on this understanding, the present disclosure also provides an image processing device. Figure 7 FIG. 2 shows a schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure. Figure 7 As shown, the image processing device may include: an acquisition unit 701 and a processing unit 702;
[0156] The acquisition unit 701 is used to acquire, in each of the multiple target regions in the original image, region parameters of a first sub-region and a second sub-region, and frequency band information of each target region; the first sub-region and the second sub-region are two intersecting sub-regions in which the target region is divided according to a preset rule;
[0157] A processing unit 702 is used to determine, for each target area, a filtering weight of the target area according to the area parameter of the first sub-area and the area parameter of the second sub-area;
[0158] The processing unit 702 is further configured to obtain a target image after processing the original image according to the filter weights and frequency band information of the multiple target areas.
[0159] Optionally, the regional parameters include: pixel average, pixel variance and pixel intensity; the processing unit 702 is specifically configured to:
[0160] Obtaining pixel values of all pixels in the target sub-region, and determining the ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region as the pixel average value of the target sub-region; the target sub-region is the first sub-region or the second sub-region;
[0161] Determine the pixel variance of the target sub-region according to the pixel average value of the target sub-region;
[0162] The pixel average of the target sub-region is determined as the pixel intensity of the target sub-region.
[0163] Optionally, the processing unit 702 is specifically configured to:
[0164] When the area parameter of the first sub-area and the area parameter of the second sub-area meet the preset conditions, determining the filtering weight of the target area to be the first weight; the preset conditions include: the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area is greater than the first preset difference, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area is greater than zero and less than the second preset difference;
[0165] When the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition, the filtering weight of the target area is determined to be a second weight; and the second weight is smaller than the first weight.
[0166] Optionally, the filtering weight of the target area is positively correlated with the target value; the target value is the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area.
[0167] Optionally, the preset rules include: the pixel average value of the target area is equal to the sum of the first value and the second value; the first value is half of the pixel average value of the first sub-area; the second value is half of the pixel average value of the second sub-area.
[0168] Optionally, the frequency band information includes high frequency information and low frequency information; the processing unit 702 is specifically configured to:
[0169] For each target area, weighted fusion is performed according to the filter weight of the target area and the high-frequency information of the target area, and the fused result is fused with the low-frequency information of the target area to obtain a processed regional image of the target area;
[0170] The regional images of multiple target areas are fused to obtain a target image.
[0171] Optionally, the acquiring unit 701 is specifically configured to:
[0172] For each target area, a preset filter is called to filter the target area to obtain low-frequency information of the target area;
[0173] The high-frequency information of the target area is determined according to the difference between the image information of the target area and the low-frequency information of the target area.
[0174] As described above, the embodiment of the present disclosure can divide the functional modules of the image processing device according to the above method example. Among them, the above integrated modules can be implemented in the form of hardware or in the form of software functional modules. In addition, it should be noted that the division of modules in the embodiment of the present disclosure is schematic and is only a logical function division. There may be other division methods in actual implementation. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module.
[0175] Regarding the image processing device in the above embodiment, the specific manner in which each unit performs operations and the beneficial effects possessed have been described in detail in the aforementioned method embodiment and will not be repeated here.
[0176] Figure 8 is a schematic diagram of the structure of another image processing device provided by the present disclosure. Figure 8 The image processing device 12 may include at least one processor 121 and a memory 123 for storing processor executable instructions. The processor 121 is used to execute instructions in the memory 123 to implement the image processing method in the above embodiment.
[0177] In addition, the image processing device 12 may further include a communication bus 122 and at least one communication interface 124 .
[0178] The processor 121 may be a central processing unit (CPU), a microprocessing unit, an ASIC, or one or more integrated circuits for controlling the execution of the program of the disclosed solution.
[0179] The communication bus 122 may include a pathway for transmitting information between the above-mentioned components.
[0180] The communication interface 124 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0181] The memory 123 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processing unit through a bus. The memory may also be integrated with the processing unit.
[0182] The memory 123 is used to store instructions for executing the solution of the present disclosure, and the execution is controlled by the processor 121. The processor 121 is used to execute the instructions stored in the memory 123, so as to realize the functions in the method of the present disclosure.
[0183] In a specific implementation, as an embodiment, the processor 121 may include one or more CPUs, such as Figure 8 CPU0 and CPU1 in.
[0184] In a specific implementation, as an embodiment, the image processing device 20 may include multiple processors, such as Figure 8 1 and 127. Each of these processors may be a single-CPU processor or a multi-CPU processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0185] In a specific implementation, as an embodiment, the image processing apparatus 12 may further include an output device 125 and an input device 126. The output device 125 communicates with the processor 121 and may display information in a variety of ways. For example, the output device 125 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 126 communicates with the processor 121 and may receive user input in a variety of ways. For example, the input device 126 may be a mouse, a keyboard, a touch screen device, or a sensor device.
[0186] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the image processing device 12, and may include more or less components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
[0187] In addition, the present disclosure also provides a computer-readable storage medium, including instructions, which, when executed by an electronic device, enable the electronic device to execute the image processing method provided in the above embodiment.
[0188] In addition, the present disclosure also provides a computer program product, including instructions, which, when executed by an electronic device, enable the electronic device to execute the image processing method provided in the above embodiment.
[0189] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. An image processing method, characterized in that: include: Acquire a region parameter of a first sub-region and a region parameter of a second sub-region in each of the target regions, as well as frequency band information of each target region; The first sub-region and the second sub-region are two intersecting sub-regions obtained by dividing the target region according to a preset rule; The regional parameters include: pixel average, pixel variance and pixel intensity; the frequency band information includes high frequency information and low frequency information; For each target area, when the area parameter of the first sub-area and the area parameter of the second sub-area meet a preset condition, determining the filtering weight of the target area to be a first weight; the preset condition includes: an absolute value of a difference between a pixel variance of the first sub-area and a pixel variance of the second sub-area is greater than a first preset difference, or an absolute value of a difference between a pixel intensity of the first sub-area and a pixel intensity of the second sub-area is greater than zero and less than a second preset difference; When the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition, determining that the filtering weight of the target area is a second weight; the second weight is less than the first weight; Performing weighted fusion according to the filter weight of the target area and the high-frequency information of the target area, and fusing the fused result with the low-frequency information of the target area to obtain a processed regional image of the target area; The regional images of the multiple target regions are fused to obtain a target image.
2. The image processing method according to claim 1, characterized in that: The step of acquiring the region parameters of the first sub-region and the second sub-region in each of the plurality of target regions in the original image comprises: Obtaining pixel values of all pixels in a target sub-region, and determining a ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region as a pixel average value of the target sub-region; the target sub-region is the first sub-region or the second sub-region; Determining a pixel variance of the target sub-region according to a pixel average value of the target sub-region; The pixel average value of the target sub-region is determined as the pixel intensity of the target sub-region.
3. The image processing method according to claim 1, characterized in that: The filtering weight of the target area is positively correlated with the target value; The target value is an absolute value of a difference between a pixel variance of the first sub-region and a pixel variance of the second sub-region, or an absolute value of a difference between a pixel intensity of the first sub-region and a pixel intensity of the second sub-region.
4. The image processing method according to any one of claims 1 to 3, characterized in that: The preset rules include: the pixel average value of the target area is equal to the sum of a first value and a second value; the first value is half of the pixel average value of the first sub-area; and the second value is half of the pixel average value of the second sub-area.
5. The image processing method according to claim 1, characterized in that: Obtaining frequency band information of each target area includes: For each target area, calling a preset filter to perform filtering processing on the target area to obtain low-frequency information of the target area; The high-frequency information of the target area is determined according to the difference between the image information of the target area and the low-frequency information of the target area.
6. An image processing device, characterized in that: include: Acquisition unit and processing unit; The acquisition unit is used to acquire the region parameters of the first sub-region and the second sub-region in each of the multiple target regions in the original image, as well as the frequency band information of each target region; The first sub-region and the second sub-region are two intersecting sub-regions obtained by dividing the target region according to a preset rule; The regional parameters include: pixel average, pixel variance and pixel intensity; the frequency band information includes high frequency information and low frequency information; The processing unit is configured to determine, for each target area, when the area parameter of the first sub-area and the area parameter of the second sub-area meet a preset condition, that the filtering weight of the target area is a first weight; the preset condition includes: an absolute value of a difference between a pixel variance of the first sub-area and a pixel variance of the second sub-area is greater than a first preset difference, or an absolute value of a difference between a pixel intensity of the first sub-area and a pixel intensity of the second sub-area is greater than zero and less than a second preset difference; The processing unit is further configured to determine that the filtering weight of the target area is a second weight when the area parameter of the first sub-area and the area parameter of the second sub-area do not meet the preset condition; the second weight is less than the first weight; The processing unit is further used to perform weighted fusion with the high-frequency information of the target area according to the filtering weight of the target area, and fuse the fused result with the low-frequency information of the target area to obtain a processed regional image of the target area; The processing unit is further used to fuse the regional images of the multiple target regions to obtain a target image.
7. The image processing device according to claim 6, characterized in that: The processing unit is specifically used for: Obtaining pixel values of all pixels in a target sub-region, and determining a ratio of the sum of the pixel values of all pixels to the number of pixels in the target sub-region as a pixel average value of the target sub-region; the target sub-region is the first sub-region or the second sub-region; Determining a pixel variance of the target sub-region according to a pixel average value of the target sub-region; The pixel average value of the target sub-region is determined as the pixel intensity of the target sub-region.
8. The image processing device according to claim 6, characterized in that: The filtering weight of the target area is positively correlated with the target value; the target value is the absolute value of the difference between the pixel variance of the first sub-area and the pixel variance of the second sub-area, or the absolute value of the difference between the pixel intensity of the first sub-area and the pixel intensity of the second sub-area.
9. The image processing device according to any one of claims 6 to 8, characterized in that: The preset rules include: the pixel average value of the target area is equal to the sum of a first value and a second value; the first value is half of the pixel average value of the first sub-area; and the second value is half of the pixel average value of the second sub-area.
10. The image processing device according to claim 6, characterized in that: The acquisition unit is specifically used for: For each target area, calling a preset filter to perform filtering processing on the target area to obtain low-frequency information of the target area; The high-frequency information of the target area is determined according to the difference between the image information of the target area and the low-frequency information of the target area.
11. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image processing method according to any one of claims 1 to 5.
12. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions in the computer-readable storage medium are executed by an electronic device, the electronic device is enabled to execute the image processing method according to any one of claims 1 to 5.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the image processing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Non-local mean de-noising method for natural image
CN101950414A
Remote sensing image super-resolution reconstruction method based on multi-dictionary learning and non-local information fusion
CN105825477A