A text image splicing method, device, electronic device and storage medium
Through grayscale processing and correlation matching, the target pixel points are obtained to realize text image stitching, which solves the problems of large calculation volume and low accuracy in the prior art, and improves the stitching efficiency and accuracy.
Patent Information
- Application Number
- CN202210523876.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-14
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2042-05-14
AI Technical Summary
The existing image stitching method based on feature key point matching is problematic with large amount of calculation and low accuracy when stitching text images, especially when low resolution and fewer feature points are difficult to achieve real-time operation and accurate stitching.
By graying the initial text image, the target gradient image and the target projected image are obtained, and based on the correlation between these images and the initial text image, the target pixel points are extracted and stitched to achieve image stitching.
This method accurately captures pixel points under complex conditions, reduces the calculation amount, improves splicing efficiency and accuracy, and is suitable for text image stitching with low resolution and fewer feature points.
Smart Images

Figure CN114913070B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a text image splicing method, device, electronic device and storage medium. Background Art
[0002] Existing mosaic techniques can be roughly divided into two types: (i) Image mosaic (registration) technology based on feature key point matching, which mainly uses the overlapping areas and overlapping positions between the images to be mosaicked to perform image mosaicking. It can be roughly divided into the following steps: (1) Detect feature points in each image; (2) Calculate the matching relationship between feature points; (3) Calculate the transformation matrix between the images to be mosaicked through matching points, so that the two images are in the same coordinate system; (4) Merge the mosaicked images and process the image boundaries to complete the mosaicking.
[0003] (ii) Methods based on image feature correlation: Based on the high correlation between the overlapping areas of the two images to be stitched, the image stitching is achieved by finding the overlapping areas of the two images, such as template matching.
[0004] Existing problems: Image stitching methods based on feature key point matching, such as SURF-based image stitching methods, ORB-based image stitching methods, etc., need to first extract image features and then detect image feature points (key points), and then perform feature point matching and other steps to achieve image stitching. Then, feature extraction and feature point matching steps require a lot of calculations and are time-consuming, making it difficult to achieve real-time operation under point computing power.
[0005] Furthermore, for text images, the resolution is generally low, the content is only text, and there are fewer feature points. It is difficult to accurately capture a sufficient number of feature point matching pairs, which often affects the normal implementation of the puzzle and reduces the accuracy of the puzzle. Summary of the invention
[0006] In order to solve the above technical problem or at least partially solve the above technical problem, the present application provides a text image splicing method, device, electronic device and storage medium.
[0007] According to one aspect of an embodiment of the present application, a text image splicing method is provided, comprising:
[0008] Acquire an initial text image to be spliced, and perform grayscale processing on the initial text image to obtain a grayscale image corresponding to the initial text image;
[0009] Acquire a target gradient image corresponding to the initial text image, and acquire a target projection image corresponding to the grayscale image;
[0010] Correlation matching is performed on the grayscale image, the target gradient image, and the target projection image with the initial text image to obtain target pixel points in the grayscale image, the target gradient image, and the target projection image that match the initial text image respectively;
[0011] The target text image is obtained by performing stitching based on the target pixel points.
[0012] Furthermore, obtaining the target gradient image corresponding to the initial text image includes:
[0013] Acquire a first gradient image of the initial text image in the ordinate direction, and a second gradient image of the initial text image in the abscissa direction;
[0014] The first gradient image and the second gradient image are determined as the target gradient images.
[0015] Further, the obtaining of the target projection image corresponding to the grayscale image includes:
[0016] The projection image of the grayscale image in the horizontal coordinate direction is determined as the target projection image.
[0017] Furthermore, the grayscale image, the target gradient image, and the target projection image are respectively correlated with the initial text image to obtain target pixel points in the grayscale image, the target gradient image, and the target projection image that match the initial text image, respectively, including:
[0018] Acquire a first set of partial images extracted from the grayscale image, the target gradient image, and the target projection image according to a plurality of different preset lengths, wherein the first set of partial images includes: partial images extracted from the grayscale image, the target gradient image, and the target projection image according to each preset length;
[0019] Acquire a second set of partial images extracted from the initial text image according to a plurality of different preset lengths, wherein the second set of partial images includes: partial images extracted from the initial text image according to each preset length;
[0020] The target pixel point is obtained by comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length.
[0021] Furthermore, the obtaining of a first set of partial images extracted from the grayscale image, the target gradient image, and the target projection image according to a plurality of different preset lengths includes:
[0022] Selecting a first partial image from the grayscale image, the target gradient image, and the target projection image respectively according to a first preset length;
[0023] Calculating a sum of a first preset length and a plurality of step lengths arranged in a gradient, and determining the sum as a second preset length;
[0024] Selecting a second partial image from the grayscale image, the target gradient image, and the target projection image according to the second preset length;
[0025] The first partial image set is obtained based on the first partial image and the second partial image.
[0026] Furthermore, the step of obtaining a second set of partial images extracted from the initial text image according to a plurality of different preset lengths includes:
[0027] Selecting a third partial image from the initial text image according to a first preset length;
[0028] Calculating a sum of a first preset length and a plurality of step lengths arranged in a gradient, and determining the sum as a second preset length;
[0029] Selecting a fourth partial image from the initial text image according to the second preset length;
[0030] The second partial image set is obtained based on the third partial image and the fourth partial image.
[0031] Furthermore, the comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length to obtain the target pixel point includes:
[0032] Comparing the correlation between the local images in the first local image set at each preset length and the local images in the second local image set, to obtain candidate pixel points in each image corresponding to each preset length;
[0033] Obtaining confidences corresponding to the grayscale image, the target gradient image, the target projection image, and the initial text image respectively;
[0034] The frequency data corresponding to each candidate pixel is calculated based on the confidence level, and the candidate pixel with the highest frequency data is determined as the target pixel.
[0035] According to another aspect of the embodiment of the present application, there is also provided a text image splicing device, including:
[0036] A first acquisition module is used to acquire an initial text image to be spliced, and grayscale the initial text image to obtain a grayscale image corresponding to the initial text image;
[0037] A second acquisition module, used to acquire a target gradient image corresponding to the initial text image, and to acquire a projection image corresponding to the grayscale image;
[0038] A processing module, used for performing image correlation matching on the grayscale image, the target gradient image and the projection image with the initial text image, respectively, to obtain target pixel points in the grayscale image, the target gradient image and the projection image that match the initial text image respectively;
[0039] The splicing module is used to perform splicing based on the target pixel points to obtain a target text image.
[0040] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0041] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0042] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0043] Compared with the prior art, the above technical solution provided by the embodiment of the present application has the following advantages: the method provided by the embodiment of the present application matches the grayscale image, the gradient image and the projection image with the initial text image respectively, and performs image stitching based on the matched target pixels. In this way, the different characteristics carried by various images are used for correlation matching, and the required number of pixels can be accurately captured, so that accurate stitching can be achieved under complex conditions or backgrounds. At the same time, compared with the traditional image stitching method, the amount of calculation is small and the stitching efficiency is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A flowchart of a text image splicing method provided in an embodiment of the present application;
[0047] Figure 2 A flowchart of a text image splicing method provided by another embodiment of the present application;
[0048] Figure 3 A flowchart of a text image splicing method provided by another embodiment of the present application;
[0049] Figure 4 A block diagram of a text image splicing device provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0052] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0053] The embodiments of the present application provide a text image stitching method, device, electronic device and storage medium. The method provided by the embodiments of the present invention can be applied to any required electronic device, for example, it can be a server, terminal and other electronic devices, which are not specifically limited here. For the convenience of description, they are referred to as electronic devices in the following.
[0054] According to one aspect of the embodiments of the present application, a method embodiment of a text image splicing method is provided. Figure 1 A flowchart of a method provided in an embodiment of the present application is as follows: Figure 1 As shown, the method includes:
[0055] Step S11, obtaining an initial text image to be spliced, and graying the initial text image to obtain a gray image corresponding to the initial text image.
[0056] The method provided in the embodiment of the present application is applied to a smart terminal, which may be a smart phone, a laptop, a tablet computer, etc. Specifically, the process of the smart terminal obtaining the initial text image to be spliced may be: the requesting device sends the initial text image to the smart terminal according to its own processing requirements. Alternatively, the user directly uploads the initial text image on the smart terminal.
[0057] In the embodiment of the present application, after obtaining the initial text image, the intelligent terminal performs grayscale processing on the initial text image to obtain a grayscale image corresponding to the initial text image, which is recorded as grayscale image P1.
[0058] Step S12, obtaining a target gradient image corresponding to the initial text image, and obtaining a target projection image corresponding to the grayscale image.
[0059] In the embodiment of the present application, obtaining a target gradient image corresponding to an initial text image includes the following steps A1-A2:
[0060] Step A1, obtaining a first gradient image of an initial text image in a vertical coordinate direction, and a second gradient image of the initial text image in a horizontal coordinate direction.
[0061] Step A2: determine the first gradient image and the second gradient image as target gradient images.
[0062] In the embodiment of the present application, the initial text image can be regarded as a two-dimensional discrete function, and the process of the first gradient image of the initial text image in the ordinate direction is: using the two-dimensional discrete function and the ordinate of the pixel points in the initial text image to calculate, the calculation result is the first gradient image in the ordinate direction. Similarly, using the two-dimensional discrete function and the abscissa of the pixel points in the initial text image to calculate, the calculation result is the second gradient image in the abscissa direction. The first gradient image and the second gradient image are used as target gradient images, the first gradient image is denoted as P2, and the second gradient image is denoted as P3.
[0063] In the embodiment of the present application, obtaining the target projection image corresponding to the grayscale image includes: determining the projection image of the grayscale image in the horizontal coordinate direction as the target projection image. The target projection image is recorded as P4.
[0064] It should be noted that the grayscale image can well preserve the information of the original image, the gradient image in the horizontal axis direction can highlight the features in the horizontal axis direction, and the gradient image in the vertical axis direction can highlight the features in the vertical axis direction, and can remove the interference of noise to highlight the features of the text, so as to make the image matching more accurate. The projected image can reflect the statistical characteristics of the pixels of the image, has good robustness of text deformation, can reduce the matching errors caused by image distortion and text deformation, and can reduce the misjudgment of matching caused by multiple repeated overlapping areas. Therefore, the acquisition of the above four images by the embodiment of the present application provides a reliable basis for subsequent correlation matching.
[0065] Step S13, correlation matching is performed on the grayscale image, the target gradient image and the target projection image with the initial text image respectively, to obtain target pixel points in the grayscale image, the target gradient image and the target projection image that match the initial text image respectively.
[0066] In the embodiment of the present application, step S13, respectively performing correlation matching on the grayscale image, the target gradient image and the target projection image with the initial text image, to obtain target pixel points in the grayscale image, the target gradient image and the target projection image that match the initial text image, respectively, includes the following steps B1-B3:
[0067] Step B1, obtaining a first set of local images extracted from the grayscale image, the target gradient image and the target projection image according to a plurality of different preset lengths, wherein the first set of local images includes: local images extracted from the grayscale image, the target gradient image and the target projection image according to each preset length.
[0068] In the embodiment of the present application, step B1, obtaining a first set of partial images extracted from the grayscale image, the target gradient image, and the target projection image according to a plurality of different preset lengths, includes the following steps B101-B104:
[0069] Step B101 , selecting a first partial image from the grayscale image, the target gradient image and the target projection image respectively according to a first preset length.
[0070] Step B102, calculating the sum of the first preset length and a plurality of gradient-arranged step lengths, and determining the sum as the second preset length.
[0071] Step B103, selecting a second partial image from the grayscale image, the target gradient image and the target projection image according to a second preset length.
[0072] Step B104: obtaining a first partial image set based on the first partial image and the second partial image.
[0073] In an embodiment of the present application, first, a first local image with a length of t is selected from the left edges of the grayscale image P1, the first gradient image P2, the second gradient image P3 and the target projection image P4, respectively, wherein the first local image includes: a local image Q1 of the grayscale image P1, a local image Q2 of the first gradient image, a local image Q3 of the second gradient image and a local image Q4 of the target projection image.
[0074] Secondly, the sum of the first preset length and a plurality of step lengths arranged in a gradient is calculated, which may be t+s, t+2s, and the like. At this time, the second preset length includes: t+s, t+2s, and t+3s. Then, a local image with a length of t+s is selected from the left edge of the grayscale image P1, the first gradient image P2, the second gradient image P3, and the target projection image P4, respectively, and a local image with a length of t+2s is selected from the left edge of the grayscale image P1, the first gradient image P2, the second gradient image P3, and the target projection image P4, respectively, and then the local image with a length of t+s and the local image with a length of t+2s are used as the second local image. A first local image set is obtained based on the first local image and the second local image.
[0075] Step B2: obtaining a second set of partial images extracted from the initial text image according to a plurality of different preset lengths, wherein the second set of partial images includes: a partial image extracted from the initial text image according to each preset length.
[0076] In the embodiment of the present application, step B2, obtaining a second set of partial images extracted from the initial text image according to a plurality of different preset lengths, includes the following steps B201-B204:
[0077] Step B201, selecting a third partial image from the initial text image according to a first preset length.
[0078] Step B202, calculating the sum of the first preset length and a plurality of gradient-arranged step lengths, and determining the sum as the second preset length.
[0079] Step B203: selecting a fourth partial image from the initial text image according to the second preset length.
[0080] Step B204, obtaining a second partial image set based on the third partial image and the fourth partial image.
[0081] In an embodiment of the present application, first, a third partial image with a length of t is selected from the left edge of the initial text image. Secondly, the sum of the first preset length and a plurality of gradient-arranged step lengths is calculated, which may be t+s, t+2s, and so on. At this time, the second preset length includes: t+s, t+2s. Then, a partial image with a length of t+s is selected from the left edge of the initial text image, and a partial image with a length of t+2s is selected from the left edge of the initial text image, and then the partial image with a length of t+s and the partial image with a length of t+2s are used as the fourth partial image. A second partial image set is obtained based on the third partial image and the fourth partial image.
[0082] Step B3, comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length to obtain the target pixel point.
[0083] In the embodiment of the present application, step B3, comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length to obtain the target pixel point, includes the following steps B301-B303:
[0084] Step B301, comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length, to obtain candidate pixel points in each image corresponding to each preset length;
[0085] Step B302, obtaining the confidences corresponding to the grayscale image, the target gradient image, the target projection image and the initial text image respectively.
[0086] Step B303: Calculate the frequency data corresponding to each candidate pixel point based on the confidence level, and determine the candidate pixel point with the highest frequency data as the target pixel point.
[0087] As an example, the first local image in the first local image set is used to perform correlation comparison with the corresponding third local image in the second local image set, and the pixels with the largest correlation in the local image Q1 of the grayscale image P1, the local image Q2 of the first gradient image, the local image Q3 of the second gradient image, and the local image Q4 of the target projection image are taken as first candidate pixel points. The first candidate pixel points include: pixel A1 (XA1, YA1) in the local image Q1, pixel B1 (XB1, YB1) in the local image Q1, pixel C1 (XC1, YC1) in the local image Q1, and pixel D1 (XD1, YD1) in the local image Q1.
[0088] Secondly, local images with a preset length of t+s in the first local image set are used for correlation comparison with local images with a preset length of t+s in the second local image set, and the second candidate pixel points include: pixel point A2 (XA2, YA2), pixel point B2 (XB2, YB2), pixel point C2 (XC2, YC2), and pixel point D2 (XD2, YD2).
[0089] Repeat the above process and obtain (XA3, YA3), (XB3, YB3), (XC3, YC3), (XD3, YD3), (XA4, YA4), (XB4, YB4), (XC4, YC4), (XD4, YD4)…
[0090] For the multiple candidate pixel points (XA1, YA1), (XB1, YB1), (XC1, YC1), (XD1, YD1), (XA2, YA2), (XB2, YB2), (XC2, YC2), (XD2, YD2)…, the four pixel points A, B, C, and D come from the matching of the grayscale image, the first gradient image, the second gradient image, and the projection image respectively. Since the image quality of the above four images is different, the confidence of the above four images is set to a, b, c, and d. The weighted frequency of occurrence of the above candidate pixel points is calculated according to the confidence, and the point with the highest frequency is taken as the global best matching point (that is, the target pixel point). If there are few matching points or no repeated matching points, the global best point (target pixel point) is obtained by weighted clustering.
[0091] The embodiment of the present application utilizes grayscale images, gradient images in the horizontal axis direction, gradient images in the vertical axis direction, and projection images, and has different confidence levels for each image device according to different situations. The best matching point is found according to weighted frequency or clustering to achieve puzzle solving, thereby ensuring both the accuracy of the results and the robustness of the results with low computing power requirements.
[0092] Step S14, performing splicing based on target pixel points to obtain a target text image.
[0093] In the embodiment of the present application, after obtaining the target pixel point, the text image can be spliced according to the best matching point.
[0094] The method provided in the embodiment of the present application performs correlation matching on the grayscale image, the gradient image and the projection image respectively with the initial text image, and performs image stitching based on the matched target pixel points. In this way, the correlation matching is performed by utilizing the different characteristics carried by various images, and the required number of pixel points can be accurately captured, so that accurate stitching can be achieved under complex conditions or backgrounds. At the same time, compared with the traditional image stitching method, the computational complexity is small and the stitching efficiency is high.
[0095] Figure 4 This is a block diagram of a text image splicing device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device comprises:
[0096] The first acquisition module 41 is used to acquire an initial text image to be spliced, and grayscale the initial text image to obtain a grayscale image corresponding to the initial text image;
[0097] A second acquisition module 42 is used to acquire a target gradient image corresponding to the initial text image, and to acquire a projection image corresponding to the grayscale image;
[0098] The processing module 43 is used to perform image correlation matching on the grayscale image, the target gradient image and the projection image with the initial text image, and obtain target pixel points in the grayscale image, the target gradient image and the projection image that match the initial text image respectively;
[0099] The stitching module 44 is used to perform stitching based on target pixels to obtain a target text image.
[0100] In the embodiment of the present application, the second acquisition module 42 is used to acquire a first gradient image of the initial text image in the vertical coordinate direction and a second gradient image of the initial text image in the horizontal coordinate direction; and determine the first gradient image and the second gradient image as target gradient images.
[0101] In the embodiment of the present application, the second acquisition module 42 is used to determine the projection image of the grayscale image in the horizontal axis direction as the target projection image.
[0102] In an embodiment of the present application, a processing module 43 is used to obtain a first set of local images extracted from a grayscale image, a target gradient image, and a target projection image according to a plurality of different preset lengths, wherein the first set of local images includes: local images extracted from the grayscale image, the target gradient image, and the target projection image according to each preset length; obtain a second set of local images extracted from an initial text image according to a plurality of different preset lengths, wherein the second set of local images includes: local images extracted from the initial text image according to each preset length; compare the correlation between the local images in the first set of local images and the local images in the second set of local images at each preset length to obtain the target pixel point.
[0103] In the embodiment of the present application, the processing module 43 is used to select a first partial image from the grayscale image, the target gradient image and the target projection image according to the first preset length;
[0104] Calculate the sum of a first preset length and a plurality of gradient-arranged step lengths, and determine the sum as a second preset length; select a second local image from the grayscale image, the target gradient image, and the target projection image according to the second preset length; and obtain a first local image set based on the first local image and the second local image.
[0105] In an embodiment of the present application, the processing module 43 is used to select a third local image from the initial text image according to a first preset length; calculate the sum of the first preset length and a plurality of gradient-arranged step lengths, and determine the sum as a second preset length; select a fourth local image from the initial text image according to the second preset length; and obtain a second local image set based on the third local image and the fourth local image.
[0106] In an embodiment of the present application, the processing module 43 is used to compare the correlation between the local images in the first local image set and the local images in the second local image set at each preset length, and obtain the candidate pixel points in each image corresponding to each preset length; obtain the confidence levels corresponding to the grayscale image, the target gradient image, the target projection image, and the initial text image respectively; calculate the frequency data corresponding to each candidate pixel point based on the confidence level, and determine the candidate pixel point with the highest frequency data as the target pixel point.
[0107] The present application also provides an electronic device, such as Figure 5 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .
[0108] Memory 1503, used for storing computer programs;
[0109] The processor 1501 is used to implement the steps of the above embodiment when executing the computer program stored in the memory 1503.
[0110] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0111] The communication interface is used for communication between the above terminal and other devices.
[0112] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0113] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0114] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the text image splicing method described in any of the above embodiments.
[0115] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the text image splicing method described in any one of the above embodiments.
[0116] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk), etc.
[0117] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
[0118] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A text image splicing method, characterized in that: include: Acquire an initial text image to be spliced, and perform grayscale processing on the initial text image to obtain a grayscale image corresponding to the initial text image; Acquire a target gradient image corresponding to the initial text image, and acquire a target projection image corresponding to the grayscale image; Correlation matching is performed on the grayscale image, the target gradient image and the target projection image with the initial text image to obtain target pixel points in the grayscale image, the target gradient image and the target projection image that match the initial text image respectively; The target text image is obtained by performing stitching based on the target pixel points.
2. The method according to claim 1, characterized in that The step of obtaining a target gradient image corresponding to the initial text image includes: Acquire a first gradient image of the initial text image in the ordinate direction, and a second gradient image of the initial text image in the abscissa direction; The first gradient image and the second gradient image are determined as the target gradient images.
3. The method according to claim 1, characterized in that The obtaining of a target projection image corresponding to the grayscale image comprises: The projection image of the grayscale image in the horizontal coordinate direction is determined as the target projection image.
4. The method according to claim 1, characterized in that: The step of performing correlation matching on the grayscale image, the target gradient image, and the target projection image with the initial text image to obtain target pixel points in the grayscale image, the target gradient image, and the target projection image that match the initial text image respectively includes: Acquire a first set of partial images extracted from the grayscale image, the target gradient image, and the target projection image according to a plurality of different preset lengths, wherein the first set of partial images includes: partial images extracted from the grayscale image, the target gradient image, and the target projection image according to each preset length; Acquire a second set of partial images extracted from the initial text image according to a plurality of different preset lengths, wherein the second set of partial images includes: partial images extracted from the initial text image according to each preset length; The target pixel point is obtained by comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length.
5. The method according to claim 4, characterized in that The acquiring of a first set of partial images extracted from the grayscale image, the target gradient image, and the target projection image according to a plurality of different preset lengths comprises: Selecting a first partial image from the grayscale image, the target gradient image, and the target projection image respectively according to a first preset length; Calculating a sum of a first preset length and a plurality of step lengths arranged in a gradient, and determining the sum as a second preset length; Selecting a second partial image from the grayscale image, the target gradient image, and the target projection image according to the second preset length; The first partial image set is obtained based on the first partial image and the second partial image.
6. The method according to claim 4, characterized in that The step of obtaining a second set of partial images extracted from the initial text image according to a plurality of different preset lengths includes: Selecting a third partial image from the initial text image according to a first preset length; Calculating a sum of a first preset length and a plurality of step lengths arranged in a gradient, and determining the sum as a second preset length; Selecting a fourth partial image from the initial text image according to the second preset length; The second partial image set is obtained based on the third partial image and the fourth partial image.
7. The method according to claim 4, characterized in that The comparing the correlation between the local images in the first local image set and the local images in the second local image set at each preset length to obtain the target pixel point includes: Comparing the correlation between the local images in the first local image set at each preset length and the local images in the second local image set, to obtain candidate pixel points in each image corresponding to each preset length; Obtaining confidences corresponding to the grayscale image, the target gradient image, the target projection image, and the initial text image respectively; The frequency data corresponding to each candidate pixel is calculated based on the confidence level, and the candidate pixel with the highest frequency data is determined as the target pixel.
8. A text image splicing device, characterized in that: include: A first acquisition module is used to acquire an initial text image to be spliced, and grayscale the initial text image to obtain a grayscale image corresponding to the initial text image; A second acquisition module, used to acquire a target gradient image corresponding to the initial text image, and to acquire a projection image corresponding to the grayscale image; A processing module, used for performing image correlation matching on the grayscale image, the target gradient image and the projection image with the initial text image, respectively, to obtain target pixel points in the grayscale image, the target gradient image and the projection image that match the initial text image respectively; The splicing module is used to perform splicing based on the target pixel points to obtain a target text image.
9. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method steps of any one of claims 1 to 7 when executed.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method steps of any one of claims 1 to 7 by running a program stored in a memory.
Citation Information
Patent Citations
Image feature point matching method and device, computer device and storage medium
CN109887002A
Image splicing method and device, equipment and medium
CN114494013A