Layer superposition method and device, equipment and storage medium
By adding an offset adjustment algorithm to the ratio overlay algorithm, the problem of unnatural image color transition is solved, and a more natural color transition and improved image quality is achieved.
Patent Information
- Application Number
- CN202311789495.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2025-06-24
AI Technical Summary
When using the ratio superposition algorithm for image processing, the color transition between the local image color and the surrounding area in the image is unnatural, resulting in poor image quality and imaging effect.
By adding a smaller numerical offset to the initial ratio overlay algorithm, adjusting the numerator and/or denominator portion of the ratio overlay algorithm, a target ratio overlay algorithm is generated, and the image is superimposed by channel by pixel according to the algorithm.
By micro-correcting the color mutated pixel values in the superimposed result image, the difference in pixel values before and after adjustment is as small as possible, maintaining the overall image effect, and making the image color transition more natural, reducing abrupt color blocks, improving image quality and imaging effects.
Smart Images

Figure CN120198537A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technologies, and in particular, to a method, apparatus, device, and storage medium for layer superposition. Background Art
[0002] With the development of technologies, in order to enrich the expressive ability of images, many application program functions for image processing have emerged, including a layer superposition technology for mixing two images. The layer superposition technology performs a superposition process on the pixel values of two images according to a certain superposition processing algorithm. Among the layer superposition technologies, there are some ratio-based layer superposition algorithms (abbreviated as ratio superposition algorithms) that superpose two images by calculating ratios.
[0003] However, in the resulting image obtained by performing image processing using the ratio superposition algorithm, there will be a phenomenon of color blocks where the color of a local image transitions unnaturally with the color of its surrounding area, resulting in poor image quality and imaging effect of the resulting image. Summary of the Invention
[0004] To solve the above technical problems, embodiments of the present disclosure provide a method, apparatus, device, and storage medium for layer superposition.
[0005] In a first aspect, embodiments of the present disclosure provide a method for layer superposition, the method including:
[0006] Obtaining a first layer image as a base color and a second layer image as a mixed color;
[0007] Determining an offset that meets a preset condition;
[0008] Performing a ratio superposition process on the first layer image and the second layer image according to a target ratio superposition algorithm to generate a superposition result image; wherein, the target ratio superposition algorithm is obtained by adding the offset to a target position in an initial ratio superposition algorithm.
[0009] In a second aspect, embodiments of the present disclosure further provide a layer superposition apparatus, the apparatus including:
[0010] A layer image acquisition module, configured to obtain a first layer image as a base color and a second layer image as a mixed color;
[0011] An offset determination module, configured to determine an offset that meets a preset condition;
[0012] A layer superposition module, configured to perform a ratio superposition process on the first layer image and the second layer image according to a target ratio superposition algorithm to generate a superposition result image; wherein, the target ratio superposition algorithm is obtained by adding the offset to a target position in an initial ratio superposition algorithm.
[0013] In a third aspect, embodiments of the present disclosure also provide a layer overlay device, which includes:
[0014] A processor;
[0015] A memory for storing executable instructions;
[0016] Wherein, the processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the layer overlay method described in any embodiment of the present disclosure.
[0017] In a fourth aspect, embodiments of the present disclosure also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the layer overlay method described in any embodiment of the present disclosure.
[0018] In a fifth aspect, embodiments of the present disclosure also provide a computer program product for executing the layer overlay method described in any embodiment of the present disclosure.
[0019] The layer overlay method, apparatus, device, and storage medium according to the embodiments of the present disclosure can obtain a first layer image as a base color and a second layer image as a mixed color, and determine an offset that meets a preset condition; the value of the offset is a relatively small positive value, which can be added to a target position in an initial ratio overlay algorithm according to the service requirements of image processing to obtain a target ratio overlay algorithm with offset correction. Then, according to the target ratio overlay algorithm, the first layer image and the second layer image are subjected to ratio overlay processing pixel by pixel for each channel to generate an overlay result image; it realizes a slight correction of the calculation result of the initial ratio overlay algorithm by using the offset to adjust the pixel values of the pixels with color mutations in the overlay result image, so that the difference in pixel values of the overlay result image before and after adjustment is as small as possible to maintain the overall effect of the ratio overlay image. At the same time, it can make the image color transition in each area of the overlay result image more natural to weaken the problem of prominent color blocks in the image and improve the image quality and imaging effect of the overlay result image. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In combination with the accompanying drawings and referring to the following specific embodiments, the above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the elements and elements are not necessarily drawn to scale.
[0021] Figure 1 A schematic diagram of an image involved in the layer overlay process of a color dodge mode provided by an embodiment of the present disclosure;
[0022] Figure 2 Schematic diagram of an image involved in the process of layer superposition in a color burn mode provided by an embodiment of the present disclosure;
[0023] Figure 3 Flow schematic diagram of a layer superposition method provided by an embodiment of the present disclosure;
[0024] Figure 4 Schematic diagram of an image involved in the process of layer superposition in another color dodge mode provided by an embodiment of the present disclosure;
[0025] Figure 5 Curve comparison diagram of the layer superposition result in a color burn mode provided by an embodiment of the present disclosure;
[0026] Figure 6 Curve comparison diagram of the layer superposition result in a color dodge mode provided by an embodiment of the present disclosure;
[0027] Figure 7 Structural schematic diagram of a layer superposition device provided by an embodiment of the present disclosure;
[0028] Figure 8 Structural schematic diagram of a layer superposition device provided by an embodiment of the present disclosure. Detailed implementation manners
[0029] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0030] It should be understood that the steps recited in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0031] As used herein, the term "including" and its variations are open-ended, that is, "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0032] It should be noted that concepts such as "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.
[0033] It should be noted that the modifications of "one" and "multiple" mentioned in this disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly specified in the context, it should be understood as "one or more".
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of this disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] For the ratio superposition algorithm, such as the layer superposition algorithm in color burn mode, color dodge mode, linear dodge mode, etc., regardless of its specific algorithm formula, there is at least one pixel value of an image in the numerator part and at least one pixel value of an image in the denominator part. When calculating the pixel values, there is a situation where the calculation result of the numerator part and / or the denominator part is 0, resulting in a sudden change in the overall result of the layer superposition algorithm. For example, when the calculation result of the denominator part is 0, the overall result will suddenly change to a maximum value or a minimum value. In this way, there will be a sudden change in the color value in the superposition result image calculated by the ratio superposition algorithm, which appears as local color blocks in the image.
[0036] For example, for Figure 1 the portrait image as the base color shown in FIG. (a) and Figure 1 the solid color image as the blend color shown in FIG. (b) are subjected to ratio-based superposition processing in color dodge mode, and the unadjusted layer superposition result (i.e., the superposition result image) is as shown in Figure 1 FIG. (c). As can be seen from Figure 1 FIG. (c), there are unnatural aggregation color blocks in the region 110 where the base color image is close to 0 and the blend color image is close to 1.
[0037] Again, for Figure 2 the portrait image as the base color shown in FIG. (a) and Figure 2 the portrait image as the blend color shown in FIG. (b) are subjected to ratio-based superposition processing in color burn mode, and the unadjusted superposition result image is as shown in Figure 2 FIG. (c). As can be seen from Figure 2 FIG. (c), there are unnatural aggregation color blocks in the region 210 where the base color image is close to 1 and the blend color image is close to 0.
[0038] Based on the above situation, the embodiments of the present disclosure provide a layer overlay scheme, which adds a relatively small offset on the basis of the original ratio overlay algorithm to fine-tune the numerator part and / or denominator part of the initial ratio overlay algorithm, weaken the problem of image color blocks caused by the numerical mutation of the corresponding part, and improve the imaging effect of the overlay result image.
[0039] The layer overlay method provided by the embodiments of the present disclosure is applicable to the scenario of ratio overlay processing of two images. This method can be executed by a layer overlay device, which can be implemented in software and / or hardware, and can be integrated in an electronic device with certain image processing functions. The electronic device may include, but is not limited to, a smart phone, a personal digital assistant (PDA), a tablet personal computer (Tablet PC), a notebook computer, a desktop computer, a vehicle-mounted terminal, a digital television, etc.
[0040] Figure 3 FIG. shows a schematic flowchart of a layer overlay method provided by the embodiments of the present disclosure. As Figure 3 shown, the layer overlay method may include the following steps:
[0041] S310. Obtain a first layer image as a base color and a second layer image as a blending color.
[0042] Among them, the base color is the basic color in the image blending process, which can also be called the background color or the original manuscript color, and is used as the lower layer pixel color in the blending of two layers, etc. The blending color is the applied color in the image blending process and is used as the upper layer pixel color in the blending of two layers. The first layer image and the second layer image are respectively the lower layer image and the upper layer image in the two layers.
[0043] The electronic device can detect relevant instructions for image blending processing. For example, when the user triggers the blending processing function in the image processing application, the electronic device can generate the above instructions after detecting the trigger operation. Another example is that when the user triggers other image processing functions in the image processing application that include the image blending process, and the electronic device detects the trigger operation and executes the corresponding image processing function process, the above instructions generated in this process can also be obtained. After the electronic device detects the above instructions for image blending processing, it can obtain the first layer image as the lower layer base color and the second layer image as the upper layer blending color in the two layers. The first layer image and the second layer image can be independent and uncorrelated images, or can be images with a certain association.
[0044] In some embodiments, the first layer image and the second layer image can be two images applied in a certain image processing function. For example, the first layer image can be the input image in the image processing function, and the second layer image can be the intermediate output result or the final output result, etc. in the image processing function.
[0045] In other embodiments, the second layer image can be an image obtained by performing certain image processing on the first layer image. That is, S310 can be implemented as: obtaining the first layer image; performing image processing in a set manner on the first layer image to generate the second layer image. The set manner here can be set according to business requirements. For example, it can be an inversion processing manner, a blur processing manner, a color mapping processing manner, etc.
[0046] For example, continue to refer to Figure 2 , if the business requirement is to highlight the human contour through the layer superposition processing of the color burn model. Then, the electronic device can first obtain the human image with the contour to be highlighted as shown in figure (a) in Figure 2 as the first layer image. Then, perform inversion processing and blur processing on the human image with the contour to be highlighted in sequence to obtain the human image as shown in figure (b) in Figure 2 as the second layer image.
[0047] Another example, refer to Figure 4 , if the business requirement is to enrich the image color through the layer superposition processing of the color dodge model. Then, the electronic device can first obtain the original human image as shown in figure (a) in Figure 4 as the first layer image. Then, perform color mapping processing on the original human image with a certain color (such as red, green, blue, etc.) to obtain the human image as shown in figure (b) in Figure 4 as the second layer image.
[0048] S320. Determine the offset that meets the preset conditions.
[0049] Among them, the preset conditions are conditions determined in advance that the offset needs to meet. It can be a limiting condition for the value range of the offset, or a limiting condition for the calculation method of the offset, etc. The offset is a parameter for correcting the comparison superposition algorithm or its calculation result. It can be a certain fixed value, or a certain calculation formula / function, etc.
[0050] According to the foregoing description, the reason why the ratio superposition algorithm generates color blocks is that when the calculation result of the numerator part or the denominator part is 0, it will cause a mutation in the overall calculation result of the algorithm. Therefore, the embodiments of the present disclosure can set an offset for the corresponding positions (such as the numerator position and / or the denominator position) of the ratio superposition algorithm according to business requirements, so as to reduce the number of pixels whose calculation results at the corresponding positions become 0 during the superposition process, thereby weakening the color blocks in the superposition result image. Therefore, the electronic device can first determine the offset according to preset conditions, so that the offset can be used to adjust the ratio superposition algorithm subsequently.
[0051] In some embodiments, the offset can be set as a constant, then the preset condition can be a limiting condition for the value range of the offset, that is, the preset condition is a positive number less than or equal to a preset value. Here, the preset value is a very small value, for example, it can be 0.05. Thus, the value range corresponding to the preset condition can be (0, 0.05].
[0052] Based on these embodiments, S320 includes: determining a constant value that meets the preset condition as the offset. For example, a constant value can be arbitrarily set from the value range defined by the above preset condition as the offset. This can reduce the difficulty of setting the offset and to a certain extent reduce the calculation amount.
[0053] In some embodiments, the preset condition is a functional relationship based on the target layer image, and the value range of the functional relationship is a positive number less than or equal to a preset value.
[0054] Among them, the target layer image includes the first layer image and / or the second layer image.
[0055] In order to further improve the imaging effect of the superposition result image obtained by the ratio superposition algorithm and make the color transition in the image more natural on the basis of maintaining the image accuracy, in this embodiment, the pixel value of the target layer image can be used as the independent variable, the offset as the dependent variable, and the value range of the function being a positive number less than or equal to a preset value as the constraint condition to construct a functional relationship, so as to obtain an offset whose value changes adaptively with the pixel value of the target layer image and whose value is relatively small.
[0056] Considering that the ratio superposition algorithm is related to both the first layer image and the second layer image, when constructing the offset functional relationship, the first layer image, the second layer image, or a combination of the first layer image and the second layer image can be used as the independent variable. As for the specific form of the functional relationship, it is not limited, as long as it is ensured that the final value range of the offset is within (0, preset value].
[0057] In one example, for the offset presented in the form of a functional relationship, S320 can be specifically implemented as: constructing a functional relationship based on the target layer image and a preset constant coefficient as the offset.
[0058] Among them, the preset constant coefficient is a preset constant value, which can be used as the coefficient for calculating the offset using the pixel values of the target layer image. To ensure the value range of the offset, the preset constant coefficient can also be set as a relatively small positive number. Exemplarily, in an example where the preset value is 0.05, the value range of the preset constant coefficient is (0, 0.05].
[0059] To further ensure that the value of the offset meets the constraint of the value range described above, a preset constant coefficient can be set, and a functional relationship of the offset can be constructed based on the product form of the pixel values of the target layer image and the preset constant coefficient. In this way, the value of the final offset can be limited by the value of the preset constant coefficient.
[0060] In one example, for the offset presented in the form of a functional relationship, S320 can be specifically implemented as: determining an offset variable based on the target layer image and a preset power exponent; constructing a functional relationship using the product of the preset constant coefficient and the offset variable as the offset.
[0061] Among them, the preset power exponent is the exponent value of a preset power function, which can be set according to the adjustment amount of the superimposed result image of the comparison value type layer superposition process. For example, if the business requirement is a relatively large adjustment amount for the superimposed result image, the preset power exponent can be set as a relatively large value to make the change range of the offset with the pixel value slightly larger; conversely, if the business requirement is a relatively small adjustment amount for the superposition, the preset power exponent can be set as a relatively small value to make the change range of the offset with the pixel value slightly smaller.
[0062] The variable part (i.e., the offset variable) in the offset can be constructed in the form of a power function. In this way, the base of the power function can be constructed based on the pixel values of the target layer image, and the preset power exponent can be used as the exponent part of the power function to obtain the offset variable. For example, if the preset power exponent is set as a, the offset variable can be set as or (1.0 - color base ) a , where color base is used to represent the first layer image. Then, the offset is constructed using the product of the preset constant coefficient ∈ and the offset variable. For the above example, the functional relationship of the offset can be or ∈×(1.0 - color base ) a .
[0063] In some embodiments, if the second layer image is obtained by performing certain image processing on the first layer image, the target layer image can be set as the first layer image.
[0064] For example, Figure 2 in, the second layer image shown in Figure (b) is obtained by performing an inversion process and a blurring process on the first layer image shown in Figure (a); Figure 4 in, the second layer image shown in Figure (b) is obtained by performing a color mapping process on the first layer image shown in Figure (a). Thus, the change in the pixel values of the second layer image will depend on the change in the pixel values of the first layer. Then, the first layer image can be determined as the target layer image to be used as the independent variable in the offset function relationship. While ensuring that the offset can adaptively change, the function relationship of the offset is simplified, which can reduce the optimization difficulty of the contrast value type layer superposition process to a certain extent, reduce the computational complexity, and improve the processing speed of the image ratio superposition process.
[0065] S330. Perform a ratio superposition process on the first layer image and the second layer image according to the target ratio superposition algorithm to generate a superposition result image; the target ratio superposition algorithm is obtained by adding an offset to the target position in the initial ratio superposition algorithm.
[0066] Among them, the initial ratio superposition algorithm is an unadjusted ratio superposition algorithm. The target ratio superposition algorithm is a ratio superposition algorithm adjusted by an offset. The target position is the position in the ratio superposition algorithm, which can be the numerator position and / or the denominator position. The target position can be determined according to the service requirements of image adjustment. For example, if the service requirement is to filter out the parts with sudden color changes in the image, the target position can be the numerator position; if the service requirement is to retain the color change trend in the image but reduce the sudden color changes, the target position can be the denominator position, etc.
[0067] After the electronic device obtains the above offset, the offset can be added to the target position of the initial ratio superposition algorithm to obtain the target ratio superposition algorithm. Then, according to the target ratio superposition algorithm, a ratio calculation for each channel and each pixel of the first layer image and the second layer image is performed to obtain the superposition result image.
[0068] In some embodiments, when the service requirement of the ratio type layer superposition process is to retain the color change trend in the image, the purpose of setting the offset is to adjust the slope of the curve corresponding to the ratio superposition algorithm. Then, the target ratio superposition algorithm is pre-obtained in the following way: add the offset to the denominator position of the initial ratio superposition algorithm to adjust the slope of the initial ratio superposition algorithm and generate the target ratio superposition algorithm.
[0069] When the pixel value of the target layer image is at least in the numerator position of the initial ratio overlay algorithm, and the calculation result in the denominator position is close to 0, the slope of the overall calculated result color changing with the pixel value of the target layer image is very large, that is, a small change in the pixel value of the target layer image will cause a large change in the result color. Therefore, an offset can be added to the denominator position of the initial ratio overlay algorithm to reduce the slope of the result color changing with the pixel value of the target layer image, thereby weakening the change amplitude of the result color and achieving the reduction of the area with abrupt color changes in the overlay result image.
[0070] In some embodiments, when the service requirement of ratio-based layer overlay processing is to filter out the parts with drastic color changes in the image, the purpose of setting the offset is to translate the curve corresponding to the ratio overlay algorithm. Then, the target ratio overlay algorithm is obtained in advance in the following way: adding the offset to the numerator position of the initial ratio overlay algorithm to translate the curve of the initial ratio overlay algorithm and generate the target ratio overlay algorithm.
[0071] When the pixel value of the target layer image is at least in the numerator position of the initial ratio overlay algorithm, and the calculation result in the denominator position is close to 0, the slope of the overall calculated result color changing with the pixel value of the target layer image is very large, that is, a small change in the pixel value of the target layer image will cause a large change in the result color. In this case, if the method of adjusting the slope is adopted for optimization, there will be more pixels with the result color approaching 1, and the purpose of filtering out the parts with drastic color changes cannot be achieved. Therefore, an offset can be added to the numerator position of the initial ratio overlay algorithm to move the curve of the ratio overlay algorithm, so that the parts with drastic color changes in the result color fall outside the value range of the result color. In this way, there will no longer be pixel values with drastic color changes in the overlay result image, achieving the purpose of filtering out such pixel values.
[0072] In some embodiments, if the service requirement of ratio-based layer overlay processing is uncertain, or the service requirement is to filter out some parts with drastic color changes while maintaining the remaining color change trend, the purpose of setting the offset is to translate the curve corresponding to the ratio overlay algorithm and adjust the slope of the curve. Then, the target ratio overlay algorithm is obtained in advance in the following way: adding the offset to the numerator position and the denominator position of the initial ratio overlay algorithm to adjust the slope of the initial ratio overlay algorithm and translate the curve of the initial ratio overlay algorithm, and generate the target ratio overlay algorithm.
[0073] The layer overlay method provided by the embodiments of the present disclosure can obtain a first layer image as the base color and a second layer image as the blending color, and determine an offset that meets a preset condition; the value of the offset is a relatively small positive value, which can be added to the target position in the initial ratio overlay algorithm according to the business requirements of image processing to obtain a target ratio overlay algorithm with offset correction. Then, according to the target ratio overlay algorithm, the first layer image and the second layer image are subjected to ratio overlay processing pixel by pixel for each channel to generate an overlay result image; it realizes the use of the offset to slightly correct the calculation result of the initial ratio overlay algorithm to adjust the pixel values of the pixels with color mutations in the overlay result image, so that the pixel value difference between the overlay result images before and after adjustment is as small as possible to maintain the overall effect of the ratio overlay image. At the same time, it can make the image color transition in each area of the overlay result image more natural to weaken the problem of abrupt color blocks in the image and improve the image quality and imaging effect of the overlay result image.
[0074] In some embodiments, the initial ratio overlay algorithm includes a layer overlay algorithm in the color burn mode.
[0075] For the layer overlay algorithm in the color burn mode, the initial ratio overlay algorithm is as follows formula (1):
[0076]
[0077] where color o is the resulting color; color base is the pixel value of the first layer image, which serves as the base color for layer overlay; color blend is the pixel value of the second layer image, which serves as the blending color for layer overlay; the range of all colors is normalized to the range of 0 to 1, and clamp(x,a,b) is a normalization function that normalizes the x value to the value range of [a,b] (a < b), that is, when x > b, the clamp function returns b, and when x < a, the clamp function returns a. In the embodiments of the present disclosure, it is illustrated by taking the image color values being normalized to [0,1] as an example.
[0078] Through the analysis of formula (1), it can be seen that when the base color color basr is close to 1 and the blending color color blend is close to 0, the resulting color color o will have a mutation value close to the boundary of the value range, which is reflected in the image as the existence of abrupt color blocks. For example, using Figure 2 in figures (a) and (b), perform layer overlay processing in the color burn mode according to the initial ratio overlay algorithm shown in formula (1) to obtain Figure 2The superimposed result image shown in Figure (c). There is a region 210 with a drastic color change around the portrait in this superimposed result image, which has a certain impact on the generated human contour.
[0079] Since the second-layer image is obtained from the first-layer image, the first-layer image can be determined as the target layer image, which is in the numerator position of formula (1). According to the descriptions of the foregoing embodiments, when the business requirement is to filter out the parts with sudden color changes in the image, the optimization method for formula (1) is to add an offset in the numerator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent. In this way, for the example where the preset power exponent a is 10, the target ratio superimposition algorithm in the color deepening mode as shown in the following formula (2) can be obtained:
[0080]
[0081] When the business requirement is to retain the color change trend in the image, according to the descriptions of the foregoing embodiments, the optimization method for formula (1) is to add an offset in the denominator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent. In this way, for the example where the preset power exponent is 10, the target ratio superimposition algorithm in the color deepening mode as shown in the following formula (3) can be obtained:
[0082]
[0083] When the business requirement is not clear or includes the above two requirements, according to the descriptions of the foregoing embodiments, the optimization method for formula (1) is to add offsets in both the numerator position and the denominator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent. In this way, for the example where the preset power exponent is 10, the target ratio superimposition algorithm in the color deepening mode as shown in the following formula (4) can be obtained:
[0084]
[0085] For the above example of layer superimposition of the color deepening model, taking the blend color as a fixed value of 0.01 and the preset constant coefficient as 0.02, the result color distribution curves of the initial ratio superimposition algorithm, the ratio superimposition algorithm with an offset added in the numerator position, and the ratio superimposition algorithm with an offset added in the denominator position can be obtained, as Figure 5 shown. From Figure 5 it can be seen that for the curve corresponding to the initial ratio superimposition algorithm, the base color starts from 0.99, and the result color starts from 0 and increases with a relatively large slope, which will cause Figure 2The color mutation region 210 shown in Figure (c). For the curve corresponding to the ratio superposition algorithm with an offset added to the molecular position, since the curve is shifted, the resulting color value exceeds the range [0, 1], so normalization processing is performed to make them all colors with a value of 0, and then we can get Figure 2 the superposition result image shown in Figure (d), where there is no color mutation region around the human head portrait, and its image result is Figure 2 not much different from that in Figure (c), and both can well reflect the human contour. For the curve corresponding to the ratio superposition algorithm with an offset added to the denominator position, since the curve slope is adjusted, the color change value of the resulting color in the image can start from a smaller base color of 0.975, and the change range of the resulting color will be relatively gentle, which weakens the color mutation phenomenon to a certain extent.
[0086] In some embodiments, the initial ratio superposition algorithm includes a layer superposition algorithm in the color dodge mode.
[0087] For the layer superposition algorithm in the color dodge mode, the initial ratio superposition algorithm is the following formula (5):
[0088]
[0089] By analyzing formula (5), it can be seen that when the base color color base is close to 0 and the blend color color blend is close to 1, the resulting color color o will have a mutation value close to the boundary of the value range, which is reflected in the image as a color block with a sudden change. For example, using Figure 4 Figures (a) and (b), perform layer superposition processing in the color dodge mode according to the initial ratio superposition algorithm shown in formula (5) to obtain Figure 4 the superposition result image shown in Figure (c). There is a region 410 with a drastic color change in this superposition result image, which has a certain impact on the imaging effect.
[0090] Since the second layer image is obtained from the first layer image, the first layer image can be determined as the target layer image, which is in the molecular position of formula (5). According to the descriptions of the foregoing embodiments, when the business requirement is to retain the color change trend in the image, according to the descriptions of the foregoing embodiments, the optimization method for formula (5) is to add an offset in the denominator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent ∈×(1.0 - color base ) a . Thus, for an example where the preset power exponent a is 10, the target ratio superposition algorithm in the color dodge mode shown in the following formula (6) can be obtained:
[0091]
[0092] When the business requirement is to filter the parts with color mutations in the image, the optimization method for formula (5) is to add an offset at the numerator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent. Thus, for an example with a preset power exponent of 10, the target ratio overlay algorithm in the color dodge mode as shown in the following formula (7) can be obtained:
[0093]
[0094] When the business requirement is unclear or includes the above two requirements, according to the descriptions of the foregoing embodiments, the optimization method for formula (5) is to add offsets at both the numerator position and the denominator position. This offset can be a functional relationship determined according to the target layer image, a preset constant coefficient, and a preset power exponent. Thus, for an example with a preset power exponent of 10, the target ratio overlay algorithm in the color burn mode as shown in the following formula (8) can be obtained:
[0095]
[0096] For the layer overlay example of the above color dodge model, taking the blend color as a fixed value of 0.99 and the preset constant coefficient as 0.05, the result color distribution curves of the initial ratio overlay algorithm, the ratio overlay algorithm with an offset added at the numerator position, and the ratio overlay algorithm with an offset added at the denominator position can be obtained, as Figure 6 shown. From Figure 6 it can be seen that for the curve corresponding to the initial ratio overlay algorithm, when the base color changes from 0 to 0.01, the result color increases from 0 to 1 with a relatively large slope, which will cause Figure 4 the color mutation region 410 shown in Figure (c) of Figure 4 . For the curve corresponding to the ratio overlay algorithm with an offset added at the denominator position, since its curve slope is adjusted, when the base color increases from 0 to 0.025, the result color increases from 0 to 1 with a relatively gentle change amplitude, weakening the color mutation phenomenon to a certain extent. Thus, the overlay result image shown in Figure (d) of
[0097] The following are embodiments of the layer overlay device provided by the present disclosure. This device and the layer overlay methods of the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the layer overlay device, reference may be made to the embodiments of the above layer overlay methods.
[0098] Figure 7 FIG. shows a schematic structural diagram of a layer overlay device provided by an embodiment of the present disclosure. As Figure 7 shown, the layer overlay device 700 may include:
[0099] A layer image acquisition module 710, configured to acquire a first layer image as a base color and a second layer image as a mixed color;
[0100] An offset determination module 720, configured to determine an offset that meets a preset condition;
[0101] A layer overlay module 730, configured to perform ratio overlay processing on the first layer image and the second layer image according to a target ratio overlay algorithm to generate an overlay result image; wherein, the target ratio overlay algorithm is obtained by adding the offset to a target position in an initial ratio overlay algorithm.
[0102] The layer overlay device provided by the embodiments of the present disclosure can acquire a first layer image as a base color and a second layer image as a mixed color, and determine an offset that meets a preset condition; the value of the offset is a small positive value, which can be added to a target position in an initial ratio overlay algorithm according to the service requirements of image processing to obtain a target ratio overlay algorithm with offset correction. Then, according to the target ratio overlay algorithm, the first layer image and the second layer image are subjected to ratio overlay processing pixel by pixel for each channel to generate an overlay result image; it realizes micro-correction of the calculation result of the initial ratio overlay algorithm by using the offset to adjust the pixel values of the pixels with color mutations in the overlay result image, so that the pixel value difference between the overlay result images before and after adjustment is as small as possible to maintain the overall effect of the ratio overlay image. At the same time, the image color transition in each area of the overlay result image can be made more natural to weaken the problem of abrupt color blocks in the image and improve the image quality and imaging effect of the overlay result image.
[0103] In some embodiments, the layer overlay device 700 further includes a target ratio overlay algorithm generation module, configured to pre-obtain the target ratio overlay algorithm in the following manner:
[0104] Adding the offset to the denominator position of the initial ratio overlay algorithm to adjust the slope of the initial ratio overlay algorithm and generate the target ratio overlay algorithm.
[0105] In some other embodiments, the target ratio superposition algorithm generation module is configured to pre-obtain the target ratio superposition algorithm in the following manner:
[0106] Add an offset to the numerator position of the initial ratio superposition algorithm to translate the curve of the initial ratio superposition algorithm and generate the target ratio superposition algorithm.
[0107] In still some other embodiments, the target ratio superposition algorithm generation module is configured to pre-obtain the target ratio superposition algorithm in the following manner:
[0108] Add an offset to the numerator position and the denominator position of the initial ratio superposition algorithm to adjust the slope of the initial ratio superposition algorithm and translate the curve of the initial ratio superposition algorithm, and generate the target ratio superposition algorithm.
[0109] In some embodiments, the initial ratio superposition algorithm includes a layer superposition algorithm in the color burn mode or a layer superposition algorithm in the color dodge mode.
[0110] In some embodiments, the preset condition is based on a functional relationship of the target layer image, and the value range of the functional relationship is a positive number less than or equal to a preset value; wherein, the target layer image includes a first layer image and / or a second layer image.
[0111] Further, the offset determination module 720 is specifically configured to:
[0112] Construct a functional relationship based on the target layer image and a preset constant coefficient as the offset.
[0113] Optionally, the offset determination module 720 is specifically configured to:
[0114] Determine an offset variable based on the target layer image and a preset power exponent;
[0115] Construct a functional relationship using the product of the preset constant coefficient and the offset variable as the offset.
[0116] Wherein, the value range of the preset constant coefficient is (0, 0.05].
[0117] In some embodiments, the preset condition is a positive number less than or equal to a preset value;
[0118] Correspondingly, the offset determination module 720 is specifically configured to:
[0119] Determine a constant value that meets the preset condition as the offset.
[0120] In some embodiments, the layer image acquisition module 710 is specifically configured to:
[0121] Acquire the first layer image;
[0122] Perform image processing on the first layer image in a set manner to generate a second layer image.
[0123] Furthermore, the target layer image is the first layer image.
[0124] The layer overlay device provided by the embodiments of the present disclosure can execute the layer overlay method provided by any embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution of the method.
[0125] It should be noted that in the embodiments of the above layer overlay device, the various modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional modules are only for the convenience of mutual distinction and do not limit the protection scope of the present disclosure.
[0126] The embodiments of the present disclosure also provide a layer overlay device, which may include a processor and a memory, and the memory may be used to store executable instructions. Among them, the processor may be used to read the executable instructions from the memory and execute the executable instructions to implement the layer overlay method in the above embodiments.
[0127] Figure 8 Fig. shows a schematic structural diagram of a layer overlay device provided by an embodiment of the present disclosure.
[0128] As Figure 8 shown, the layer overlay device 800 may include a processing device 801 (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the layer overlay device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output interface (I / O interface) 805 is also connected to the bus 804.
[0129] Generally, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the layer overlay device 800 to communicate with other devices wirelessly or wiredly to exchange data.
[0130] It should be noted that Figure 8The illustrated layer overlay device 800 is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure. That is, although Figure 8 the layer overlay device 800 with various devices is illustrated, it should be understood that it is not required to implement or include all the illustrated devices. Instead, more or fewer devices may be implemented or included.
[0131] Specifically, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above-mentioned functions defined in the layer overlay method of any embodiment of the present disclosure are performed.
[0132] The embodiments of the present disclosure also provide a computer-readable storage medium that stores a computer program, and when the computer program is executed by a processor, the processor is caused to implement the layer overlay method in any embodiment of the present disclosure.
[0133] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0134] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP, and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of the communication network include a local area network (“LAN”), a wide area network (“WAN”), the Internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future-developed network.
[0135] The above-mentioned computer-readable medium can be included in the above-mentioned layer stacking device; or it can exist separately without being assembled into the layer stacking device.
[0136] The above-mentioned computer-readable medium carries one or more programs, and when the one or more programs are executed by the layer stacking device, the layer stacking device is caused to perform the steps of the layer stacking method described in any embodiment of the present disclosure.
[0137] In the embodiments of the present disclosure, computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The above-mentioned programming languages include, but are not limited to, object-oriented programming languages - such as Java, Smalltalk, C++, and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or, alternatively, may be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0138] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of devices, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0139] The functions described above in this document may be performed at least in part by one or more hardware logic components. For example, by way of non-limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and so on.
[0140] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0141] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0142] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although a number of specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment can also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0143] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for layer superposition, characterized in that, Comprising: Obtaining a first layer image as a base color and a second layer image as a blend color; Determining an offset that meets a preset condition; Performing ratio overlay processing on the first layer image and the second layer image according to a target ratio overlay algorithm to generate an overlay result image; wherein, the target ratio overlay algorithm is obtained by adding the offset to a target position in an initial ratio overlay algorithm.
2. The method according to claim 1, wherein The target ratio overlay algorithm is pre-obtained in the following manner: Adding the offset to the denominator position of the initial ratio overlay algorithm to adjust the slope of the initial ratio overlay algorithm and generate the target ratio overlay algorithm.
3. The method according to claim 1, characterized in that, The target ratio overlay algorithm is pre-obtained in the following manner: Adding the offset to the numerator position of the initial ratio overlay algorithm to translate the curve of the initial ratio overlay algorithm and generate the target ratio overlay algorithm.
4. The method according to claim 1, characterized in that, The target ratio overlay algorithm is pre-obtained in the following manner: Adding the offset to the numerator position and the denominator position of the initial ratio overlay algorithm to adjust the slope of the initial ratio overlay algorithm and translate the curve of the initial ratio overlay algorithm, and generate the target ratio overlay algorithm.
5. The method according to any one of claims 2-4, characterized in that, The initial ratio overlay algorithm includes a layer overlay algorithm in color burn mode or a layer overlay algorithm in color dodge mode.
6. The method according to claim 1, wherein The preset condition is based on a functional relationship of a target layer image, and the value range of the functional relationship is a positive number less than or equal to a preset value; wherein, the target layer image includes the first layer image and / or the second layer image.
7. The method according to claim 6, characterized in that, The determining of the offset that meets the preset condition includes: Constructing the functional relationship based on the target layer image and a preset constant coefficient as the offset.
8. The method according to claim 6, characterized in that, The determining of the offset that meets the preset condition includes: Determining an offset variable based on the target layer image and a preset power exponent; Constructing the functional relationship using the product of the preset constant coefficient and the offset variable as the offset.
9. The method according to claim 1, wherein The preset condition is a positive number less than or equal to a preset value; The determining of the offset that meets the preset condition includes: Determining the constant value that meets the preset condition as the offset.
10. The method according to any one of claims 6-8, characterized in that, The obtaining of the first layer image as a base color and the second layer image as a blend color includes: Obtaining the first layer image; Performing image processing in a set manner on the first layer image to generate the second layer image.
11. The method according to claim 10, wherein The target layer image is the first layer image.
12. A layer overlay device, characterized in that, Comprising: A layer image obtaining module for obtaining a first layer image as a base color and a second layer image as a blend color; An offset determining module for determining an offset that meets a preset condition; A layer overlay module for performing ratio overlay processing on the first layer image and the second layer image according to a target ratio overlay algorithm to generate an overlay result image; wherein, the target ratio overlay algorithm is obtained by adding the offset to a target position in an initial ratio overlay algorithm.
13. A layer overlay device, characterized in that, Comprising: A processor; A memory for storing executable instructions; Among them, the processor is used to read the executable instructions from the memory and execute the executable instructions to implement the layer overlay method described in any one of claims 1-11 above.
14. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, causes the processor to implement the layer overlay method described in any one of claims 1-11 above.