CN114581508B - Curved surface image generation method and device, electronic equipment and storage medium - Google Patents
Curved surface image generation method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN114581508B CN114581508B CN202210179218.2A CN202210179218A CN114581508B CN 114581508 B CN114581508 B CN 114581508B CN 202210179218 A CN202210179218 A CN 202210179218A CN 114581508 B CN114581508 B CN 114581508B
- Authority
- CN
- China
- Prior art keywords
- curved surface
- image
- pixel point
- neighborhood
- coordinate
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 74
- 238000013507 mapping Methods 0.000 claims abstract description 215
- 239000011159 matrix material Substances 0.000 claims abstract description 88
- 238000005452 bending Methods 0.000 claims description 101
- 238000001514 detection method Methods 0.000 claims description 55
- 238000004364 calculation method Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 7
- 238000005516 engineering process Methods 0.000 abstract description 6
- 238000013473 artificial intelligence Methods 0.000 abstract description 3
- 230000000694 effects Effects 0.000 description 23
- 230000009466 transformation Effects 0.000 description 21
- 230000008569 process Effects 0.000 description 19
- 238000012545 processing Methods 0.000 description 14
- 230000006870 function Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 8
- 238000012549 training Methods 0.000 description 5
- 238000007667 floating Methods 0.000 description 4
- 238000002372 labelling Methods 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000010276 construction Methods 0.000 description 3
- 238000007726 management method Methods 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000005484 gravity Effects 0.000 description 2
- 230000007774 longterm Effects 0.000 description 2
- 238000010295 mobile communication Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000005236 sound signal Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000010897 surface acoustic wave method Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
- G06T7/64—Analysis of geometric attributes of convexity or concavity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/20—Drawing from basic elements, e.g. lines or circles
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/70—Determining position or orientation of objects or cameras
- G06T7/73—Determining position or orientation of objects or cameras using feature-based methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Geometry (AREA)
- Image Processing (AREA)
Abstract
The embodiment of the invention discloses a curved surface image generation method, a curved surface image generation device, electronic equipment and a storage medium; the embodiment of the invention can be applied to cloud technology, artificial intelligence, intelligent traffic, internet of vehicles and other scenes, coordinates of each pixel point in a plane image can be mapped based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point, a curved positioning line is determined from the plane image, the distance from each pixel point to the curved positioning line is calculated, the coordinate weight corresponding to each pixel point is calculated based on the curved type and the distance of the image, the curved surface mapping coordinate value of each pixel point is calculated according to the coordinate weight and the initial coordinate values of each pixel point, the position increment between the curved surface mapping coordinate value and the initial coordinate values is calculated, a new curved surface mapping matrix is generated based on the position increment and the curved surface mapping matrix, the steps are returned to be executed until the mapping end condition is reached, and a target curved surface image is generated based on the curved surface mapping coordinate values and the pixel values of each pixel point; the generation efficiency of the curved surface image can be improved.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a curved image generating method, a curved image generating device, an electronic device, and a storage medium.
Background
With the development of current technology, methods for content detection in images are also becoming more and more mature. However, the existing method for detecting the image content basically detects the image on the premise of taking the image as a plane image by default, and ignores the influence of factors such as content deformation and the like existing in the curved image. Therefore, more and more researchers need more curved surface images to test so as to improve the accuracy of content detection.
At present, the main method adopted in the generation of curved surface images is to perform curved surface transformation on pictures with planar effects through a curve equation preset by a technician. By adopting the scheme, the curved surface transformation has single effect, if complex curved surface effect is to be realized, a technician is required to perform multiple transformation operations through the same curved surface equation, and the generation efficiency of the curved surface image is low.
Disclosure of Invention
The embodiment of the invention provides a curved surface image generation method, a curved surface image generation device, electronic equipment and a storage medium, which can realize various curved surface conversion effects and improve the generation efficiency of curved surface images.
The embodiment of the invention provides a curved surface image generation method, which comprises the following steps:
Obtaining a plane image, and mapping coordinates of each pixel point in the plane image based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
Determining a bending locating line when the planar image is bent from the planar image, and calculating the distance between each pixel point and the bending locating line;
Calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance;
Calculating a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
Calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to the step of performing the mapping on the coordinates of each pixel point in the planar image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the planar image in a curved surface coordinate system until the mapping ending condition is reached;
and generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
Correspondingly, the embodiment of the invention also provides a curved surface image generating device, which comprises:
The coordinate mapping unit is used for obtaining a plane image, mapping the coordinates of each pixel point in the plane image based on a curved surface mapping matrix, and obtaining initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
A distance calculating unit for determining a curved positioning line when the planar image is curved from the planar image, and calculating a distance from each pixel point to the curved positioning line;
the weight calculation unit is used for calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance;
A curved surface coordinate calculation unit, configured to calculate a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
the matrix updating unit is used for calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to the step of executing the mapping of the coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the plane image in a curved surface coordinate system until a mapping ending condition is reached;
and the curved surface image generating unit is used for generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
Optionally, the curved surface image generating unit is configured to determine a neighborhood range using each pixel point as a neighborhood center based on a curved surface mapping coordinate value of each pixel point and a preset neighborhood distance;
a neighborhood center is taken as a target neighborhood center, a neighborhood pixel point in a neighborhood range corresponding to the target neighborhood center is determined, and a target pixel value of the target neighborhood center is calculated according to the distance between each neighborhood pixel point and the target neighborhood center and the pixel value of each neighborhood pixel point;
returning to the step of taking a neighborhood center as a target neighborhood center until the target pixel value of each neighborhood center is obtained;
And generating a target curved surface image according to the curved surface mapping coordinate values of the centers of the target neighborhood and the target pixel values.
Optionally, the image bending type includes an upper convex bending type, a lower concave bending type, and a folding bending type;
The weight calculation unit is used for calculating an upward convex parameter corresponding to each pixel point as a coordinate weight according to the distance corresponding to each pixel point and a preset bending index when the image bending type is an upward convex bending type; or alternatively
When the image bending type is a concave bending type, calculating a concave parameter corresponding to each pixel point as a coordinate weight according to the distance corresponding to each pixel point and a preset bending index; or alternatively
When the image bending type is a folding bending type, calculating folding parameters corresponding to the pixel points as coordinate weights according to the distance corresponding to the pixel points and a preset bending index.
Optionally, the curved surface generating device provided by the embodiment of the invention further includes a plane image generating unit, configured to receive an image generating instruction, where the image generating instruction includes image size information and text information;
generating an initial image canvas according to the image size information;
determining text typesetting information of the initial image canvas based on the image size information;
according to the text typesetting information, the preset character size and the character spacing, dividing the text information into texts to obtain divided texts;
And generating a content map according to the divided text, and adding the content map to the initial image canvas to obtain a plane image.
Optionally, the curved surface generating device provided by the embodiment of the present invention further includes a binary image generating unit, configured to determine, based on the curved surface mapping coordinate values of each pixel point and a preset neighborhood distance, a neighborhood range using each pixel point as a neighborhood center;
determining initial coordinate values corresponding to the neighborhood centers in the plane image and initial neighborhood ranges corresponding to the neighborhood ranges in the plane image according to the curved surface mapping matrix;
taking a neighborhood center as a target neighborhood center, determining an initial neighborhood pixel point in an initial neighborhood range corresponding to the target neighborhood center, and taking a pixel value of the initial neighborhood pixel point with the minimum distance between the initial neighborhood pixel point and an initial coordinate value of the target neighborhood center as a reference pixel value of the target neighborhood center;
Returning to the step of taking a neighborhood center as a target neighborhood center until the reference pixel value of each neighborhood center is obtained;
And generating a text region binary image corresponding to the target curved surface image according to the reference pixel value of each target neighborhood center.
Optionally, the curved surface generating device provided by the embodiment of the present invention further includes a text labeling unit, configured to determine an adding position of each content map in the initial image canvas, and a divided text corresponding to each content map;
Determining the mapping position of each content map in the target curved surface image according to the curved surface mapping matrix and each adding position;
And generating text labels of the target curved surface image based on the mapping positions and the divided texts corresponding to the content maps.
Optionally, the curved surface generating device provided by the embodiment of the invention further includes a network training unit, configured to obtain a content detection network to be trained, where the content detection network is configured to detect the content of the curved surface image;
Performing content detection on the target curved surface image through the content detection network to be trained to obtain detection content information;
Calculating the detection loss of the content detection network to be trained based on the detection content information and the text labels of the target curved surface images;
And adjusting network parameters of the content detection network to be trained according to the detection loss to obtain the trained content detection network.
Correspondingly, the embodiment of the invention also provides electronic equipment, which comprises a memory and a processor; the memory stores an application program, and the processor is configured to run the application program in the memory, so as to execute any step in the curved surface image generating method provided by the embodiment of the present invention.
Correspondingly, the embodiment of the invention also provides a computer readable storage medium, which stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor to execute the steps in any curved surface image generating method provided by the embodiment of the invention.
In addition, the embodiment of the invention also provides a computer program product, which comprises a computer program or instructions, wherein the computer program or instructions realize the steps in any curved surface image generation method provided by the embodiment of the invention when being executed by a processor.
By adopting the scheme of the embodiment of the invention, a plane image can be obtained, coordinates of each pixel point in the plane image are mapped based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system, a curved positioning line of each pixel point in the plane image when the plane image is curved is determined from the plane image, the distance from each pixel point to the curved positioning line is calculated, coordinate weights corresponding to each pixel point are calculated based on a preset image curved type and the distance, curved surface mapping coordinate values of each pixel point are calculated according to the coordinate weights corresponding to each pixel point and the initial coordinate values, position increment between the curved surface mapping coordinate values and the initial coordinate values is calculated, a new curved surface mapping matrix is generated based on the position increment and the curved surface mapping matrix, and the step of mapping the coordinates of each pixel point in the plane image based on the curved surface mapping matrix is performed to obtain the initial coordinate values of each pixel point in the curved surface coordinate system until a mapping end condition is reached, and a target curved surface image is generated based on the curved surface mapping coordinate values of each pixel point; in the embodiment of the invention, after the curved surface transformation is carried out on the image, the curved surface mapping matrix can be updated according to the curved surface mapping coordinate values and the initial coordinate values after the curved surface transformation, so that various curved surface transformation effects can be realized through continuous updating of the curved surface mapping matrix, the curved surface image with more complex curved surface effects can be quickly constructed, and the generation efficiency of the curved surface image is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of a curved image generating method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a curved image generation method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a curved image generation process according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a curved image generation process according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a text region binary image provided by an embodiment of the present invention;
FIG. 6 is another schematic flow chart of a curved image generating method according to an embodiment of the present invention;
Fig. 7 is a schematic structural diagram of a curved image generating device according to an embodiment of the present invention;
fig. 8 is another schematic structural diagram of a curved image generating device according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
The embodiment of the invention provides a curved surface image generation method, a curved surface image generation device, electronic equipment and a computer readable storage medium. Specifically, the embodiment of the invention provides a curved surface image generation method suitable for a curved surface image generation device, and the curved surface image generation device can be integrated in electronic equipment.
The electronic device may be a terminal or the like, including but not limited to a mobile terminal and a fixed terminal, for example, a mobile terminal including but not limited to a smart phone, a smart watch, a tablet computer, a notebook computer, a smart car, etc., wherein the fixed terminal includes but not limited to a desktop computer, a smart television, etc.
The electronic device may be a server, which may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network ), and basic cloud computing services such as big data and artificial intelligence platform, but is not limited thereto.
The curved surface image generation method of the embodiment of the invention can be realized by a server or a terminal and the server together.
The curved image generation method is described below by taking a method in which a terminal and a server together implement the method.
As shown in fig. 1, a curved image generating system provided by an embodiment of the present invention includes a terminal 10, a server 20, and the like; the terminal 10 and the server 20 are connected through a network, for example, a wired or wireless network connection, etc., wherein the terminal 10 may exist as a terminal that transmits a planar image to the server 20.
The terminal 10 may upload a planar image for a user who needs to generate a curved image, and is configured to transmit the planar image to the server 20.
The server 20 may be configured to obtain a planar image, map coordinates of each pixel point in the planar image based on a curved surface mapping matrix, obtain initial coordinate values of each pixel point in the planar image in a curved surface coordinate system, determine a curved positioning line when the planar image is curved from the planar image, calculate a distance from each pixel point to the curved positioning line, calculate coordinate weights corresponding to each pixel point based on a preset image curved type and distance, and calculate curved surface mapping coordinate values of each pixel point according to the coordinate weights and the initial coordinate values corresponding to each pixel point.
The server 20 may calculate a position increment between the curved surface mapping coordinate value and the initial coordinate value, generate a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and return to perform the step of mapping the coordinates of each pixel point in the planar image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the planar image in the curved surface coordinate system until reaching the mapping end condition, and generate the target curved surface image based on the curved surface mapping coordinate value of each pixel point and the pixel value of each pixel point.
The following will describe in detail. The following description of the embodiments is not intended to limit the preferred embodiments.
The embodiments of the present invention will be described from the perspective of a curved image generating apparatus, which may be integrated in a server or a terminal in particular.
As shown in fig. 2, the specific flow of the curved surface image generating method of the present embodiment may be as follows:
201. And (3) obtaining a plane image, and mapping coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system.
The planar image is an image that needs to be converted into a curved image. Specifically, the content in the planar image may include only text, may include only non-text content such as characters and scenery, or may be a combination of text and non-text content, and the embodiment of the present invention does not limit the image content of the planar image.
For example, the planar image may be an image of a page of text, or the planar image may be a portrait of a person, or the planar image may include a picture therein and parsing of the picture, etc.
The curved surface mapping matrix may be used to map coordinates of each pixel point in the coordinate system where the planar image is located in the planar image to coordinates in the curved surface coordinate system where the target curved surface image to be generated is located.
For example, in the coordinate system where the plane image is located, each pixel point in the plane image is an integer coordinate, and in the curved surface coordinate system is a floating point coordinate, at this time, the integer coordinate of each pixel point in the plane image may be mapped based on the curved surface mapping matrix, so as to obtain an initial coordinate value corresponding to each pixel point in the plane image in the curved surface coordinate system.
It will be appreciated that the floating point coordinate is actually a logical coordinate, and it is required to correspond to the actual device through a mapping relationship when actually displayed. For example, if a pixel point is in the coordinate system of integer coordinates, the pixel point may be displayed at the position of (4, 1), and the floating point coordinates after coordinate conversion may be (4,1.15), but when displaying, the actually required coordinate point (4,1.15) may be displayed at the position of (400, 115) of the curved surface coordinate system. At this time, the initial coordinate value is (400, 115).
In some alternative examples, the curved surface mapping matrix when mapping the coordinates of each pixel point in the planar image for the first time may be randomly initialized, or may be a full 1 matrix, or the curved surface mapping matrix may be set by a technician corresponding to different image bending types.
For example, a technician may set four different curved surface mapping matrices for four image bending types, up convex bending, down concave bending, up folding, and down folding, respectively.
Specifically, the dimension of the curved surface mapping matrix is h×w, where H is the height of the planar image and W is the width of the planar image.
It should be noted that the curved surface coordinate system is not a three-dimensional coordinate system, but is still a two-dimensional coordinate system of a plane, but the coordinate system in which the curved surface coordinate system and the plane image originally exist may be different from each other in terms of coordinate description of the same coordinate point.
202. And determining a bending locating line of the planar image during bending, and calculating the distance from each pixel point to the bending locating line.
The curved positioning line is a line segment or a straight line which needs to be referred when the planar image is curved. Specifically, the curved positioning line may be preset, or may be randomly determined when each time of the planar image is curved.
For example, the technician may designate in advance a straight line passing through the planar image, which is a curved alignment line of y=2x. Or the curved alignment line may be any randomly determined straight line passing through the planar image.
For another example, in determining the curved positioning line, the initial point p may be randomly selected in the area where the planar image is located, and the other point v may be randomly selected in any direction (for example, a diagonal direction, a horizontal or vertical direction, etc.). The curved positioning line may be a straight line pv or a line segment pv.
When calculating the distance between each pixel point and the curved positioning line, the vertical distance, normalized distance or Euclidean distance between each pixel point and the straight line pv or the straight line where the line pv is located is calculated.
Taking the plane text diagram with the width of 1280 x 720 as an example, the point p can be randomly selected in the pixel range of the horizontal direction [200,520] and the vertical direction [400,800], and the point v can be randomly selected in the horizontal increment of the point p [ -50, -25] [25,50], the vertical increment of the point p [ -100, -50] [50,100 ].
The method and the device for determining the curved positioning line and the calculated distance can be determined according to the coordinates of each pixel point in the plane image in a coordinate system where the plane image is located or according to the initial coordinate values of each pixel point in a curved surface coordinate system, the method and the device are not limited, and a technician can select according to actual conditions. Generally, the scheme of adopting the initial coordinate value of each pixel point in the curved surface coordinate system can reduce calculation errors and improve the accuracy of image bending.
203. And calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance.
In the embodiment of the invention, in order to make each bending of the image more closely approximate to the bending effect in the display life, a plurality of different image bending types are set.
In some optional embodiments, the image bending types may include an up convex bending type, a down concave bending type, and a folding bending type, and the step of calculating the coordinate weight corresponding to each pixel point based on the image bending type and the axis distance may specifically include:
When the image bending type is an upward convex bending type, according to the distance corresponding to each pixel point and a preset bending index, calculating upward convex parameters corresponding to each pixel point as coordinate weights; or alternatively
When the image bending type is a concave bending type, calculating a concave parameter corresponding to each pixel point as a coordinate weight according to the distance corresponding to each pixel point and a preset bending index; or alternatively
When the image bending type is a folding bending type, calculating folding parameters corresponding to the pixel points as coordinate weights according to the distance corresponding to the pixel points and a preset bending index.
Specifically, the upward-convex parameter corresponding to each pixel point may be ω=1-d α, where d is a vertical parameter corresponding to each pixel point and α is a preset bending index. For example, the value range of α under the bending type (convex bending and concave bending) may be [0.8,2.8]. The dip parameter corresponding to each pixel point may be ω= 1+d α. The folding parameter corresponding to each pixel point may be ω=α/(d+α), for example, in the folding type (fold up or fold down), the value range of α may be [0.4,0.9].
It can be understood that the value range of α can be adjusted by a technician according to the actual bending effect, and the specific value of α is not limited in the embodiment of the present invention.
In the related art, to realize the transformation from a planar image to a curved image, the original coordinates of the planar image are generally transformed directly by a transformation equation preset by a technician, so as to obtain the coordinates corresponding to each point in the planar image under the curved effect. With this approach, however, a single transformation equation is relied upon for mapping during the transformation process. If complex curved surface effects are desired, such as the effect of a crumpled sheet of paper concavely curved, this cannot be achieved by a single transformation equation.
In the embodiment of the invention, a plurality of different bending types are arranged, when complex curved surface effects are required to be realized, the images can be mapped by selecting the corresponding bending types, and the curved surface images are more various in generating effect.
204. And calculating the curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point.
In the embodiment of the invention, the initial coordinate value of each pixel point can be directly multiplied by the coordinate weight to obtain the curved surface mapping coordinate value of each pixel point. Or the initial coordinate value of each pixel point may be multiplied by a coordinate weight, and the product result may be added to a certain parameter, or the initial coordinate value and the coordinate weight may be used as the curved surface mapping coordinate value, or the like.
In some optional examples, the calculation manners of the curved surface mapping coordinate values corresponding to different image bending types may be the same or different.
And the initial coordinate value of each pixel point can be adaptively adjusted through the coordinate weight in the process of determining the curved surface mapping coordinate value through the coordinate weight and the initial coordinate value. The larger the value of the bending index α, the larger the influence of the coordinate weight on the initial coordinate value for the same coordinate point.
For example, the initial coordinate value corresponding to a certain pixel point may be [100, 120], the distance is 10, the image bending type is convex bending, and the preset bending index α=1.0. At this time, the coordinate weight is the upward convex parameter ω= -9. If the curved surface map coordinate value is calculated by adding the initial coordinate value and the coordinate weight, the curved surface map coordinate value is [101, 111].
205. Calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to perform the step of mapping the coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the plane image in the curved surface coordinate system until the mapping ending condition is reached.
The mapping end condition may be the number of loop executions (the number of distortions to the image) preset by the technician, for example, 2 or 4 times. Or the mapping end condition may be that the position increment of each pixel point is smaller than a preset increment threshold, for example, 0.01. Or the mapping end condition may be that the curvature of the image reaches a certain degree. The re-or mapping end condition may also be manual end of mapping, etc.
Because in the embodiment of the invention, the curved surface mapping matrix can be adaptively adjusted according to the position increment before each mapping, a technician is not required to manually modify the curved surface mapping matrix. In the related art, due to the dependence on a single transformation equation, if a certain curved surface effect is to be achieved, a technician is required to manually adjust parameters of the transformation equation.
For example, to achieve the effect of 37 degrees of upper convex curvature, in the embodiment of the present invention, only the corresponding mapping end condition needs to be set, and a related technical scheme is adopted, so that a technician is required to continuously test which specific parameter can achieve the effect. Therefore, the embodiment of the invention has higher construction efficiency when constructing the curved surface picture.
Specifically, as shown in fig. 3, the position increment of a pixel point along the horizontal and vertical directions after mapping can be calculated according to the curved surface mapping coordinate value and the initial coordinate value of the pixel point, and the curved surface mapping matrix can be updated according to the position increment of each pixel point.
For example, as shown in fig. 3, the position increment of a certain pixel point may be the original increment of the pixel point added with the coordinate weight of the pixel point x the distance from the pixel point to the straight line pv in the mapping process, and so on. Parameters related to the mapping times and the like can be set in the position increment, for example, the position increment of a certain pixel point can be the original increment of the pixel point added with the coordinate weight of the pixel point multiplied by the distance between the pixel point and a straight line pv in the mapping process, and the reciprocal of the current mapping times (for example, the current mapping process is the 6 th mapping to a certain plane image, and the reciprocal of the current mapping times at the moment is 1/6). The embodiment of the present invention is not limited thereto.
In the process of circularly executing steps 201 to 204, the curved positioning lines may be the same straight line or line segment each time, or may be randomly determined each time. In addition, the image bending type may be the same or different each time.
206. And generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
When the target curved surface image is generated, the color of the plane image can be still reserved, and the original pixel value of each pixel point is directly used as the pixel value in the target curved surface image. Or in order to save the storage space or realize the black-and-white processing effect, binarization processing can be performed according to the original pixel value of each pixel point, so as to obtain a target curved surface image with black-and-white color.
In some alternative embodiments, to avoid errors in pixel values, a weighted difference process may be performed on the pixel values for each pixel point. The step of generating the target curved surface image based on the curved surface mapping coordinate values of each pixel point and the pixel values of each pixel point may specifically include:
Determining a neighborhood range taking each pixel point as a neighborhood center based on the curved surface mapping coordinate value of each pixel point and a preset neighborhood distance;
A neighborhood center is taken as a target neighborhood center, neighborhood pixel points in a neighborhood range corresponding to the target neighborhood center are determined, and a target pixel value of the target neighborhood center is calculated according to the distance between each neighborhood pixel point and the target neighborhood center and the pixel value of each neighborhood pixel point;
returning to execute the step of taking a neighborhood center as a target neighborhood center until the target pixel value of each neighborhood center is obtained;
And generating a target curved surface image according to the curved surface mapping coordinate values of the centers of the target neighborhoods and the target pixel values.
The neighborhood distance may be a preset value, for example, the neighborhood distance may be euclidean distance=1, and the neighborhood range with the pixel point a as the neighborhood center may be a region range with the euclidean distance between the pixel point a and the neighborhood range with the euclidean distance of 1.
Wherein, the neighborhood pixel point is a pixel point in the neighborhood range. The neighborhood center is the pixel point in the neighborhood range center. For example, with pixel A, B, C, the neighborhood distance may be 2, and in the embodiment of the present invention, pixel A, B, C is used as the neighborhood center. A neighborhood range with the pixel point a as the neighborhood center is a circular area with the pixel point a as the center of the circle, 2 as the radius, and the like.
For example, according to the curved surface mapping coordinate values of each pixel point, the point set attribute of the pixel point set of the original image contained in the neighborhood of each pixel point of the curved surface text can be obtained. Wherein, the neighborhood of the pixel point refers to a neighborhood range with the pixel point as a center and the Euclidean distance between the pixel point and the neighborhood range being 1; the point set attributes include: a pixel value val i for each point in the set of points, and the Euclidean distance dist i from each point in the set of points to the center pixel point of the region.
According to the obtained point set of each curved text pixel point, the weighted average value val mean is calculated by taking the inverse of the distance as a weight value, and the calculation mode is val mean=(∑vali/disti)/(∑1/disti.
And rounding down the weighted average value corresponding to each curved text pixel point to obtain an interpolation result of the pixel point.
In some alternative embodiments, if a curved image with specific text content is desired, a flat image may be generated from the text content. Before the step of acquiring the plane image, the curved surface image generating method provided by the embodiment of the invention further may include:
receiving an image generation instruction, wherein the image generation instruction comprises image size information and text information;
generating an initial image canvas according to the image size information;
determining text typesetting information of an initial image canvas based on the image size information;
According to the text typesetting information, the preset character size and the character spacing, dividing the text information into texts to obtain divided texts;
And generating a content map according to the divided text, and adding the content map to an initial image canvas to obtain a plane image.
That is, as shown in fig. 4, an initial canvas (e.g., with an aspect ratio of 1280 x 720) with a corresponding size may be generated according to the image size information, and then text information (original corpus) is read line by line for processing, where the text information may be derived from english novels or articles, etc., so that the original corpus is generally divided according to paragraphs.
When the text information is subjected to text division, judging whether the current text exceeds the maximum length which can be displayed in one line according to the configured character size and the spacing, and if so, dividing the text into a plurality of lines; after the text division is completed, generating one or more lines of maps of the divided text, and sequentially placing the maps on an initial image canvas.
In some examples, if the text currently being processed is the last line, saving the canvas and exiting after processing is complete, resulting in a flat image; otherwise, judging whether the current canvas is full, if so, generating a new initial canvas and repeating the operation.
In the practical application process, if the curved image needs to be used in a model training process and the like, a binary image marked with a content area may be needed. Therefore, in some optional embodiments, the curved surface image generating method provided by the embodiment of the present invention may further include:
Determining a neighborhood range taking each pixel point as a neighborhood center based on the curved surface mapping coordinate value of each pixel point and a preset neighborhood distance;
According to the curved surface mapping matrix, determining initial coordinate values corresponding to the centers of all the neighborhoods in the planar image and initial neighborhood ranges corresponding to all the neighborhood ranges in the planar image;
Taking a neighborhood center as a target neighborhood center, determining an initial neighborhood pixel point in an initial neighborhood range corresponding to the target neighborhood center, and taking a pixel value of the initial neighborhood pixel point with the minimum distance between the initial neighborhood pixel point and an initial coordinate value of the target neighborhood center as a reference pixel value of the target neighborhood center;
returning to execute the step of taking a neighborhood center as a target neighborhood center until the reference pixel value of each neighborhood center is obtained;
And generating a text region binary image corresponding to the target curved surface image according to the reference pixel value of each target neighborhood center.
The definition of the neighborhood center and the neighborhood range is the same as the definition of the neighborhood, and the embodiments of the present invention are not described herein. The initial neighborhood range is a corresponding interval range of the neighborhood range in the planar image, for example, when the pixel point A in the curved surface image is taken as a neighborhood center, the corresponding neighborhood range is a circular area taking the coordinates (1, 1) as a circle center and taking 1 as a radius, and the initial neighborhood range corresponding to the neighborhood range may be a circular area taking the coordinates (0.8,1.2) as a circle center and taking 1.1 as a radius in the planar image, and the like.
It will be appreciated that, due to the change in the coordinate values of the pixels in the planar image and the curved image caused by the mapping, the coordinate values of the pixels in the initial neighborhood may be different from the coordinate values of the pixels in the neighborhood, and the shape and size of the initial neighborhood may be different from the neighborhood.
That is, in the embodiment of the present invention, the pixel value of the pixel point of the planar image closest to the corresponding pixel point in the neighborhood of each pixel point mapped to the curved image may be used as the reference pixel value according to the generated curved mapping matrix; and taking the reference pixel value corresponding to each curved text pixel point as an interpolation result of the pixel point.
Taking the example that the plane image and the curved surface image comprise n lines of texts, a text region binary image corresponding to the target curved surface image can be shown in fig. 5.
In the practical application process, if the curved image needs to be used in the processes of model training and the like, the content marking with specific image content may be needed. Therefore, taking the image content as a text as an example, the curved surface image generating method provided by the embodiment of the invention may further include:
determining the adding position of each content map in the initial image canvas and the divided text corresponding to each content map;
Determining the mapping position of each content map in the target curved surface image according to the curved surface mapping matrix and each adding position;
And generating text labels of the target curved surface image based on the mapping positions and the divided texts corresponding to the content maps.
In the related art, if line-level text labeling of a curved text image is to be implemented, it is necessary to perform line division on text in a generated curved text image and perform text recognition based on the line division, so that labeling of the image can be implemented. However, in the embodiment of the invention, since the plane text pictures are generated line by line, the position and the text label of each line can be naturally obtained in the generation process, and the target curved surface image labeled with the text can be obtained.
In some optional embodiments, the curved surface image generating method provided by the embodiment of the present invention may further include: acquiring a content detection network to be trained, wherein the content detection network is used for detecting the content of the curved surface image;
Performing content detection on the target curved surface image through a content detection network to be trained to obtain detection content information;
Calculating the detection loss of the content detection network to be trained based on the detection content information and the text labels of the target curved surface images;
and adjusting network parameters of the content detection network to be trained according to the detection loss to obtain the trained content detection network.
The construction process of the content detection network relies on Computer Vision technology (CV), which is a science for researching how to make a machine "see", and further means that a camera and a Computer are used to replace human eyes to perform machine Vision such as identification and measurement on a target, and further perform graphic processing, so that the Computer is processed into an image more suitable for human eyes to observe or transmit to an instrument for detection. As a scientific discipline, computer vision research-related theory and technology has attempted to build artificial intelligence systems that can acquire information from images or multidimensional data. Computer vision techniques typically include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content/behavior recognition, three-dimensional object reconstruction, 3D techniques, virtual reality, augmented reality, synchronous positioning, and map construction, among others, as well as common biometric recognition techniques such as face recognition, fingerprint recognition, and others.
The target curved surface image generated by the embodiment of the invention can be used for training an OCR algorithm model, and specific application scenes include but are not limited to character detection and recognition of the curved surface image, character detection and recognition of a commodity label, restoration of the curved surface image and the like.
As can be seen from the foregoing, the embodiment of the present invention may obtain a planar image, map coordinates of each pixel point in the planar image based on a curved surface mapping matrix, obtain an initial coordinate value of each pixel point in the planar image in a curved surface coordinate system, determine a curved positioning line when the planar image is curved from the planar image, calculate a distance from each pixel point to the curved positioning line, calculate a coordinate weight corresponding to each pixel point based on a preset image curved type and distance, calculate a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point, calculate a position increment between the curved surface mapping coordinate value and the initial coordinate value, generate a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and return to execute a step of mapping coordinates of each pixel point in the planar image based on the curved surface mapping matrix, to obtain an initial coordinate value of each pixel point in the curved surface coordinate system, until a mapping end condition is reached, and generate a target curved surface image based on the curved surface mapping coordinate value of each pixel point and the pixel point; in the embodiment of the invention, after the curved surface transformation is carried out on the image, the curved surface mapping matrix can be updated according to the curved surface mapping coordinate values and the initial coordinate values after the curved surface transformation, so that various curved surface transformation effects can be realized through continuous updating of the curved surface mapping matrix, the curved surface image with more complex curved surface effects can be quickly constructed, and the generation efficiency of the curved surface image is improved.
The method described in the previous examples is described in further detail below by way of example.
In this embodiment, a description will be given with reference to the system of fig. 1.
As shown in fig. 6, the curved surface image generating method of the present embodiment may specifically include the following steps:
601. The terminal receives the image size information and the text information, generates an initial image canvas according to the image size information, and determines text typesetting information of the initial image canvas based on the image size information.
Firstly, generating initial canvas with corresponding size (such as height and width are 800 x 600) according to the image size information, and determining the maximum length that each line of text in the initial canvas can be displayed, the maximum number of lines that each line of text can be displayed and the like, namely text typesetting information
602. The terminal divides the text information into texts according to the text typesetting information, the preset character size and the character spacing to obtain divided texts, generates a content map according to the divided texts, and adds the content map to an initial image canvas to obtain a plane image.
The terminal can read text information line by line for processing, and the text information is generally derived from English novels or articles, so that the original text information is generally divided according to paragraphs.
When each line of text information is processed, whether the text information of the current line exceeds the maximum length which can be displayed by each line of text in the initial canvas or not can be judged according to the configured font size and the interval, and if so, the text information of the current line is divided into a plurality of lines.
After the division of the text information is completed, one or more lines of content maps may be generated based on the API provided by Pygame and placed on the initial image canvas in the order of text. If the current text information is the last line, the canvas is saved and exited after the processing is completed, otherwise, whether the current canvas is full is judged, if so, a new initial canvas is generated and the operation is repeated.
In the embodiment of the invention, in order to improve the authenticity of data, after the generation of the initial planar image is completed, the data enhancement operation (for example, the data enhancement operation can be realized through an API provided by Imgaug) can be performed on the initial planar image, and specifically, background replacement, random noise addition, brightness modification, blurring processing and the like are included, so that the planar image is obtained.
603. The terminal sends the planar image to the server, the server acquires the planar image, and maps the coordinates of each pixel point in the planar image based on the curved surface mapping matrix to obtain the initial coordinate values of each pixel point in the planar image in the curved surface coordinate system.
The server may initialize a mapping matrix, where the dimensions of the matrix are h×w, H, W are the height and width of the planar image, and the matrix maps integer coordinates of the planar image to floating point coordinates (initial coordinate values) of the curved image.
604. The server determines a bending locating line when the plane image is bent from the plane image, and calculates the distance between each pixel point and the bending locating line.
In some alternative embodiments, the server may randomly select the initial point p from the middle area of the planar image, then randomly select another control point v along a diagonal line, a horizontal direction or a vertical direction, and calculate the distance between all pixels of the planar text image and the straight line pv, taking the aspect ratio of the planar text image as 1280×720 as an example, randomly select the point p in the horizontal direction [200,520] and the vertical direction [400,800] within the pixel range, and randomly select the point v in the horizontal increment [ -50, -25] [25,50], the vertical increment [ -100, -50] [50,100] of the point p.
605. The server calculates the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance.
The server calculates the weight omega according to the selected basic mapping type, and the scheme comprises three basic mapping types of upward convex, downward concave bending and folding: the weight calculation mode of the upward convex curvature is that omega=1-d α; the weight calculation mode of the concave curve is that ω= 1+d α; the fold weight is calculated in such a way that ω=α/(d+α). Alpha in the formula is a super parameter set by human, when the basic mapping type is bending, the value range of alpha is [0.82.8], and when the basic mapping type is folding, the value range of alpha is [0.4,0.9].
606. And the server calculates the curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point.
607. The server calculates the position increment between the curved surface mapping coordinate value and the initial coordinate value, generates a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returns to execute the steps 603-606 until the mapping end condition is reached.
The server may calculate the position increment along the horizontal and vertical directions after the warping, update the surface mapping matrix according to the position increment, and repeat steps 603-606 until the maximum number of warping times is reached.
608. The server generates a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
Specifically, the server may obtain coordinates of the planar image mapped onto the curved image according to the generated curved mapping matrix, and then obtain the point set attribute of the original pixel point set of the planar image contained in the neighborhood of each pixel point of the curved image. Wherein, the neighborhood of the pixel point refers to a neighborhood range with the pixel point as a center and the Euclidean distance between the pixel point and the neighborhood range being 1; the point set attributes include: pixel value vali for each point in the set of points, euclidean distance disti for each point in the set of points to the center pixel point of the region.
According to the obtained point set of each curved text pixel point, a weighted average valmean is calculated by taking the inverse of the distance as a weight, wherein the calculation mode is valmean = (Σ vali/disti)/(Σ1/disti). And (3) rounding down the weighted average value corresponding to the pixel point in each curved surface image to obtain an interpolation result of the pixel point.
609. The server determines the location of the addition of each content map in the initial image canvas and the corresponding divided text of each content map.
610. The server generates a text region binary image of the target curved surface image based on the adding position of each content map in the initial image canvas, and generates a text label of the target curved surface image based on the divided text corresponding to each content map.
Because the plane image is generated row by row, the position and text label of each row can be naturally obtained in the generation process, and the binary image labeled with the text region can be obtained.
As can be seen from the above, in the embodiment of the present invention, since the curved surface mapping matrix can be updated according to the curved surface mapping coordinate values and the initial coordinate values after the curved surface transformation is performed on the image each time, multiple curved surface transformation effects can be achieved through continuous updating of the curved surface mapping matrix, a curved surface image with a more complex curved surface effect can be quickly constructed, the generation efficiency of the curved surface image is improved, and meanwhile, the text line level data annotation can be obtained.
In order to better implement the method, correspondingly, the embodiment of the invention also provides a curved surface image generation device.
Referring to fig. 7, the apparatus includes:
the coordinate mapping unit 701 may be used to obtain a planar image, and map coordinates of each pixel point in the planar image based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the planar image in a curved surface coordinate system;
A distance calculating unit 702, configured to determine a curved positioning line when the planar image is curved from the planar image, and calculate a distance from each pixel point to the curved positioning line;
A weight calculating unit 703, configured to calculate a coordinate weight corresponding to each pixel point based on a preset image bending type and a preset distance;
The curved surface coordinate calculating unit 704 may be configured to calculate a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
The matrix updating unit 705 may be configured to calculate a position increment between the curved surface mapping coordinate value and the initial coordinate value, generate a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and return to perform a step of mapping coordinates of each pixel point in the planar image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the planar image in the curved surface coordinate system until reaching a mapping end condition;
the curved surface image generating unit 706 may be configured to generate the target curved surface image based on the curved surface mapping coordinate values of the respective pixels and the pixel values of the respective pixels.
In some optional embodiments, the curved surface image generating unit 706 may be configured to determine, based on the curved surface mapping coordinate values of each pixel point and a preset neighborhood distance, a neighborhood range with each pixel point as a neighborhood center;
A neighborhood center is taken as a target neighborhood center, neighborhood pixel points in a neighborhood range corresponding to the target neighborhood center are determined, and a target pixel value of the target neighborhood center is calculated according to the distance between each neighborhood pixel point and the target neighborhood center and the pixel value of each neighborhood pixel point;
returning to execute the step of taking a neighborhood center as a target neighborhood center until the target pixel value of each neighborhood center is obtained;
And generating a target curved surface image according to the curved surface mapping coordinate values of the centers of the target neighborhoods and the target pixel values.
In some alternative embodiments, the image bending type may include an upper convex bending type, a lower concave bending type, and a folding bending type;
the weight calculating unit 703 may be configured to calculate, when the image bending type is an upward convex bending type, an upward convex parameter corresponding to each pixel point as a coordinate weight according to a distance corresponding to each pixel point and a preset bending index; or alternatively
When the image bending type is a concave bending type, calculating a concave parameter corresponding to each pixel point as a coordinate weight according to the distance corresponding to each pixel point and a preset bending index; or alternatively
When the image bending type is a folding bending type, calculating folding parameters corresponding to the pixel points as coordinate weights according to the distance corresponding to the pixel points and a preset bending index.
In some alternative embodiments, as shown in fig. 8, the curved surface generating device provided in the embodiment of the present invention may further include a planar image generating unit 707, which may be configured to receive an image generating instruction, where the image generating instruction may include image size information and text information;
generating an initial image canvas according to the image size information;
determining text typesetting information of an initial image canvas based on the image size information;
According to the text typesetting information, the preset character size and the character spacing, dividing the text information into texts to obtain divided texts;
And generating a content map according to the divided text, and adding the content map to an initial image canvas to obtain a plane image.
In some optional embodiments, the curved surface generating device provided by the embodiments of the present invention may further include a binary image generating unit 708, configured to determine a neighborhood range using each pixel point as a neighborhood center based on the curved surface mapping coordinate values of each pixel point and a preset neighborhood distance;
According to the curved surface mapping matrix, determining initial coordinate values corresponding to the centers of all the neighborhoods in the planar image and initial neighborhood ranges corresponding to all the neighborhood ranges in the planar image;
Taking a neighborhood center as a target neighborhood center, determining an initial neighborhood pixel point in an initial neighborhood range corresponding to the target neighborhood center, and taking a pixel value of the initial neighborhood pixel point with the minimum distance between the initial neighborhood pixel point and an initial coordinate value of the target neighborhood center as a reference pixel value of the target neighborhood center;
returning to execute the step of taking a neighborhood center as a target neighborhood center until the reference pixel value of each neighborhood center is obtained;
And generating a text region binary image corresponding to the target curved surface image according to the reference pixel value of each target neighborhood center.
In some optional embodiments, the curved surface generating device provided by the embodiments of the present invention may further include a text labeling unit 709, which may be configured to determine an adding position of each content map in the initial image canvas, and a divided text corresponding to each content map;
Determining the mapping position of each content map in the target curved surface image according to the curved surface mapping matrix and each adding position;
And generating text labels of the target curved surface image based on the mapping positions and the divided texts corresponding to the content maps.
In some optional embodiments, the curved surface generating device provided in the embodiments of the present invention may further include a network training unit 710, which may be configured to obtain a content detection network to be trained, where the content detection network may be configured to detect the content of the curved surface image;
Performing content detection on the target curved surface image through a content detection network to be trained to obtain detection content information;
Calculating the detection loss of the content detection network to be trained based on the detection content information and the text labels of the target curved surface images;
and adjusting network parameters of the content detection network to be trained according to the detection loss to obtain the trained content detection network.
From the above, by the curved surface image generating device, a planar image can be obtained, coordinates of each pixel point in the planar image are mapped based on the curved surface mapping matrix, initial coordinate values of each pixel point in the planar image in the curved surface coordinate system are obtained, a curved positioning line when the planar image is curved is determined from the planar image, a distance from each pixel point to the curved positioning line is calculated, coordinate weights corresponding to each pixel point are calculated based on a preset image curved type and distance, curved surface mapping coordinate values of each pixel point are calculated according to the coordinate weights corresponding to each pixel point and the initial coordinate values, a position increment between the curved surface mapping coordinate values and the initial coordinate values is calculated, a new curved surface mapping matrix is generated based on the position increment and the curved surface mapping matrix, and the step of mapping the coordinates of each pixel point in the planar image based on the curved surface mapping matrix is performed to obtain initial coordinate values of each pixel point in the curved surface coordinate system until a mapping end condition is reached, and a target curved surface image is generated based on the curved surface mapping coordinate values of each pixel point and the pixel point; in the embodiment of the invention, after the curved surface transformation is carried out on the image, the curved surface mapping matrix can be updated according to the curved surface mapping coordinate values and the initial coordinate values after the curved surface transformation, so that various curved surface transformation effects can be realized through continuous updating of the curved surface mapping matrix, the curved surface image with more complex curved surface effects can be quickly constructed, and the generation efficiency of the curved surface image is improved.
In addition, the embodiment of the present invention further provides an electronic device, which may be a terminal or a server, as shown in fig. 9, and shows a schematic structural diagram of the electronic device according to the embodiment of the present invention, specifically:
The electronic device may include Radio Frequency (RF) circuitry 901, memory 902 including one or more computer-readable storage media, input unit 903, display unit 904, sensor 905, audio circuitry 906, wireless fidelity (WiFi, wireless Fidelity) module 907, processor 908 including one or more processing cores, and power supply 909. It will be appreciated by those skilled in the art that the electronic device structure shown in fig. 9 is not limiting of the electronic device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components. Wherein:
The RF circuit 901 may be used for receiving and transmitting signals during the process of receiving and transmitting information or communication, in particular, after receiving downlink information of a base station, the downlink information is processed by one or more processors 908; in addition, data relating to uplink is transmitted to the base station. Typically, RF circuitry 901 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a subscriber identity module (SIM, subscriber Identity Module) card, a transceiver, a coupler, a low noise amplifier (LNA, low Noise Amplifier), a duplexer, and the like. In addition, RF circuitry 901 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol including, but not limited to, global system for mobile communications (GSM, global System of Mobile communication), universal packet Radio Service (GPRS, general Packet Radio Service), code division multiple access (CDMA, code Division Multiple Access), wideband code division multiple access (WCDMA, wideband Code Division Multiple Access), long term evolution (LTE, long Term Evolution), email, short message Service (SMS, short MESSAGING SERVICE), and the like.
The memory 902 may be used to store software programs and modules that the processor 908 performs various functional applications and data processing by executing the software programs and modules stored in the memory 902. The memory 902 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device (such as audio data, phonebooks, etc.), and the like. In addition, the memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 902 may also include a memory controller to provide access to the memory 902 by the processor 908 and the input unit 903.
The input unit 903 may be used to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, in one particular embodiment, the input unit 903 may include a touch sensitive surface as well as other input devices. The touch-sensitive surface, also referred to as a touch display screen or a touch pad, may collect touch operations thereon or thereabout by a user (e.g., operations thereon or thereabout by a user using any suitable object or accessory such as a finger, stylus, etc.), and actuate the corresponding connection means according to a predetermined program. Alternatively, the touch-sensitive surface may comprise two parts, a touch detection device and a touch controller. The touch detection device detects the touch azimuth of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 908 and can receive commands from the processor 908 and execute them. In addition, touch sensitive surfaces may be implemented in a variety of types, such as resistive, capacitive, infrared, and surface acoustic waves. The input unit 903 may comprise other input devices besides a touch sensitive surface. In particular, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, mouse, joystick, etc.
The display unit 904 may be used to display information entered by a user or provided to a user as well as various graphical user interfaces of the electronic device, which may be composed of graphics, text, icons, video, and any combination thereof. The display unit 904 may include a display panel, which may optionally be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch-sensitive surface may overlay a display panel, upon detection of a touch operation thereon or thereabout by the touch-sensitive surface, being communicated to the processor 908 to determine the type of touch event, and the processor 908 then provides a corresponding visual output on the display panel based on the type of touch event. Although in fig. 9 the touch sensitive surface and the display panel are implemented as two separate components for input and output functions, in some embodiments the touch sensitive surface may be integrated with the display panel to implement the input and output functions.
The electronic device may also include at least one sensor 905, such as a light sensor, a motion sensor, and other sensors. In particular, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel according to the brightness of ambient light, and a proximity sensor that may turn off the display panel and/or backlight when the electronic device is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the acceleration in all directions (generally three axes), and can detect the gravity and the direction when the mobile phone is stationary, and can be used for applications of recognizing the gesture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and knocking), and the like; other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that may also be configured with the electronic device are not described in detail herein.
Audio circuitry 906, speakers, and a microphone may provide an audio interface between the user and the electronic device. The audio circuit 906 may transmit the received electrical signal after audio data conversion to a speaker, which converts the electrical signal to a sound signal for output; on the other hand, the microphone converts the collected sound signals into electrical signals, which are received by the audio circuit 906 and converted into audio data, which are processed by the audio data output processor 908 for transmission to, for example, another electronic device via the RF circuit 901, or which are output to the memory 902 for further processing. The audio circuitry 906 may also include an ear bud jack to provide communication of the peripheral headphones with the electronic device.
WiFi belongs to a short-distance wireless transmission technology, and the electronic equipment can help a user to send and receive emails, browse webpages, access streaming media and the like through a WiFi module 907, so that wireless broadband Internet access is provided for the user. Although fig. 9 shows a WiFi module 907, it is to be understood that it does not belong to the necessary constitution of the electronic device, and can be omitted entirely as required within a range that does not change the essence of the invention.
The processor 908 is a control center of the electronic device, connects various parts of the entire handset using various interfaces and lines, performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 902, and invoking data stored in the memory 902. Optionally, the processor 908 may include one or more processing cores; preferably, the processor 908 may integrate an application processor that primarily handles operating systems, user interfaces, applications, etc., with a modem processor that primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 908.
The electronic device also includes a power supply 909 (e.g., a battery) that provides power to the various components, preferably in logical communication with the processor 908 via a power management system, to enable management of charge, discharge, and power consumption by the power management system. The power supply 909 may also include one or more of any of a direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, the electronic device may further include a camera, a bluetooth module, etc., which will not be described herein. In particular, in this embodiment, the processor 908 in the electronic device loads executable files corresponding to the processes of one or more application programs into the memory 902 according to the following instructions, and the processor 908 executes the application programs stored in the memory 902, so as to implement various functions as follows:
Acquiring a plane image, and mapping coordinates of each pixel point in the plane image based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
Determining a bending locating line of the plane image during bending, and calculating the distance from each pixel point to the bending locating line;
calculating coordinate weights corresponding to all pixel points based on preset image bending types and distances;
calculating the curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
Calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to perform the step of mapping the coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the plane image in the curved surface coordinate system until the mapping ending condition is reached;
And generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present invention provides a computer readable storage medium having stored therein a plurality of instructions capable of being loaded by a processor to perform any of the steps in the curved image generating method provided by the embodiment of the present invention. For example, the instructions may perform the steps of:
Acquiring a plane image, and mapping coordinates of each pixel point in the plane image based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
Determining a bending locating line of the plane image during bending, and calculating the distance from each pixel point to the bending locating line;
calculating coordinate weights corresponding to all pixel points based on preset image bending types and distances;
calculating the curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
Calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to perform the step of mapping the coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the plane image in the curved surface coordinate system until the mapping ending condition is reached;
And generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Wherein the computer-readable storage medium may comprise: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
Because the instructions stored in the computer readable storage medium may execute the steps in any of the curved surface image generating methods provided in the embodiments of the present invention, the beneficial effects that any of the curved surface image generating methods provided in the embodiments of the present invention can be achieved, which are detailed in the previous embodiments and are not described herein.
According to one aspect of the present application, there is also provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions to cause the electronic device to perform the methods provided in the various alternative implementations of the embodiments described above.
The above description of the curved image generating method, the apparatus, the electronic device and the storage medium provided by the embodiments of the present invention applies specific examples to illustrate the principles and the implementation of the present invention, and the description of the above embodiments is only used to help understand the method and the core idea of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present invention, the present description should not be construed as limiting the present invention.
Claims (11)
1. A curved image generation method, characterized by comprising:
Obtaining a plane image, and mapping coordinates of each pixel point in the plane image based on a curved surface mapping matrix to obtain initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
Determining a bending locating line when the planar image is bent from the planar image, and calculating the distance between each pixel point and the bending locating line;
Calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance;
Calculating a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
Calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to the step of performing the mapping on the coordinates of each pixel point in the planar image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the planar image in a curved surface coordinate system until the mapping ending condition is reached;
and generating a target curved surface image based on the curved surface mapping coordinate values of the pixel points and the pixel values of the pixel points.
2. The curved surface image generating method according to claim 1, wherein said generating a target curved surface image based on the curved surface map coordinate values of each of the pixels and the pixel values of each of the pixels comprises:
determining a neighborhood range taking each pixel point as a neighborhood center based on the curved surface mapping coordinate value of each pixel point and a preset neighborhood distance;
a neighborhood center is taken as a target neighborhood center, a neighborhood pixel point in a neighborhood range corresponding to the target neighborhood center is determined, and a target pixel value of the target neighborhood center is calculated according to the distance between each neighborhood pixel point and the target neighborhood center and the pixel value of each neighborhood pixel point;
returning to the step of taking a neighborhood center as a target neighborhood center until the target pixel value of each neighborhood center is obtained;
And generating a target curved surface image according to the curved surface mapping coordinate values of the centers of the target neighborhood and the target pixel values.
3. The curved image generating method according to claim 1, wherein the image bending type includes an upward convex bending type, a downward concave bending type, and a folding bending type;
The calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance comprises the following steps:
When the image bending type is an upward convex bending type, calculating upward convex parameters corresponding to the pixel points as coordinate weights according to the distance corresponding to the pixel points and a preset bending index; or alternatively
When the image bending type is a concave bending type, calculating a concave parameter corresponding to each pixel point as a coordinate weight according to the distance corresponding to each pixel point and a preset bending index; or alternatively
When the image bending type is a folding bending type, calculating folding parameters corresponding to the pixel points as coordinate weights according to the distance corresponding to the pixel points and a preset bending index.
4. The curved surface image generating method according to claim 1, wherein before said obtaining the planar image, the method further comprises:
receiving an image generation instruction, wherein the image generation instruction comprises image size information and text information;
generating an initial image canvas according to the image size information;
determining text typesetting information of the initial image canvas based on the image size information;
according to the text typesetting information, the preset character size and the character spacing, dividing the text information into texts to obtain divided texts;
And generating a content map according to the divided text, and adding the content map to the initial image canvas to obtain a plane image.
5. The curved surface image generation method according to claim 4, wherein the method further comprises:
determining a neighborhood range taking each pixel point as a neighborhood center based on the curved surface mapping coordinate value of each pixel point and a preset neighborhood distance;
determining initial coordinate values corresponding to the neighborhood centers in the plane image and initial neighborhood ranges corresponding to the neighborhood ranges in the plane image according to the curved surface mapping matrix;
taking a neighborhood center as a target neighborhood center, determining an initial neighborhood pixel point in an initial neighborhood range corresponding to the target neighborhood center, and taking a pixel value of the initial neighborhood pixel point with the minimum distance between the initial neighborhood pixel point and an initial coordinate value of the target neighborhood center as a reference pixel value of the target neighborhood center;
Returning to the step of taking a neighborhood center as a target neighborhood center until the reference pixel value of each neighborhood center is obtained;
And generating a text region binary image corresponding to the target curved surface image according to the reference pixel value of each target neighborhood center.
6. The curved surface image generation method according to claim 4, wherein the method further comprises:
Determining the adding position of each content map in the initial image canvas and the divided text corresponding to each content map;
Determining the mapping position of each content map in the target curved surface image according to the curved surface mapping matrix and each adding position;
And generating text labels of the target curved surface image based on the mapping positions and the divided texts corresponding to the content maps.
7. The curved surface image generating method according to claim 6, wherein said method further comprises:
acquiring a content detection network to be trained, wherein the content detection network is used for detecting the content of the curved surface image;
Performing content detection on the target curved surface image through the content detection network to be trained to obtain detection content information;
Calculating the detection loss of the content detection network to be trained based on the detection content information and the text labels of the target curved surface images;
And adjusting network parameters of the content detection network to be trained according to the detection loss to obtain the trained content detection network.
8. A curved image generating apparatus, comprising:
The coordinate mapping unit is used for obtaining a plane image, mapping the coordinates of each pixel point in the plane image based on a curved surface mapping matrix, and obtaining initial coordinate values of each pixel point in the plane image in a curved surface coordinate system;
A distance calculating unit for determining a curved positioning line when the planar image is curved from the planar image, and calculating a distance from each pixel point to the curved positioning line;
the weight calculation unit is used for calculating the coordinate weight corresponding to each pixel point based on the preset image bending type and the distance;
A curved surface coordinate calculation unit, configured to calculate a curved surface mapping coordinate value of each pixel point according to the coordinate weight and the initial coordinate value corresponding to each pixel point;
the matrix updating unit is used for calculating the position increment between the curved surface mapping coordinate value and the initial coordinate value, generating a new curved surface mapping matrix based on the position increment and the curved surface mapping matrix, and returning to the step of executing the mapping of the coordinates of each pixel point in the plane image based on the curved surface mapping matrix to obtain the initial coordinate value of each pixel point in the plane image in a curved surface coordinate system until a mapping ending condition is reached;
And the image generation unit is used for generating a target curved surface image based on the curved surface mapping coordinate value of each pixel point and the pixel value of each pixel point.
9. An electronic device comprising a memory and a processor; the memory stores an application program, and the processor is configured to execute the application program in the memory to perform the steps in the curved image generating method according to any one of claims 1 to 7.
10. A computer readable storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the steps in the curved image generating method of any of claims 1 to 7.
11. A computer program product comprising a computer program or instructions which, when executed by a processor, implement the steps of the curved surface image generating method according to any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210179218.2A CN114581508B (en) | 2022-02-25 | 2022-02-25 | Curved surface image generation method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210179218.2A CN114581508B (en) | 2022-02-25 | 2022-02-25 | Curved surface image generation method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114581508A CN114581508A (en) | 2022-06-03 |
CN114581508B true CN114581508B (en) | 2024-10-18 |
Family
ID=81773848
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210179218.2A Active CN114581508B (en) | 2022-02-25 | 2022-02-25 | Curved surface image generation method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114581508B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113450253A (en) * | 2021-05-20 | 2021-09-28 | 北京城市网邻信息技术有限公司 | Image processing method, image processing device, electronic equipment and computer readable storage medium |
CN113819890A (en) * | 2021-06-04 | 2021-12-21 | 腾讯科技(深圳)有限公司 | Distance measuring method, distance measuring device, electronic equipment and storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9536136B2 (en) * | 2015-03-24 | 2017-01-03 | Intel Corporation | Multi-layer skin detection and fused hand pose matching |
CN111857515B (en) * | 2020-07-24 | 2024-03-19 | 深圳市欢太科技有限公司 | Image processing method, device, storage medium and electronic equipment |
-
2022
- 2022-02-25 CN CN202210179218.2A patent/CN114581508B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113450253A (en) * | 2021-05-20 | 2021-09-28 | 北京城市网邻信息技术有限公司 | Image processing method, image processing device, electronic equipment and computer readable storage medium |
CN113819890A (en) * | 2021-06-04 | 2021-12-21 | 腾讯科技(深圳)有限公司 | Distance measuring method, distance measuring device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114581508A (en) | 2022-06-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20220207821A1 (en) | Image rendering method and related apparatus, terminal and storage medium | |
CN107977674B (en) | Image processing method, image processing device, mobile terminal and computer readable storage medium | |
CN110069580B (en) | Road marking display method and device, electronic equipment and storage medium | |
US9805488B2 (en) | Method and apparatus for processing image | |
CN107193518B (en) | Information display method and terminal equipment | |
CN108846274B (en) | Security verification method, device and terminal | |
CN108205398B (en) | Method and device for adapting webpage animation to screen | |
CN105303149B (en) | The methods of exhibiting and device of character image | |
CN105989572B (en) | Picture processing method and device | |
CN110431563B (en) | Method and device for correcting image | |
CN109726368B (en) | Map marking method and device | |
CN106250080A (en) | Method for displaying image and device | |
CN109902282B (en) | Text typesetting method, text typesetting device and storage medium | |
CN113409468B (en) | Image processing method and device, electronic equipment and storage medium | |
CN111556337B (en) | Media content implantation method, model training method and related device | |
CN114581508B (en) | Curved surface image generation method and device, electronic equipment and storage medium | |
CN117292384B (en) | Character recognition method, related device and storage medium | |
CN115841575A (en) | Key point detection method, device, electronic apparatus, storage medium, and program product | |
CN113469923B (en) | Image processing method and device, electronic equipment and storage medium | |
CN113780291B (en) | Image processing method and device, electronic equipment and storage medium | |
CN108376255B (en) | Image processing method, device and storage medium | |
CN110503084B (en) | Method and device for identifying text region in image | |
CN112819938B (en) | Information processing method, device and computer readable storage medium | |
CN111523286A (en) | Picture display method and electronic equipment | |
CN112733573B (en) | Form detection method and device, mobile terminal and storage medium |
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 |