CN115082323A - Image processing method, image processing device, electronic equipment and storage medium - Google Patents

Image processing method, image processing device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115082323A
CN115082323A CN202211000999.0A CN202211000999A CN115082323A CN 115082323 A CN115082323 A CN 115082323A CN 202211000999 A CN202211000999 A CN 202211000999A CN 115082323 A CN115082323 A CN 115082323A
Authority
CN
China
Prior art keywords
target
interpolation
pixel
pixel point
new
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211000999.0A
Other languages
Chinese (zh)
Other versions
CN115082323B (en
Inventor
陈冠亨
张坚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenliu Micro Intelligent Technology Shenzhen Co ltd
Original Assignee
Shenliu Micro Intelligent Technology Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenliu Micro Intelligent Technology Shenzhen Co ltd filed Critical Shenliu Micro Intelligent Technology Shenzhen Co ltd
Priority to CN202211000999.0A priority Critical patent/CN115082323B/en
Publication of CN115082323A publication Critical patent/CN115082323A/en
Application granted granted Critical
Publication of CN115082323B publication Critical patent/CN115082323B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4023Decimation- or insertion-based scaling, e.g. pixel or line decimation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4007Interpolation-based scaling, e.g. bilinear interpolation

Abstract

The application relates to the technical field of image processing, and discloses an image processing method, an image processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: calculating a target distance between two pixel points in a target pixel point pair in a target image; performing exponential operation according to the target distance and the first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; determining an interpolation distance in an interpolation direction corresponding to the target pixel point pair according to a first interpolation coefficient and a target distance corresponding to the target pixel point pair; inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of the new pixel points; and determining an interpolation image corresponding to the target image based on the pixel coordinates of each new pixel point. The scheme can dynamically change the number of new pixel points inserted between the two pixel points along with the distance between the two pixel points, and improves the flexibility of pixel insertion.

Description

Image processing method, image processing device, electronic equipment and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, an electronic device, and a storage medium.
Background
In the current scene of pixel interpolation, the specified number of new pixel points to be inserted between pixel point pairs is generally preset, and then the new pixel points are inserted at equal intervals between two pixel points in the pixel point pairs correspondingly according to the specified number. However, generally, the distances between two pixels in different pixel pairs may be different, so that for a corresponding pixel pair with a shorter distance, new pixels are inserted equidistantly according to a specified number, and the pixels are denser after the new pixels are inserted; and for the corresponding pixel point pairs with larger distances, the pixel points are sparse after new pixel points are inserted. For example, in fig. 1, the pixels inserted between the closer pixel a1 and the closer pixel B1 are denser, and the pixels inserted between the farther pixel A3 and the farther pixel B3 are sparser.
In summary, the pixel interpolation method has the problem of low flexibility, and the interpolation image obtained by pixel interpolation has poor effect.
Disclosure of Invention
In view of the foregoing problems, embodiments of the present application provide an image processing method, an image processing apparatus, an electronic device, and a storage medium, so as to solve the problem of low flexibility of pixel interpolation in the related art.
According to an aspect of an embodiment of the present application, there is provided an image processing method including: calculating a target distance between two pixel points in a target pixel point pair in a target image; performing exponential operation according to the target distance and a first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; the first specified parameter is used as a base number, and the target distance is used for determining an index of the first specified parameter; the first specified parameter e (0, 1); determining an interpolation distance in an interpolation direction corresponding to the target pixel point pair according to a first interpolation coefficient corresponding to the target pixel point pair and the target distance; inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of the new pixel points; and determining an interpolation image corresponding to the target image based on the pixel coordinates of the new pixel points.
In some embodiments of the present application, based on the foregoing scheme, the determining, based on the pixel coordinate of each new pixel point, an interpolated image corresponding to the target image includes: determining the color component difference value of two pixel points in the target pixel point pair on each color component; performing exponential operation according to the color component difference and a second specified parameter to obtain a second interpolation coefficient corresponding to the target pixel point pair, wherein the second specified parameter is used as a base number, the color component difference is used for determining an exponent of the second specified parameter, and the second specified parameter belongs to (0, 1); determining a color component change value in the interpolation direction corresponding to the target pixel point pair according to the second interpolation coefficient and the color component difference value; determining the color component value of each new pixel point on the color component according to the color component change value; wherein, the color component values of the plurality of new pixel points along the interpolation direction are in equal difference change; and generating an interpolation image corresponding to the target image according to the color component value of each new pixel point on each color component and the pixel coordinate of each new pixel point.
In some embodiments of the present application, based on the foregoing solution, after determining, based on the pixel coordinate of the new pixel point, an interpolated image corresponding to the target image, the method further includes: determining an initial texture image corresponding to the interpolation image; calculating the texture pixel distance between two texture pixel points in the target texture pixel point pair for the target texture pixel point pair in which a new texture pixel point needs to be inserted in the initial texture image; performing exponential operation according to the texel distance and a third designated parameter to obtain a third interpolation coefficient corresponding to the target texel point pair; wherein the third specified parameter is used as a base number, and the texel distance is used for determining an index of the third specified parameter; the third specified parameter e (0, 1); determining a texture interpolation distance in the interpolation direction corresponding to the target texture pixel point pair according to the third interpolation coefficient and the texture pixel distance; inserting new texture pixel points between the target texture pixel point pairs at equal intervals according to the texture interpolation interval to obtain texture pixel coordinates of the new texture pixel points; and determining a target texture image corresponding to the interpolation image based on the texture pixel coordinates of the new texture pixel points.
In some embodiments of the application, based on the foregoing solution, before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further includes: calculating the square of the target distance to obtain a first target parameter; taking the product of the first target parameter and a first coefficient as the exponent of the first specified parameter, wherein the first coefficient is e (0, 1).
In other embodiments of the present application, based on the foregoing solution, before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further includes: taking the product of the target distance and a first coefficient as an index of the first specified parameter; wherein the first coefficient ∈ (0, 1 ].
In some embodiments of the present application, based on the foregoing scheme, the inserting a new pixel point between the target pixel point pairs at equal intervals according to the interpolation interval to obtain a pixel coordinate of the new pixel point includes: acquiring a target interpolation coefficient corresponding to the (t-1) th new pixel point, wherein the target interpolation coefficient corresponding to the (t-1) th new pixel point is equal to the product of the (t-1) and the first interpolation coefficient corresponding to the target pixel point pair; t is a positive integer greater than or equal to 2; if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is not less than 1, stopping inserting the new pixel point; if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is smaller than 1, taking the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient as the target interpolation coefficient corresponding to the t-th new pixel point; based on the interpolation interval, determining the pixel coordinate increment of the t-th new pixel point relative to the pixel point which is taken as the starting point in the target pixel point pair; and determining the pixel coordinate of the t-th new pixel point according to the pixel coordinate increment of the t-th new pixel point relative to the pixel point which serves as the starting point in the target pixel point pair and the pixel coordinate of the pixel point which serves as the starting point in the target pixel point pair.
In some embodiments of the application, based on the foregoing solution, before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further includes: acquiring interpolation scene indication information; if the interpolation application scene indicated by the interpolation scene indication information is a pixel interpolation scene, acquiring a specified parameter associated with the pixel interpolation scene based on a mapping relation between the interpolation scene and the specified parameter, and taking the specified parameter associated with the pixel interpolation scene as the first specified parameter.
In some embodiments of the application, based on the foregoing scheme, before the taking the product of the first target parameter and the first coefficient as the exponent of the first specified parameter, the method further includes: acquiring interpolation scene indication information; if the interpolation application scene indicated by the interpolation scene indication information is a pixel interpolation scene, acquiring a coefficient associated with the pixel interpolation scene based on a mapping relation between the interpolation scene and the coefficient, and taking the coefficient associated with the pixel interpolation scene as the first coefficient.
According to an aspect of an embodiment of the present application, there is provided an image processing apparatus including: the target distance calculation module is used for calculating the target distance between two pixel points in a target pixel point pair in the target image; the first interpolation coefficient determining module is used for performing exponential operation according to the target distance and a first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; the first specified parameter is used as a base number, and the target distance is used for determining an index of the first specified parameter; the first specified parameter is epsilon (0, 1); an interpolation interval determining module, configured to determine, according to a first interpolation coefficient and the target distance that correspond to the target pixel point pair, an interpolation interval in an interpolation direction that corresponds to the target pixel point pair; the pixel inserting module is used for inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of the new pixel points; and the interpolation image determining module is used for determining an interpolation image corresponding to the target image based on the pixel coordinates of the new pixel points.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: a processor; a memory having computer readable instructions stored thereon which, when executed by the processor, implement the image processing method as described above.
According to an aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored thereon computer-readable instructions which, when executed by a processor, implement the image processing method as above.
According to an aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions which, when executed by a processor, implement the image processing method as above.
In the scheme of the application, based on the target distance between two pixels in the target pixel pair and the interpolation distance determined aiming at the target pixel, the number of targets in the target pixel pair, in which new pixels can be inserted, can be determined, the number of targets in the target pixel pair, in which new pixels can be inserted, between two pixels in the target pixel pair is equal to the integer part of the result obtained by dividing the target distance by the interpolation distance, the number of targets is approximately equal to a first interpolation coefficient, and the first interpolation coefficient and the target distance have a negative correlation relationship, so that the larger the corresponding target distance is, the more new pixels can be inserted between the two pixels are; the number of the new pixel points inserted between the target pixel point pairs with different target distances can be ensured to be different, the dynamic change of the number of the new pixel points inserted between the two pixel points in the target pixel point pairs along with the change of the target distances is realized, and the flexibility of pixel interpolation is improved.
In addition, in the application, the interpolation distance also changes dynamically along with the target distance between two pixels in the target pixel pair. Compared with the scheme that new pixel points are inserted among different target pixel point pairs at equal intervals according to the specified quantity in the prior art, the scheme further improves the flexibility of pixel interpolation; moreover, the scheme of the application can ensure that more interpolation is carried out between two pixel points with larger target distance, and less interpolation is carried out between two pixel points with smaller target distance, so that the reasonability of the inserted new pixel point is ensured, and the pixel interpolation effect of the obtained interpolation image is ensured.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a schematic diagram of pixel interpolation in the prior art.
FIG. 2 is a flow diagram illustrating an image processing method according to one embodiment of the present application.
Fig. 3 is a flow chart of step 240 in some embodiments of the corresponding embodiment of fig. 2.
FIG. 4 is a flowchart illustrating step 240 according to an embodiment of the present application.
Fig. 5 is a flow chart of step 250 in some embodiments in a corresponding embodiment of fig. 2.
FIG. 6 is a flowchart illustrating steps subsequent to step 250 according to one embodiment of the present application.
Fig. 7 is a block diagram of an image processing apparatus according to an embodiment of the present application.
Fig. 8 shows a schematic structural diagram of an electronic device suitable for implementing an embodiment of the present application.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the subject matter of the present application can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the application.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It should be noted that: reference herein to "a plurality" means two or more. "and/or" describe the association relationship of the associated objects, meaning that there may be three relationships, e.g., A and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The implementation details of the technical solution of the embodiment of the present application are set forth in detail below:
fig. 2 is a flowchart illustrating an image processing method according to an embodiment of the present application, which may be performed by an electronic device with processing capability, such as a server, a cloud server, or a desktop computer with processing capability. Referring to fig. 2, the method includes at least steps 210 to 250, which are described in detail as follows:
step 210, calculating a target distance between two pixels in a target pixel pair in the target image.
The target image refers to an image to be subjected to pixel interpolation. The target image may be a two-dimensional image or a primitive obtained by dividing a primitive on the surface of the three-dimensional model.
The target pixel point pair is a pixel point pair formed by two pixel points which are used as end points and in which a new pixel point needs to be inserted in the target image. It is to be understood that the number of target pixel point pairs in the target image is not limited, and may be one or more, and is not particularly limited herein. For each target pixel point pair in the target image, the pixel coordinates of a new pixel point to be inserted between the target pixel point pairs can be determined according to the method of the application.
The target distance is the distance between two pixel points calculated according to the pixel coordinates of the two pixel points in the target pixel point pair.
Specifically, in step 210, for each target pixel point pair in the target image, the distance between two pixel points in the target pixel point pair is calculated according to the pixel coordinates of the two pixel points in the target image.
Step 220, performing exponential operation according to the target distance and the first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; the target distance is used for determining an index of the first designated parameter; the first specified parameter ∈ (0, 1).
Specifically, the exponent of the first specified parameter may be a positive number, and thus, in the case of the first exponent parameter ∈ (0, 1), a first interpolation coefficient ∈ (0, 1) obtained by performing an exponential operation based on the target distance and the first specified parameter.
In some embodiments, the index of the first specified parameter may be determined as follows: calculating the square of the target distance to obtain a first target parameter; the product of the first target parameter and the first coefficient is taken as the exponent of the first specified parameter, where the first coefficient ∈ (0, 1).
Assuming that two pixels in the target pixel pair are respectively a pixel a and a pixel B, g (a) represents the pixel coordinate of the pixel a, and g (B) represents the pixel coordinate of the pixel B, the first target parameter S1 may be determined according to the following formula:
Figure 917706DEST_PATH_IMAGE001
(ii) a (formula 1)
Wherein the content of the first and second substances,
Figure 818534DEST_PATH_IMAGE002
and representing the target distance between the pixel point A and the pixel point B.
Further, if used
Figure 67113DEST_PATH_IMAGE003
Expressing the first coefficient, the exponent of the first specified parameter can be determined according to equation 2 below
Figure 931164DEST_PATH_IMAGE004
1:
Figure 681556DEST_PATH_IMAGE005
S1; (formula 2)
In this embodiment, if t1 represents the first specified parameter, the above formula 1 and formula 2 are combined, which is equivalent to calculating the first interpolation coefficient according to the following formula 3
Figure 972860DEST_PATH_IMAGE006
Figure 974314DEST_PATH_IMAGE007
(ii) a (formula 3)
In a particular embodiment, the first coefficient
Figure 642056DEST_PATH_IMAGE008
And the first specified parameter t1 may be preset. It can be understood that due to the secondCoefficient of one
Figure 232306DEST_PATH_IMAGE009
∈(0,1]When the first coefficient
Figure 960091DEST_PATH_IMAGE010
In the case of =1, the above equation 3 can be expressed as:
Figure 183262DEST_PATH_IMAGE011
(ii) a (formula 4)
In other embodiments, the product of the target distance and the first coefficient may be used as an index of the first specified parameter; wherein the first coefficient is ∈ (0, 1)]. In this case, it is equivalent to calculating the first interpolation coefficient according to the following equation 5
Figure 638383DEST_PATH_IMAGE012
Figure 833872DEST_PATH_IMAGE013
(ii) a (formula 5)
As can be seen from the above equations 3 to 5, in the case of the first specified parameter t1 ∈ (0, 1), since the exponent of the first specified parameter is a positive number, the calculated first interpolation coefficient
Figure 732558DEST_PATH_IMAGE014
E (0, 1). Moreover, under the condition that the target distance between the pixel point a and the pixel point B is larger, the first interpolation coefficient determined for the pixel point a and the pixel point B is smaller. The first interpolation coefficients determined for the respective target pixel point pairs are all within the range of (0, 1) even if the corresponding target distances are different for the different target pixel point pairs.
Step 230, determining an interpolation distance in the interpolation direction corresponding to the target pixel point pair according to the first interpolation coefficient and the target distance corresponding to the target pixel point pair.
The interpolation direction corresponding to the target pixel point pair refers to a direction in which one pixel point in the target pixel point pair is used as a starting point, the other pixel point is used as an end point, and the pixel point used as the starting point points to the pixel point used as the end point. The interpolation interval refers to the interval between adjacent pixel points.
Specifically, the product of the first interpolation coefficient and the target distance may be used as the interpolation distance of the target pixel point pair in the corresponding interpolation direction
Figure 957871DEST_PATH_IMAGE015
. Namely:
Figure 701837DEST_PATH_IMAGE016
(ii) a (equation 6)
And 240, inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain the pixel coordinates of each new pixel point.
Specifically, one pixel point in the target pixel point pair may be used as a starting point, then a newly inserted pixel point (i.e., a pixel coordinate of a new pixel point) is calculated according to the interpolation interval, then, equidistant interpolation is correspondingly continued according to the interpolation interval, a pixel coordinate of a next new pixel point is calculated, and the interpolation is ended until it is determined that the distance from the new pixel point to be inserted to the previous new pixel point is greater than or equal to the interpolation interval.
In some embodiments, the target number of new pixels insertable between two pixels in the target pixel pair may be determined according to the target distance between the two pixels in the target pixel pair and the interpolation distance, where the target number of new pixels insertable is equal to an integer part of a result obtained by dividing the target distance by the interpolation distance. And then correspondingly calculating the pixel coordinate of each new pixel point according to the interpolation distance and the pixel coordinate of at least one pixel point in the target pixel point pair until the number of the inserted new pixel points is determined to reach the target number.
And step 250, determining an interpolation image corresponding to the target image based on the pixel coordinates of each new pixel point.
The interpolation image corresponding to the target image is an image obtained after a new pixel point is inserted into the target image, and it can be understood that the number of pixel points included in the interpolation image corresponding to the target image is greater than the number of pixel points included in the target image.
In a specific embodiment, after determining the position of the new pixel point in the interpolated image based on the pixel coordinate of the new pixel point, it is further necessary to determine the color component value of each new pixel point under each color component, so that the color of the new pixel point can be determined based on the color component values of the new pixel point under all the color components.
In some embodiments, the color component values of the new pixel points under the color components may be determined by combining the color component values of the pixel points around the new pixel point under the color components. For example, for a new pixel point of a color component value to be determined, N known pixel points of known color component values (N is a positive integer greater than or equal to 2, for example, N is 2, 4, 6, 8, etc.) near the pixel point are determined; then, the color component values of the N known pixel points on a color component may be averaged, and the average color component value obtained by the calculation may be used as the color component value of the new pixel point under the color component. The color component values of the new pixel point under other color components can be calculated in a similar manner, and are not specifically limited herein.
In the scheme of the application, based on the target distance between two pixels in the target pixel pair and the interpolation distance determined for the target pixel, the number of targets into which new pixels can be inserted in the target pixel pair can be determined, as described above, the number of targets into which new pixels can be inserted between two pixels in the target pixel pair is equal to the integer part of the result obtained by dividing the target distance by the interpolation distance, the number of targets is approximately equal to the reciprocal of the first interpolation coefficient, and the first interpolation coefficient and the target distance are in a negative correlation relationship, so that the larger the corresponding target distance is, the larger the number of target pixel pairs between the two pixels can be inserted; on the contrary, the smaller the corresponding target distance is, the smaller the number of new pixel points inserted between the target pixel point pairs is; the number of the new pixel points inserted between the target pixel point pairs with different target distances can be guaranteed to be different, the number of the new pixel points inserted between the two pixel points in the target pixel point pairs is dynamically changed along with the change of the target distances, therefore, the pixel interpolation is flexibly carried out according to the target distances between the two pixel points in the target pixel point pairs, and the flexibility of the pixel interpolation is improved.
In addition, in the scheme of the application, the interpolation distance also changes along with the target distance between two pixels in the target pixel pair. Compared with the scheme that new pixel points are uniformly inserted among different target pixel point pairs according to the specified quantity in the prior art, the scheme of the application improves the flexibility of pixel insertion; moreover, the scheme of the application can ensure that more interpolation is carried out between two pixel points with larger target distance, and less interpolation is carried out between two pixel points with smaller target distance, so that the pixel interpolation rationality is ensured, and the pixel interpolation effect is ensured.
In addition, the scheme of the application can realize the target pixel point pair with larger target distance, wherein the number of the insertable new pixel points between the two pixel points is larger; on the contrary, the number of new pixel points inserted between target pixel point pairs with smaller corresponding target distances is smaller, so that the scheme can solve the problem that the newly inserted pixel points are too dense or too sparse due to different distances because the new pixel points are inserted between different pixel point pairs according to the specified number in the prior art to a certain extent.
In some embodiments of the present application, as shown in fig. 3, step 240, comprises:
step 310, obtaining a target interpolation coefficient corresponding to the (t-1) th new pixel point, wherein the target interpolation coefficient corresponding to the (t-1) th new pixel point is equal to the product of the (t-1) th new pixel point and a first interpolation coefficient corresponding to the target pixel point; t is a positive integer of 2 or more.
In this embodiment, in the process of pixel insertion for a target pixel point pair, one pixel point in the target pixel point pair is used as a starting point, and the other pixel point is used as an end point, and then interpolation is sequentially performed along the interpolation direction corresponding to the target pixel point pair, which can also be understood as sequentially performing interpolation from the near direction to the far direction according to the pixel points with the distance as the starting point. Correspondingly, the distances of the pixels taking the determined new pixel distance as a starting point are sorted from small to large, and the new pixel positioned at the (t-1) th position in the sorting is the (t-1) th new pixel.
Assume that the target interpolation coefficient corresponding to the (t-1) th new pixel point is
Figure 17411DEST_PATH_IMAGE017
Then it can be calculated according to the following formula
Figure 73617DEST_PATH_IMAGE017
Figure 536959DEST_PATH_IMAGE018
(ii) a (equation 7)
Step 320, judging whether the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is less than 1; if not less than 1, stopping inserting the new pixel point; if less than 1, go to step 330.
Step 330, taking the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient as the target interpolation coefficient corresponding to the t-th new pixel point; and determining the pixel coordinate increment of the t-th new pixel point relative to the pixel point which is taken as the starting point in the target pixel point pair based on the interpolation distance.
The pixel coordinate increment of the tth new pixel point relative to the pixel point of the target pixel point pair serving as the starting point is used for indicating the pixel coordinate increment of the tth new pixel point relative to the pixel point of the target pixel point pair serving as the starting point.
In the application, because the equidistant pixel insertion is performed according to the interpolation interval corresponding to the target pixel point pair, and the pixel insertion is performed along the interpolation direction from the pixel point serving as the starting point in the target pixel point pair to the pixel point serving as the end point, for the tth new pixel point, the pixel coordinate increment of the tth new pixel point relative to the pixel point serving as the starting point in the target pixel point pair is equal to the product of t and the interpolation interval corresponding to the target pixel point pair. In a specific embodiment, the pixel point of the target pixel point pair serving as the starting point may be set according to actual needs, and no specific limitation is made herein.
Suppose that the pixel coordinate increment of the t-th new pixel point relative to the pixel point which is taken as the starting point in the target pixel point pair is
Figure 84615DEST_PATH_IMAGE019
Then, it can be calculated according to the following formula
Figure 503964DEST_PATH_IMAGE020
Figure 744452DEST_PATH_IMAGE021
=
Figure 429512DEST_PATH_IMAGE022
(ii) a (formula 8)
Substituting equation 6 into equation 8 above, one can obtain:
Figure 233388DEST_PATH_IMAGE023
=
Figure 54714DEST_PATH_IMAGE024
(ii) a (formula 9)
Step 340, determining the pixel coordinate of the t-th new pixel point according to the pixel coordinate increment of the t-th new pixel point relative to the pixel point of the target pixel point pair as the starting point and the pixel coordinate of the pixel point of the target pixel point pair as the starting point.
Suppose that the pixel coordinates of the pixel point as the starting point in the target pixel point pair are
Figure 466104DEST_PATH_IMAGE025
And then the pixel coordinate of the t-th new pixel point
Figure 638459DEST_PATH_IMAGE026
Comprises the following steps:
Figure 777185DEST_PATH_IMAGE027
=
Figure 921859DEST_PATH_IMAGE028
+
Figure 504150DEST_PATH_IMAGE029
=
Figure 415999DEST_PATH_IMAGE030
+
Figure 109148DEST_PATH_IMAGE024
(ii) a (formula 10)
Step 350, adding 1 to t accumulation; and then the step 310 is executed again until the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is greater than or equal to 1.
Since pixel insertion is performed between two pixels in the target pixel pair, it is inevitable that the pixel distance of the inserted new pixel from the pixel that is the starting point in the target pixel pair is smaller than the distance between two pixels in the target pixel pair (i.e., the target distance). As can be seen from the above formula 9, if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is greater than or equal to 1, that is to say
Figure 842749DEST_PATH_IMAGE031
Not less than 1, calculated according to the formula 9
Figure 845209DEST_PATH_IMAGE020
Figure 992156DEST_PATH_IMAGE032
At this time, apparently contradict the conclusion that the distance between any new pixel point and the pixel point as the starting point is smaller than the target distance, thereby showing thatAnd (t-1) new pixel points can only be inserted between two pixel points in the target pixel point pair, and the t-th new pixel point cannot be inserted. And under the condition that the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is not less than 1, stopping pixel point insertion between two pixel points in the target pixel point pair, thereby saving computing resources.
In the prior art, one way is to insert pixels between two pixels according to a set interpolation distance and a specified number. Therefore, no matter the target distance between two pixels in the target pixel pair, a specified number of new pixels are inserted between the two pixels. If the designated number is 7, in the process of pixel insertion according to the set interpolation interval, the target distance between two pixel points may not satisfy the condition of inserting 7 new pixel points according to the set interpolation interval, but only 4 new pixel points are inserted. However, in this case, in the interpolation process, it is still necessary to calculate 7 times according to the interpolation pitch, resulting in invalid calculation of pixel coordinates and wasting calculation resources.
In the embodiment corresponding to fig. 3 of the present application, before the pixel coordinate of the next new pixel point is calculated, the calculation of the pixel coordinate of the next new pixel point is started only when the sum of the target interpolation coefficient corresponding to the currently inserted new pixel point and the first interpolation coefficient is less than 1, and if the sum of the target interpolation coefficient corresponding to the currently inserted new pixel point and the first interpolation coefficient is not less than 1, the pixel insertion is stopped, so that the problems that the pixel coordinate of the new pixel point with the specified number of pixel points is still calculated and the pixel coordinate of the new pixel point is calculated inefficiently and the calculation resources are wasted in the case that the target distance between two pixel points is not satisfied with the situation that the new pixel points with the specified number are inserted in the prior art can be effectively avoided.
FIG. 4 is a flowchart illustrating step 240 according to a specific embodiment of the present application. As shown in fig. 4, includes:
step 410, obtaining the pixel coordinates of three vertices in the triangle primitive.
In step 420, the pixel coordinates of two vertices (vertex A and vertex B) of the triangle primitive are obtained.
Step 430, inserting vertex A into a linked list, namely enabling ipStart- > next = A; iped = a.
Step 440, calculating a first interpolation coefficient
Figure 488997DEST_PATH_IMAGE033
(ii) a And order
Figure 591951DEST_PATH_IMAGE034
=
Figure 250465DEST_PATH_IMAGE014
And let temp =
Figure 884709DEST_PATH_IMAGE035
Step 450, judge
Figure 919661DEST_PATH_IMAGE036
If the value is less than 1, if so, executing the step 460, if not, inserting the pixel point B in the linked list as the tail part of the linked list, namely ipEnd->next = B, ipEnd = B, and correspondingly stops inserting new pixel points.
Step 460, calculating the pixel coordinate of the newly inserted pixel point P;
step 470, will
Figure 142701DEST_PATH_IMAGE037
=
Figure 972117DEST_PATH_IMAGE037
+ temp; and then correspondingly returns to perform step 450.
Specifically, the triangle primitive to be subjected to pixel interpolation may be defined in advance by the following structural body:
struct private {// triangle primitive
struct Vertex A;
struct Vertex B;
struct Vertex C;
};
Then, the pixel coordinates of each vertex in the triangle primitive may be defined by the following structural body:
struct Vertex {// Vertex information, pos denotes coordinates
int pos[3];
};
Thereafter, the interpolation point chain table is defined by the following structure:
struct InterPoint {// interpolated point chain table
struct Vertex p;
struct interPoint *next;
};
Based on the three structural bodies defined above, step 410-470 as above can be realized by the following codes.
Main:
struct interPoint A,B,P;
A- > p = primitive vertex A data;
b- > p = data of primitive vertex B;
struct InterPoint IPStart;/interpolation point chain table
struct interPoint *ipEnd;
Point a inserts linked list:
calculated according to any one of formulas 3-5
Figure 93656DEST_PATH_IMAGE038
;
Order to
Figure 184497DEST_PATH_IMAGE036
=
Figure 747196DEST_PATH_IMAGE039
μ
temp = μ;
While μ<1 do:
Calculating the pixel coordinate of the new pixel point P according to a formula 9;
inserting point P in the linked list;
μ = μ + temp;
end;
and inserting point B in the linked list as the tail part of the linked list.
Therefore, under the condition that the mu is larger than or equal to 1, the insertion of the new pixel point is stopped, and the invalid calculation of the pixel coordinate of the new pixel point is avoided.
In other embodiments of the present application, as shown in FIG. 5, the step 250 includes the following steps 510 and 550, which are described in detail as follows:
step 510, determining a color component difference value of two pixels in the target pixel pair on each color component.
In the case of determining the target image, the color component values of the pixels in the target image on the color components are correspondingly determined, for example, if the colors of the pixels in the target image are represented by RGB values, the color component values of the pixels on the red component, the color component values on the green component, and the color component values on the blue component are correspondingly determined.
Therefore, based on the color component values of the two pixel points in the target pixel point pair on the color components, the color component difference values of the two pixel points on the color components can be correspondingly determined.
And 520, performing exponential operation according to the color component difference value and a second specified parameter to obtain a second interpolation coefficient corresponding to the target pixel point pair, wherein the second specified parameter is used as a base number, the color component difference value is used for determining an exponent of the second specified parameter, and the second specified parameter belongs to (0, 1).
Wherein the second specified parameter can be preset. In the present application, the exponent of the second specified parameter may be a positive number, so that in the case of the second index parameter ∈ (0, 1), a second interpolation coefficient ∈ (0, 1) resulting from an exponential operation based on the color component difference value and the second specified parameter.
In some embodiments, the index of the second specified parameter may be determined according to the following procedure: calculating the square of the color component difference to obtain a second target parameter; the product of the second target parameter and the second coefficient is used as the exponent of the second specified parameter, wherein the second coefficient is e (0, 1).
Assuming that two pixels in the target pixel pair are respectively a pixel A and a pixel B, and the color component value of the pixel A under the color component X is
Figure 278672DEST_PATH_IMAGE040
The color component value of the pixel point B under the color component X is
Figure 605617DEST_PATH_IMAGE041
Then the second target parameter may be determined according to the following formula:
Figure 451213DEST_PATH_IMAGE042
(ii) a (formula 11)
Further, if used
Figure 930736DEST_PATH_IMAGE043
Expressing the second coefficient, the index of the second specified parameter can be determined according to the following formula
Figure 882380DEST_PATH_IMAGE044
2:
Figure 447354DEST_PATH_IMAGE045
S2; (formula 12)
In this embodiment, if t2 is the second specified parameter, the above equation 11 and equation 12 are combined, which is equivalent to calculating the second interpolation coefficient according to the following equation 13
Figure 831062DEST_PATH_IMAGE046
Figure 414359DEST_PATH_IMAGE047
(ii) a (formula 13)
In a particular embodiment, the second coefficient
Figure 287637DEST_PATH_IMAGE048
And the second designated parameter t2 may be preset.
In other embodiments, the product of the absolute value of the color component difference and the second coefficient may also be used as an index of the second specified parameter; wherein the content of the first and second substances,the second coefficient is ∈ (0, 1)]. In this case, it is equivalent to calculating the second interpolation coefficient according to the following formula 14
Figure 339906DEST_PATH_IMAGE049
Figure 58464DEST_PATH_IMAGE050
(ii) a (formula 14)
Step 530, determining a color component variation value in the interpolation direction corresponding to the target pixel point pair according to the second interpolation coefficient and the color component difference value.
The color component variation value in the interpolation direction corresponding to the target pixel point pair is used to indicate the variation of the color component value between two adjacent pixel points in the interpolation direction corresponding to the target pixel point pair.
Specifically, the product of the absolute value of the color component difference and the second interpolation coefficient may be used as the color component variation value of the target pixel point pair in the corresponding interpolation direction
Figure 956320DEST_PATH_IMAGE051
C. Namely:
Figure 734920DEST_PATH_IMAGE052
(ii) a (formula 15)
Step 540, determining the color component value of each new pixel point on the color component according to the color component variation value; and the color component values of the plurality of new pixel points in the interpolation direction are in equal difference change.
In this embodiment, it is equivalent to perform equal variation on the new pixel points inserted between two pixel points in the target pixel point pair according to the color component variation value to determine the color component values of the new pixel points on the corresponding color components, so that the color component values of the new pixel points in the interpolation direction corresponding to the target pixel point pair are changed in an equal difference manner.
In a specific embodiment, for a new pixel point of a color component value to be determined on a color component, the color component value of a previous pixel point corresponding to the new pixel point on the color component is obtained, and then the color component value of the previous pixel point corresponding to the new pixel point on the color component is added to the color component variation value, so as to obtain the color component value of the new pixel point on the color component. It can be understood that, when the new pixel point of the color component value to be determined on the color component is the first new pixel point inserted between the target pixel point pairs along the interpolation direction, the previous pixel point corresponding to the new pixel point is the pixel point of the target pixel point pair as the starting point. Similarly, the color component values of other new pixel points under each color component can be determined according to a similar process.
And 550, generating an interpolation image corresponding to the target image according to the color component value of each new pixel point on each color component and the pixel coordinate of each new pixel point.
Based on the color component values of the new pixel point on all the color components, the color of the new pixel point can be correspondingly determined. Therefore, under the condition of determining the pixel coordinates of the new pixel points and the colors of the new pixel points, the related information of the new pixel points is known, and therefore the interpolation image corresponding to the target image can be correspondingly determined.
In the above embodiment, for a new pixel point inserted between two pixel points in a target pixel point pair, the color component value of each new pixel point on each color component is determined based on the color component difference value between the two pixel points in the target pixel point pair on each color component, and the color component values of a plurality of new pixel points on each color component are in equal difference change along the interpolation direction corresponding to the target pixel point pair, so that uniform transition of the colors of the plurality of new pixel points between the pixel point as the starting point and the pixel point as the ending point in the target pixel point pair is ensured, and the color of the plurality of pixel points inserted in the target pixel point pair can be ensured to have a gradual change effect.
The second interpolation coefficient is obtained by performing exponential operation according to the color component difference value and a second specified parameter, and the color component change value under one color component changes along with the change of the color component difference value of two pixel points in a target pixel point pair on the color component, so that the gradient amplitude of the corresponding color component difference value on the color component is different between the target pixel point pairs and new pixel points inserted between the target pixel point pairs, and the gradient amplitude of the corresponding color component between the new pixel points is adapted and determined by the color component difference value of the two pixel points in the target pixel point pair on the color component.
It should be noted that, in a case that color interpolation needs to be performed on any image or a gradual change effect of an image is required, color interpolation may also be performed according to a similar process of the embodiment corresponding to fig. 5, so as to achieve a color gradual change effect.
In some embodiments of the present application, as shown in fig. 6, after step 250, the method further comprises the following step 610 and 660, which are described in detail as follows:
step 610, determining an initial texture image corresponding to the interpolated image.
An important process in the rendering phase of primitives of a three-dimensional model surface is texture mapping. Texture mapping, also known as texture mapping, is the process of mapping texels in texture space to pixels in screen space. Simply, a texture image is attached to the surface of an object (such as a target image) to enhance the reality, and can be combined with technologies such as illumination calculation, image mixing and the like to form a plurality of very beautiful effects.
In practice, if a pixel point on the interpolated image does not correspond to a texture pixel point in the texture image, for example, in this application, a plurality of pixel points on the interpolated image cover one texture pixel point in the texture image, in this case, the texture image needs to be interpolated, so that after the interpolation process, one pixel point in the interpolated image covers one texture pixel point in the texture image.
The initial texture image corresponding to the interpolated image may be predetermined, for example, a texture effect to be created on the interpolated image is predetermined, and the initial texture image corresponding to the interpolated image is specified.
Step 620, for the target texture pixel point pair in which the new texture pixel point needs to be inserted in the initial texture image, calculating the texture pixel distance between two texture pixel points in the target texture pixel point pair.
As described above, if a plurality of pixel points on the interpolated image cover one texture pixel point in the initial texture image, in order to ensure the texture mapping effect, in this case, the interpolation process needs to be performed on the initial texture image.
In the present application, a texel point pair formed by two texel points, into which a new texel point needs to be inserted, in an initial texture image is referred to as a target texel point pair. One or more target pixel point pairs in the initial texture image may be provided.
The texel distance between the target texel point pair is the distance between two texture pixel points calculated based on the texel coordinates of the two texture pixel points in the target texture pixel point.
Step 630, performing exponential operation according to the texel distance and a third designated parameter to obtain a third interpolation coefficient corresponding to the target texel point pair; the third designated parameter is used as a base number, and the texel distance is used for determining an index of the third designated parameter; the third specified parameter ∈ (0, 1).
The exponent of the third specified parameter is a positive number, and thus, in the case where the third exponential parameter is ∈ (0, 1), a third interpolation coefficient ∈ (0, 1) obtained by performing an exponential operation based on the texel distance and the third specified parameter.
In some embodiments, the index of the third specified parameter may be determined according to the following procedure: calculating the square of the texture pixel distance to obtain a third target parameter; the product of the third target parameter and a third coefficient is taken as the exponent of the third specified parameter, where the third coefficient ∈ (0, 1).
Suppose that two texture pixels in the target texture pixel pair are respectively a texture pixel E and a texture pixel F, and the texture pixel coordinate of the texture pixel E is
Figure 540065DEST_PATH_IMAGE053
The texture pixel point F has a texture pixel coordinate of
Figure 311580DEST_PATH_IMAGE054
Then the third target parameter S3 corresponding to the target texel point pair may be determined according to the following formula:
Figure 823464DEST_PATH_IMAGE055
(ii) a (formula 16)
Figure 772966DEST_PATH_IMAGE056
And expressing the texel distance between the texel E and the texel F.
Further, if used
Figure 49095DEST_PATH_IMAGE057
Expressing the third coefficient, the exponent of the third specified parameter can be determined according to the following equation
Figure 578297DEST_PATH_IMAGE004
3:
Figure 741425DEST_PATH_IMAGE058
S3; (formula 17)
In this embodiment, if t3 is the third specific parameter, the above equation 16 and equation 17 are combined, which is equivalent to calculating the third interpolation coefficient according to the following equation 18
Figure 111095DEST_PATH_IMAGE059
Figure 890832DEST_PATH_IMAGE060
(ii) a (formula 18)
In one embodiment, the third coefficient
Figure 754883DEST_PATH_IMAGE061
And the third specifying parameter t3 may be preset.
In other embodiments, the product of the texel distance and the third coefficient may be used as an index of a third specified parameter; wherein the third coefficient ∈ (0, 1)]. In this case, it is equivalent to calculating the third interpolation coefficient according to the following formula 19
Figure 227977DEST_PATH_IMAGE062
Figure 50440DEST_PATH_IMAGE063
(ii) a (formula 19)
As can be seen from the above equations 18 and 19, in the case of the third specified parameter t1 ∈ (0, 1), since the exponent of the third specified parameter is a positive number, the calculated third interpolation coefficient
Figure 786315DEST_PATH_IMAGE064
E (0, 1). Moreover, under the condition that the distance between the texture pixel point E and the texture pixel point F is larger, the third interpolation coefficient determined for the texture pixel point E and the texture pixel point F is smaller. The third interpolation coefficients determined for each target pair of texel points are all within the range of (0, 1) for different target pairs of texel points, even though the corresponding texel distances are different.
And step 640, determining a texture interpolation distance in the interpolation direction corresponding to the target texture pixel point pair according to the third interpolation coefficient and the texture pixel distance.
The texture interpolation distance in the interpolation direction corresponding to the target texture pixel point pair is used for indicating the variation of the texture pixel coordinate between two adjacent texture pixel points in the interpolation direction corresponding to the target texture pixel point pair.
Specifically, the product of the texel distance and the third interpolation coefficient may be used as the target texel point pair in the corresponding interpolation directionTexture interpolation interval of
Figure 906586DEST_PATH_IMAGE051
D. Namely:
Figure 44306DEST_PATH_IMAGE065
(ii) a (formula 20)
And 650, inserting new texture pixel points between the target texture pixel point pairs at equal intervals according to the texture interpolation interval to obtain texture pixel coordinates of the new texture pixel points.
In some embodiments, one of the target texture pixel point pair may be used as a starting point, then the texture pixel coordinate of a newly inserted texture pixel point (i.e., a new texture pixel point) is calculated according to the texture interpolation interval, then, equidistant interpolation is correspondingly continued according to the texture interpolation interval, the texture pixel coordinate of a next new texture pixel point is calculated, and the new texture pixel point is stopped from being inserted until it is determined that the distance from the new texture pixel point to be inserted to the new texture pixel point is greater than or equal to the texture interpolation interval.
In some embodiments, the number of new texture pixel points that can be inserted between two texture pixel points in the target texture pixel point pair may be determined according to the texture pixel distance between the two texture pixel points in the target texture pixel point pair and the determined texture interpolation distance, where the number of the new texture pixel points that can be inserted is equal to the rounding of the result obtained by dividing the texture pixel distance by the texture interpolation distance. And then correspondingly calculating the texture pixel coordinate of each new texture pixel point according to the texture interpolation distance and the pixel coordinate of at least one texture pixel point in the target texture pixel point pair until the number of the inserted new texture pixel points is determined to reach the number of the insertable new texture pixel points.
In other embodiments, the texel coordinates of each new texture pixel point may be determined according to a process similar to that shown in fig. 3, which may specifically refer to the description of the embodiment corresponding to fig. 3 and will not be described herein again.
Step 660, determining a target texture image corresponding to the interpolated image based on the texture pixel coordinates of the new texture pixel points.
The target texture image corresponding to the interpolated image is a texture image obtained after new texture pixel points are inserted into the initial texture image corresponding to the interpolated image, and it can be understood that the number of texture pixel points included in the target texture image is greater than the number of texture pixel points included in the initial texture image.
In a specific embodiment, after determining the position of the new texture pixel point in the target texture image based on the texture pixel coordinate of the new texture pixel point, it is further necessary to further determine a texture pixel value corresponding to each new texture pixel point, so that the target texture image is correspondingly determined based on the texture pixel value of the new texture pixel point and the texture pixel value of each texture pixel point in the initial texture image.
In some embodiments, the texel values of the texel points surrounding the new texel point may be combined to determine the texel value of the new texel point. For example, for a new texture pixel point whose texture pixel value is to be determined, M known texture pixel points whose texture pixel values are known are determined (M is a positive integer greater than or equal to 2, for example, M is 2, 4, 6, 8, etc.) in the vicinity of the new texture pixel point; then, the average value of the texel values of the M known texture pixel points may be calculated, and the calculated average texel value is used as the texel value of the new texture pixel point.
In other embodiments, the texel values corresponding to the new texel points inserted between the two texel points in the target texel point pair may be determined according to a process similar to that in step 510-540 in fig. 5, so that the texel values of the new texel points inserted between the two texel points in the target texel point pair exhibit a gradual change effect.
It should be noted that, in a scene where any texture image needs to be interpolated, texture pixel points may also be inserted according to the process of the embodiment corresponding to fig. 6.
In the embodiment corresponding to fig. 6, based on the texel distance between two texel points in the target texel point pair and the interpolation distance determined for the target texel point, a first target number, in which a new texel point can be inserted in the target texel point pair, can be determined, where the first target number is approximately equal to the reciprocal of a third interpolation coefficient, and the third interpolation coefficient is in a negative correlation with the texel distance, and thus, the larger the corresponding texel distance is, the larger the number of target texel point pairs between two texel points, where the new texel point can be inserted; conversely, the smaller the corresponding texel distance is, the smaller the number of new texture pixel points inserted between the target texel point pairs is; therefore, the scheme can ensure that the number of the new texture pixel points inserted between the target texture pixel point pairs with different texture pixel distances is different, and the number of the new texture pixel points inserted between the two texture pixel points in the target texture pixel point pairs is dynamically changed along with the change of the texture pixel distances.
In addition, in the scheme of the application, the texture interpolation distance is dynamically changed along with the texture pixel distance between two texture pixel points in the target texture pixel point pair, so that the flexibility of texture interpolation is improved; moreover, the scheme of the application can ensure that more interpolation is carried out between two texture pixel points with larger distance between the texture pixels, and less interpolation is carried out between two texture pixel points with smaller distance between the texture pixels, so that the reasonability of texture pixel insertion is ensured, and the effect of the obtained target texture image is ensured.
As can be seen from the above embodiments corresponding to fig. 2, fig. 5, and fig. 6, the solution of the present application may be applied in a pixel interpolation scenario (e.g., the embodiment corresponding to fig. 2), may also be applied in a color interpolation scenario (e.g., steps 510 and 540 corresponding to fig. 5), and may also be applied in a texture pixel interpolation scenario (e.g., steps 620 and 640 corresponding to fig. 6). In all of the three interpolation scenarios, the predetermined parameters (first predetermined parameter, second predetermined parameter, and third predetermined parameter) and the predetermined coefficients (first coefficient, second coefficient, and third coefficient) are involved. Therefore, in a specific embodiment, the corresponding relationship between the interpolation application scenario and the specified parameter and coefficient may be preset, so that the user may obtain the specified parameter and coefficient that are correspondingly set according to the interpolation application scenario.
In some embodiments of the present application, prior to step 220, the method further comprises: acquiring interpolation scene indication information; if the interpolation application scene indicated by the interpolation scene indication information is a pixel interpolation scene, acquiring a specified parameter associated with the pixel interpolation scene based on a mapping relation between the interpolation scene and the specified parameter, and taking the specified parameter associated with the pixel interpolation scene as a first specified parameter.
In some embodiments of the present application, the method further comprises: acquiring interpolation scene indication information; if the interpolation application scene indicated by the interpolation scene indication information is a pixel interpolation scene, acquiring a coefficient associated with the pixel interpolation scene based on a mapping relation between the interpolation scene and the coefficient, and taking the coefficient associated with the pixel interpolation scene as a first coefficient.
Similarly, in the embodiment corresponding to fig. 5, the specified parameter associated with the color interpolation scene may also be obtained as the second specified parameter based on the mapping relationship between the interpolation scene and the specified parameter. And acquiring a coefficient associated with the color interpolation scene as a second coefficient based on a mapping relation between the interpolation scene and the coefficient.
Similarly, in the embodiment corresponding to fig. 6, the specified parameter associated with the texel interpolation scene may also be obtained as the third specified parameter based on the mapping relationship between the interpolation scene and the specified parameter. And acquiring a coefficient associated with the texture pixel interpolation scene as a third coefficient based on the mapping relation between the interpolation scene and the coefficient.
Embodiments of the apparatus of the present application are described below, which may be used to perform the methods of the above-described embodiments of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the above-described embodiments of the method of the present application.
Fig. 7 is a block diagram of an image processing apparatus according to an embodiment of the present application, which may be configured in an electronic device such as a server or a terminal device, and is used for implementing the image processing method provided by the present application. As shown in fig. 7, the image processing apparatus includes: a target distance calculating module 710, configured to calculate a target distance between two pixels in a target pixel pair in a target image; a first interpolation coefficient determining module 720, configured to perform an exponential operation according to the target distance and the first specified parameter, to obtain a first interpolation coefficient corresponding to the target pixel point pair; the target distance is used for determining an index of the first designated parameter; a first specified parameter e (0, 1); an interpolation interval determining module 730, configured to determine, according to the first interpolation coefficient and the target distance corresponding to the target pixel point pair, an interpolation interval in the interpolation direction corresponding to the target pixel point pair; the pixel inserting module 740 is configured to insert new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval, so as to obtain pixel coordinates of each new pixel point; and an interpolated image determining module 750, configured to determine an interpolated image corresponding to the target image based on the pixel coordinates of each new pixel.
In some embodiments of the present application, the interpolated image determination module 750 includes: the color component difference determining unit is used for determining the color component difference of two pixel points in the target pixel point pair on each color component; the second interpolation coefficient determining unit is used for performing exponential operation according to the color component difference and a second specified parameter to obtain a second interpolation coefficient corresponding to the target pixel point pair, wherein the second specified parameter is used as a base number, the color component difference is used for determining an index of the second specified parameter, and the second specified parameter belongs to (0, 1); a color component change value determination unit, configured to determine a color component change value in the interpolation direction corresponding to the target pixel point pair according to the second interpolation coefficient and the color component difference value; the color component value determining unit is used for determining the color component value of each new pixel point on the color component according to the color component change value; wherein, the color component values of the plurality of new pixel points along the interpolation direction are in equal difference change; and the interpolation image determining unit is used for generating an interpolation image corresponding to the target image according to the color component values of the new pixel points on the color components.
In some embodiments of the present application, the image processing apparatus further comprises: the initial texture image determining module is used for determining an initial texture image corresponding to the interpolation image; the texture pixel distance determining module is used for calculating the texture pixel distance between two texture pixel points in a target texture pixel point pair for the target texture pixel point pair in which a new texture pixel point needs to be inserted in the initial texture image; the third interpolation coefficient determining module is used for performing exponential operation according to the texel distance and a third specified parameter to obtain a third interpolation coefficient corresponding to the target texel point pair; the third specified parameter is used as a base number, and the texel distance is used for determining an index of the third specified parameter; a third specified parameter e (0, 1); the texture interpolation interval determining module is used for determining the texture interpolation interval in the interpolation direction corresponding to the target texture pixel point pair according to the third interpolation coefficient and the texture pixel distance; the texture pixel coordinate determination module is used for inserting new texture pixel points between the target texture pixel point pairs at equal intervals according to the texture interpolation interval to obtain texture pixel coordinates of the new texture pixel points; and the target texture image determining module is used for determining a target texture image corresponding to the interpolation image based on the texture pixel coordinates of the new texture pixel points.
In some embodiments of the present application, the image processing apparatus further comprises: the first target parameter determining module is used for calculating the square of the target distance to obtain a first target parameter; and a first exponent determining module for taking a product of the first target parameter and a first coefficient as an exponent of the first specified parameter, wherein the first coefficient is e (0, 1).
In further embodiments of the present application, the image processing apparatus further comprises: the second index determining module is used for taking the product of the target distance and the first coefficient as the index of the first specified parameter; wherein the first coefficient ∈ (0, 1).
In some embodiments of the present application, the pixel interpolation module 740 includes: a target interpolation coefficient acquisition unit for acquiring a target interpolation coefficient corresponding to the (t-1) th new pixel point, wherein the target interpolation coefficient corresponding to the (t-1) th new pixel point is equal to the product of the (t-1) and the first interpolation coefficient corresponding to the target pixel point pair; t is a positive integer greater than or equal to 2; the insertion stopping unit is used for stopping inserting the new pixel point if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is not less than 1; the summing unit is used for taking the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient as the target interpolation coefficient corresponding to the t-th new pixel point if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is smaller than 1; the pixel coordinate increment determining unit is used for determining the pixel coordinate increment of the t-th new pixel point relative to the pixel point which is taken as the starting point in the target pixel point pair based on the interpolation distance; and the pixel coordinate determination unit is used for determining the pixel coordinate of the t-th new pixel point according to the pixel coordinate increment of the t-th new pixel point relative to the pixel point which serves as the starting point in the target pixel point pair and the pixel coordinate of the pixel point which serves as the starting point in the target pixel point pair.
In some embodiments of the present application, the image processing apparatus further comprises: the acquisition module is used for acquiring interpolation scene indication information; and the first specified parameter acquiring module is used for acquiring specified parameters associated with the pixel interpolation scene based on the mapping relation between the interpolation scene and the specified parameters if the interpolation application scene indicated by the interpolation scene indication information is the pixel interpolation scene, and taking the specified parameters associated with the pixel interpolation scene as the first specified parameters.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device can be used for executing the image processing method provided by the application. Those skilled in the art will appreciate that the configuration of the electronic device shown in fig. 8 does not constitute a limitation of the electronic device and may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 8, the electronic device may include: a processor 801, e.g. a CPU, a network interface 804, a user interface 803, a memory 805, a communication bus 802. The communication bus 802 is used to realize connection communication among these components. The user interface 803 may include a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally, the user interface 803 may also include a standard wired interface, a wireless interface. The network interface 804 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 805 may be a high-speed RAM memory or a non-volatile memory (e.g., a disk memory). The memory 805 may alternatively be a storage device separate from the processor 801 described above.
As shown in fig. 8, an operating system, a network communication module, a user interface module, and a program implementing the image processing method may be included in the memory 805 as a computer-readable storage medium.
In the electronic device shown in fig. 8, the network interface 804 is mainly used for communication connection with other devices. The user interface 803 is mainly used for connecting a client and performing data communication with the client; and the processor 801 may be configured to call a program stored in the memory 805 to implement the image processing method and perform the steps of the image processing method in any of the above method embodiments.
According to an aspect of the embodiments of the present application, there is provided a computer-readable storage medium having stored thereon computer-readable instructions which, when executed by a processor, implement an image processing method as in any one of the above method embodiments.
It should be noted that the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may be, for example, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a 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. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
According to an aspect of an embodiment of the present application, there is provided a computer program product comprising computer instructions which, when executed by a processor, implement an image processing method as in any of the above method embodiments.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, and may also be implemented by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the present application is not limited to the precise arrangements that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. An image processing method, comprising:
calculating a target distance between two pixel points in a target pixel point pair in a target image;
performing exponential operation according to the target distance and a first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; the first specified parameter is used as a base number, and the target distance is used for determining an index of the first specified parameter; the first specified parameter e (0, 1);
determining an interpolation distance in an interpolation direction corresponding to the target pixel point pair according to a first interpolation coefficient corresponding to the target pixel point pair and the target distance;
inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of the new pixel points;
and determining an interpolation image corresponding to the target image based on the pixel coordinates of the new pixel points.
2. The method according to claim 1, wherein the determining an interpolated image corresponding to the target image based on the pixel coordinates of each new pixel point comprises:
determining the color component difference value of two pixel points in the target pixel point pair on each color component;
performing exponential operation according to the color component difference and a second specified parameter to obtain a second interpolation coefficient corresponding to the target pixel point pair, wherein the second specified parameter is used as a base number, the color component difference is used for determining an exponent of the second specified parameter, and the second specified parameter belongs to (0, 1);
determining a color component change value in the interpolation direction corresponding to the target pixel point pair according to the second interpolation coefficient and the color component difference value;
determining the color component value of each new pixel point on the color component according to the color component change value; wherein, the color component values of the plurality of new pixel points along the interpolation direction are in equal difference change;
and generating an interpolation image corresponding to the target image according to the color component value of each new pixel point on each color component and the pixel coordinate of each new pixel point.
3. The method according to claim 1, wherein before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further comprises:
calculating the square of the target distance to obtain a first target parameter;
taking the product of the first target parameter and a first coefficient as the exponent of the first specified parameter, wherein the first coefficient is e (0, 1).
4. The method according to claim 1, wherein before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further comprises:
taking the product of the target distance and a first coefficient as an index of the first specified parameter; wherein the first coefficient ∈ (0, 1 ].
5. The method of claim 1, wherein the inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of each new pixel point comprises:
acquiring a target interpolation coefficient corresponding to the (t-1) th new pixel point, wherein the target interpolation coefficient corresponding to the (t-1) th new pixel point is equal to the product of the (t-1) and the first interpolation coefficient corresponding to the target pixel point pair; t is a positive integer greater than or equal to 2;
if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is not less than 1, stopping inserting the new pixel point;
if the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient is less than 1, taking the sum of the target interpolation coefficient corresponding to the (t-1) th new pixel point and the first interpolation coefficient as a target interpolation coefficient corresponding to the t-th new pixel point; and
based on the interpolation interval, determining the pixel coordinate increment of the t-th new pixel point relative to the pixel point which is taken as the starting point in the target pixel point pair;
and determining the pixel coordinate of the t-th new pixel point according to the pixel coordinate increment of the t-th new pixel point relative to the pixel point which serves as the starting point in the target pixel point pair and the pixel coordinate of the pixel point which serves as the starting point in the target pixel point pair.
6. The method according to claim 1, wherein before performing an exponential operation according to the target distance and a first specified parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair, the method further comprises:
acquiring interpolation scene indication information;
if the interpolation application scene indicated by the interpolation scene indication information is a pixel interpolation scene, acquiring a specified parameter associated with the pixel interpolation scene based on a mapping relation between the interpolation scene and the specified parameter, and taking the specified parameter associated with the pixel interpolation scene as the first specified parameter.
7. The method according to any one of claims 1 to 6, wherein after determining the interpolated image corresponding to the target image based on the pixel coordinates of each of the new pixel points, the method further comprises:
determining an initial texture image corresponding to the interpolation image;
calculating the texture pixel distance between two texture pixel points in the target texture pixel point pair for the target texture pixel point pair in which a new texture pixel point needs to be inserted in the initial texture image;
performing exponential operation according to the texel distance and a third designated parameter to obtain a third interpolation coefficient corresponding to the target texel point pair; wherein the third specified parameter is used as a base number, and the texel distance is used for determining an index of the third specified parameter; the third specified parameter e (0, 1);
determining a texture interpolation distance in the interpolation direction corresponding to the target texture pixel point pair according to the third interpolation coefficient and the texture pixel distance;
inserting new texture pixel points between the target texture pixel point pairs at equal intervals according to the texture interpolation interval to obtain texture pixel coordinates of the new texture pixel points;
and determining a target texture image corresponding to the interpolation image based on the texture pixel coordinates of the new texture pixel points.
8. An image processing apparatus characterized by comprising:
the target distance calculation module is used for calculating the target distance between two pixel points in a target pixel point pair in the target image;
the first interpolation coefficient determining module is used for performing exponential operation according to the target distance and a first designated parameter to obtain a first interpolation coefficient corresponding to the target pixel point pair; the first specified parameter is used as a base number, and the target distance is used for determining an index of the first specified parameter; the first specified parameter is epsilon (0, 1);
an interpolation interval determining module, configured to determine, according to a first interpolation coefficient and the target distance that correspond to the target pixel point pair, an interpolation interval in an interpolation direction that corresponds to the target pixel point pair;
the pixel inserting module is used for inserting new pixel points between the target pixel point pairs at equal intervals according to the interpolation interval to obtain pixel coordinates of the new pixel points;
and the interpolation image determining module is used for determining an interpolation image corresponding to the target image based on the pixel coordinates of the new pixel points.
9. An electronic device, comprising:
a processor;
a memory having stored thereon computer readable instructions which, when executed by the processor, implement the method of any one of claims 1 to 7.
10. A computer readable storage medium having stored thereon computer readable instructions which, when executed by a processor, implement the method of any one of claims 1 to 7.
CN202211000999.0A 2022-08-19 2022-08-19 Image processing method, image processing device, electronic equipment and storage medium Active CN115082323B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211000999.0A CN115082323B (en) 2022-08-19 2022-08-19 Image processing method, image processing device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211000999.0A CN115082323B (en) 2022-08-19 2022-08-19 Image processing method, image processing device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115082323A true CN115082323A (en) 2022-09-20
CN115082323B CN115082323B (en) 2022-11-04

Family

ID=83244580

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211000999.0A Active CN115082323B (en) 2022-08-19 2022-08-19 Image processing method, image processing device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115082323B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030201997A1 (en) * 2002-04-26 2003-10-30 Xerox Corporation Method and system for efficient interpolation using programmable node spacing
US20070110300A1 (en) * 2005-11-17 2007-05-17 Hung-An Chang Color interpolation apparatus and color interpolation method utilizing edge indicators adjusted by stochastic adjustment factors to reconstruct missing colors for image pixels
US20150016749A1 (en) * 2013-07-12 2015-01-15 National Central University Image interpolation method and image interpolation device and image apparatus using the same
CN108305228A (en) * 2018-01-26 2018-07-20 网易(杭州)网络有限公司 Image processing method, device, storage medium and processor
CN110211193A (en) * 2019-05-17 2019-09-06 山东财经大学 Three dimensional CT interlayer image interpolation reparation and super-resolution processing method and device
CN114092336A (en) * 2022-01-19 2022-02-25 深圳鲲云信息科技有限公司 Image scaling method, device, equipment and medium based on bilinear interpolation algorithm

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030201997A1 (en) * 2002-04-26 2003-10-30 Xerox Corporation Method and system for efficient interpolation using programmable node spacing
US20070110300A1 (en) * 2005-11-17 2007-05-17 Hung-An Chang Color interpolation apparatus and color interpolation method utilizing edge indicators adjusted by stochastic adjustment factors to reconstruct missing colors for image pixels
US20150016749A1 (en) * 2013-07-12 2015-01-15 National Central University Image interpolation method and image interpolation device and image apparatus using the same
CN108305228A (en) * 2018-01-26 2018-07-20 网易(杭州)网络有限公司 Image processing method, device, storage medium and processor
CN110211193A (en) * 2019-05-17 2019-09-06 山东财经大学 Three dimensional CT interlayer image interpolation reparation and super-resolution processing method and device
CN114092336A (en) * 2022-01-19 2022-02-25 深圳鲲云信息科技有限公司 Image scaling method, device, equipment and medium based on bilinear interpolation algorithm

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
BIER, V. A等: "Interpolation selection index for delineation of thematic maps", 《COMPUTERS AND ELECTRONICS IN AGRICULTURE》 *
符祥等: "图像插值技术综述", 《计算机工程与设计》 *

Also Published As

Publication number Publication date
CN115082323B (en) 2022-11-04

Similar Documents

Publication Publication Date Title
CN112116692A (en) Model rendering method, device and equipment
JP2010113624A (en) Device and method for drawing bezier curve and program
CN109949693B (en) Map drawing method and device, computing equipment and storage medium
CN110570506B (en) Map resource management method, device, computing equipment and storage medium
US10922852B2 (en) Oil painting stroke simulation using neural network
JP2019536174A (en) Apparatus and method for generating light intensity images
CN106875328B (en) Image processing method and device
US20180033185A1 (en) Texture mapping apparatus, texture mapping method, and computer readable medium
US20040183451A1 (en) Fast lighting processors
CN108960012B (en) Feature point detection method and device and electronic equipment
CN111476851A (en) Image processing method, image processing device, electronic equipment and storage medium
CN115082323B (en) Image processing method, image processing device, electronic equipment and storage medium
US8989486B2 (en) Generation of intermediate images for texture compression
CN113827958B (en) Magma rendering method, device, equipment and storage medium
US5892516A (en) Perspective texture mapping circuit having pixel color interpolation mode and method thereof
CN116681860A (en) Feature line rendering method and device, electronic equipment and storage medium
CN115908685A (en) Scene rendering method, device, equipment and storage medium
US20230377265A1 (en) Systems for Efficiently Rendering Vector Objects
US10417789B2 (en) Motion blur using cached texture space blur
CN114581586A (en) Method and device for generating model substrate, electronic equipment and storage medium
CN114119831A (en) Snow accumulation model rendering method and device, electronic equipment and readable medium
JPH11185052A (en) Device and method for calculating texture mapping coordinate of three-dimensional computer graphics
CN111340924B (en) Image rendering method, device, equipment and storage medium
JPH11242585A (en) Division circuit and graphic arithmetic unit
CN114170368A (en) Method and system for rendering quadrilateral wire frame of model and model rendering equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant