Four-way continuous texture synthesis method, device, equipment and medium based on template matching
Through the template matching algorithm, the size of texture loop blocks is found and the problem of repetition in texture splicing in the existing technology is solved, and a higher quality texture synthesis effect is achieved.
Patent Information
- Application Number
- CN202210173075.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-24
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2042-02-24
AI Technical Summary
The prior art relies on the uniformity of image texture in the size extraction of texture loop blocks, resulting in a sense of repetition when splicing the output loop blocks.
The template matching algorithm is used to find and correct the size of texture loop blocks, and avoid the sense of repeating texture by reducing the matching degree of continuous area. The specific steps include establishing an image pyramid, determining the optimal calibration angle and cyclic area size, performing direction correction and block extraction, selecting texture synthesis candidate blocks and performing splicing.
It effectively avoids the sense of repetition in texture synthesis and improves the quality and continuity of texture splicing.
Smart Images

Figure CN114663321B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of image processing, and in particular relates to a four-way continuous texture synthesis method, device, electronic equipment and storage medium based on template matching. Background Art
[0002] The four-way continuity of texture is very important in fabric digitization. Textures that meet the four-way continuity can be extended infinitely without gaps. For an input texture image, its repeated seed blocks are automatically identified to obtain a four-way continuous texture, which greatly facilitates users who need to digitize textures to generate four-way continuous maps. Patent CN108280861A proposes an intelligent cycle search method that uses the normal distribution of pixels to determine the size of the cycle area. However, the normal distribution method proposed in the patent extracts block size that depends on the uniformity of the image texture, and the output cycle blocks are prone to repetition when spliced. Summary of the invention
[0003] In order to solve the shortcomings of the above-mentioned prior art, the present invention provides a method, device, electronic device and storage medium for synthesizing four-way continuous textures based on template matching. The method uses template matching to find and correct the size of texture cycle blocks, and avoids the repetitive feeling of synthesized textures by reducing the matching degree of continuous areas.
[0004] The first object of the present invention is to provide a four-way continuous texture synthesis method based on template matching.
[0005] The second object of the present invention is to provide a four-way continuous texture synthesis device based on template matching.
[0006] A third object of the present invention is to provide an electronic device.
[0007] A fourth object of the present invention is to provide a storage medium.
[0008] The first object of the present invention can be achieved by adopting the following technical solutions:
[0009] A four-way continuous texture synthesis method based on template matching, the method comprising:
[0010] According to the input image, an image pyramid is established to determine the optimal calibration angle and the size of the circulation area of the input image;
[0011] Directionally correcting the input image according to the optimal calibration angle to obtain a corrected image;
[0012] Extracting the corrected image according to the size of the circulation area to obtain a seed block;
[0013] According to the seed block, a texture synthesis candidate block is selected in the corrected image; and the texture synthesis candidate blocks are spliced to generate a final image.
[0014] Furthermore, the step of establishing an image pyramid based on the input image and determining the optimal calibration angle and the size of the circulation area of the input image specifically includes:
[0015] According to the input image, an image pyramid is established, and each layer of images in the pyramid is sorted from small to large to obtain a sorted image; wherein the last image in the sorted image is the input image;
[0016] The following processing is performed on each layer of the sorted images in turn:
[0017] The current layer image search calibration angle range is [k best -N i ,k best +N i ], divide the range into equal parts, and the angle difference of each interval is d i , get a set of image tilt angles to be searched in the current layer; where k best is the best calibration angle of the previous layer, and k is the top layer best =0,N i The range to be searched for the current layer;
[0018] Take any image tilt angle k from a set of image tilt angles i , and proceed as follows:
[0019] Rotate the current layer image by angle k i , and cut off the irregular parts to obtain the cropped image;
[0020] The template matching algorithm is used to calculate the width and height of the loop area in the X and Y directions of the cropped image, and the score X at the best match is recorded. score And score Y score ;
[0021] Final score
[0022] For the current layer image, select the score from a set of image tilt angles. The largest angle is used as the optimal calibration angle for the current layer image. The height and width of the loop area corresponding to the angle are used as the loop area size of the current layer image;
[0023] The optimal calibration angle and loop area size obtained for the last layer of images are the optimal calibration angle and loop area size for the input image.
[0024] Furthermore, the cropped image is subjected to template matching algorithm in the X direction and the Y direction respectively to calculate the width and height of the loop region, and the score X at the best match is recorded. score And score Y score , including:
[0025] Use the template matching algorithm on the cropped image in the X direction to calculate the width of the loop area and record the score X when the best match occurs. score ,include:
[0026] Select a pixel block with a width of w and a height less than the height of the cropped image from the cropped image as template B a , select a pixel block with the same height and width slightly smaller than the image height from the cropped image as the matching image B b , using the template matching algorithm, calculate the template B a Matching graph B b The matching score of the highest-scoring matching point is obtained, and the area B corresponding to the matching point with the highest score is obtained. best ;
[0027] In template B a Take an area B near the starting point sa , in B best Take a larger area B nearby sb , use B sa As a template, sb Perform template matching and select the maximum matching score X score As the best matching point;
[0028] The horizontal coordinate of the best matching point is sb The difference between the starting point's horizontal coordinates is used as the width of the loop area, and the score X of the best match in the X direction is recorded. score ;
[0029] Similarly, the template matching algorithm is used on the cropped image in the Y direction to calculate the height of the loop area and record the score Y when the best match occurs. score .
[0030] Further, extracting the corrected image according to the size of the cycle area to obtain a seed block specifically includes:
[0031] Dividing the corrected image into a plurality of cyclic blocks according to the size of the cyclic region;
[0032] Calculate the self-joining score and the size of the loop region of the loop block respectively;
[0033] The self-splicing scores of the cyclic blocks are compared, and the cyclic block with the largest self-splicing score is used as the seed block, and the size of the cyclic region of the cyclic block with the largest self-splicing score is used as the size of the seed block.
[0034] Furthermore, the calculation of the self-joining score and the size of the loop region of the loop block specifically includes:
[0035] Calculate the best matching score X of the loop block in the X direction score and loop region width, including:
[0036] At the starting position of the loop block in the X direction, select an area B h As a template, select an area B near the end of the loop block. t ;
[0037] Use template B h For area B t Perform template matching and select the maximum score as the best matching point;
[0038] The horizontal coordinate of the best matching point is the same as the template B h The difference between the horizontal coordinates is used as the loop area width of the loop block, and the score X of the best match in the X direction is recorded. score ;
[0039] Similarly, the best matching score Y of the loop block is calculated in the Y direction score and the height of the circulation area;
[0040] According to the best matching score X score and Y score , the self-joining score of the loop block is min(X score ,Y score );
[0041] The loop region width and the loop region width serve as the loop region size of the loop block.
[0042] Furthermore, selecting a texture synthesis candidate block in the corrected image according to the seed block specifically includes:
[0043] The width and height of the seed block are increased by a fixed value, and the similarity between the texture synthesis candidate block and the seed block is less than a set threshold;
[0044] A group of texture synthesis candidate blocks are selected from the corrected image, wherein the texture synthesis candidate blocks are spaced apart from each other.
[0045] Furthermore, the step of splicing the texture synthesis candidate blocks to generate a final image specifically includes:
[0046] The texture synthesis candidate blocks are stitched together from the upper left to the lower right to generate the final image, including:
[0047] Calculate the similarity of overlapping areas between a group of texture synthesis candidate blocks and the area to be spliced, and use candidate blocks with high similarity for splicing;
[0048] To avoid a sense of repetition, the similarity scores between adjacent candidate blocks in the corrected image are reduced;
[0049] Depending on the location of the area to be spliced, the overlapping area needs to be considered:
[0050] When splicing the middle part, you need to consider the overlapping areas on the top and left sides;
[0051] At the last position of the current row, the overlapping areas with the top, left, and first column are considered;
[0052] When it comes to the last row, the overlapping areas of the top, left, and first rows need to be considered.
[0053] The second object of the present invention can be achieved by adopting the following technical solutions:
[0054] A four-way continuous texture synthesis device based on template matching, the device comprising:
[0055] A calibration angle and circulation area determination module is used to establish an image pyramid according to an input image and determine an optimal calibration angle and circulation area size of the input image;
[0056] A correction module, used for performing direction correction on the input image according to the optimal calibration angle to obtain a corrected image;
[0057] An image extraction module, used for extracting the corrected image according to the size of the circulation area to obtain a seed block;
[0058] The splicing module is used to select texture synthesis candidate blocks in the corrected image according to the seed blocks; and splice the texture synthesis candidate blocks to generate a final image.
[0059] The third object of the present invention can be achieved by adopting the following technical solutions:
[0060] An electronic device comprises a processor and a memory for storing a program executable by the processor. When the processor executes the program stored in the memory, the above-mentioned four-way continuous texture synthesis method is implemented.
[0061] The fourth object of the present invention can be achieved by adopting the following technical solutions:
[0062] A storage medium stores a program, and when the program is executed by a processor, the four-way continuous texture synthesis method is implemented.
[0063] The present invention has the following beneficial effects compared with the prior art:
[0064] The present invention utilizes template matching to search and correct the size of the texture cycle block, and avoids the repetitive feeling of the synthesized texture by reducing the matching degree of the continuous area. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0066] Figure 1 This is a flow chart of a four-way continuous texture synthesis method based on template matching according to Example 1 of the present invention.
[0067] Figure 2 This is a schematic diagram of coarse matching in the X direction of Example 1 of the present invention.
[0068] Figure 3 This is the precise match in the X direction of Example 1 of the present invention.
[0069] Figure 4 It is a schematic diagram of the rough matching in the Y direction of Example 1 of the present invention.
[0070] Figure 5 This is a schematic diagram of cyclic block division in embodiment 1 of the present invention.
[0071] Figure 6 This is a schematic diagram of cyclic block template matching in Example 1 of the present invention.
[0072] Figure 7 This is a schematic diagram of the splicing of Example 1 of the present invention.
[0073] Figure 8 This is a structural block diagram of a four-way continuous texture synthesis method based on template matching according to Embodiment 2 of the present invention.
[0074] Fig. 9 This is a structural block diagram of an electronic device according to Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0075] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. It should be understood that the specific embodiments described are only used to explain the present application and are not used to limit the present application.
[0076] Embodiment 1:
[0077] like Figure 1 As shown, this embodiment provides a four-way continuous texture synthesis method based on template matching, comprising the following steps:
[0078] S101: Building an image pyramid based on an input image, and determining an optimal calibration angle and a circulation area size of the input image.
[0079] According to the input image, an image pyramid is established, and each layer of images in the pyramid is sorted from small to large, and the last layer is the input image. A search method is used for each layer of images to find the best calibration angle k and loop area size, where the width of the loop area is w and the height is h.
[0080] Furthermore, step S101 specifically includes:
[0081] Each layer of the image in the pyramid is processed as follows:
[0082] Step 1: The search calibration angle range of the current layer is [k best -N i ,k best +N i ], where k best is the optimal calibration angle of the previous layer, N i is the range to be searched in the current layer. Divide the range into equal parts, and the angle difference between each interval is d i . Get a set of image tilt angles k to be searched in the current layer i , where the top layer is k best =0.
[0083] k i =k best -N i +i*d i ,(k best -N i ≤k i ≤k best +N i )
[0084] Step 2: For any tilt angle k obtained i , and proceed as follows:
[0085] (1) Rotate the current layer image by angle k i , and cut off the irregular parts.
[0086] (2) Use the template matching algorithm on the cropped image in the X direction to calculate the width of the loop area and record the score X when the best match occurs. score .
[0087] like Figure 2 As shown, a pixel block with a width of w and a height less than the height of the cropped image is selected from the cropped image as a template B a ( Figure 2 Select a pixel block with the same height and slightly smaller width than the image height from the cropped image as the matching image B. b ( Figure 2 The gray box in the figure), using the template matching algorithm, calculates the template B a Matching graph B b The matching score of the highest-scoring matching point is obtained, and the area B corresponding to the matching point with the highest score is obtained. best ( Figure 2 white frame).
[0088] like Figure 3 As shown in B a Take an area B near the starting point sa ( Figure 3 In the white box in B best Take a larger area B nearby sb ( Figure 3 The black frame part) is shown in the figure below. sa As a template, sb Perform a template match and select the maximum matching score X score As the best matching point, its horizontal coordinate is the same as B xb The difference between the starting point and the horizontal coordinate is the final loop area width w, and the score X of the best match in the X direction is recorded. score .
[0089] (3) Similar to step 3, the height h of the loop area is calculated in the Y direction using the template matching algorithm for the cropped image, and the score Y at the best match is recorded. score ,like Figure 4 shown.
[0090] (4) At angle k i The final score of
[0091] Step 3: Select the score from this set of image tilt angles The largest angle is used as the optimal calibration angle for the current layer image. The height and width of the loop area at this angle are used as the loop area size of the current layer image.
[0092] The optimal calibration angle and loop area size obtained for the last layer of images are the optimal correction angle and loop area size for the input image.
[0093] S102, performing direction correction on the input image according to the optimal calibration angle to obtain a corrected image; extracting the corrected image according to the size of the circulation area to obtain a seed block.
[0094] Furthermore, step S102 specifically includes:
[0095] Step 1: Use the best calibration angle obtained in the above steps to correct the direction of the input image, and divide the image into multiple loop blocks according to the height and width of the loop area, such as Figure 5 shown.
[0096] Step 2: Calculate the self-joining scores of the cyclic blocks respectively.
[0097] (1) Figure 6 As shown, at the starting position of the current cycle block in the X direction, select an area B h ( Figure 6 The white box in the middle is used as a template, and an area B is selected near the end of the current loop block. t ( Figure 6 black frame).
[0098] Use template B h For area B t Perform template matching and select the maximum score as the best matching point, whose horizontal coordinate is the same as template B h The difference between the horizontal coordinates is the loop area width of the current loop block, and the score X of the best match in the X direction is recorded. score .
[0099] (2) Similarly, the best matching score Y of the current loop block is calculated in the Y direction score and the circulation area height.
[0100] (3) According to the best matching score X score and Y score , the self-joining score of the current loop block is min(X score ,Y score ) and the size of the loop region.
[0101] Step 3: Select the cyclic block with the largest self-joining score among all cyclic blocks as the seed block, and use the size of the cyclic area of the cyclic block with the largest self-joining score as the size of the seed block.
[0102] S103 . Selecting texture synthesis candidate blocks in the corrected image according to the seed blocks; and splicing the texture synthesis candidate blocks to generate a final image.
[0103] Furthermore, step S103 specifically includes:
[0104] Step 1: Considering that actual stitching requires a certain overlap area, the width and height of the seed block are increased by Δd, and a group of texture synthesis candidate blocks are selected from the direction-corrected image, denoted as C, and a certain interval is ensured between the candidate blocks. Template matching is performed on the entire image, and the similarity between the candidate block and the seed block is less than a certain threshold T.
[0105] Step 2: Splice the texture synthesis candidate blocks from the upper left to the lower right to generate the final image.
[0106] like Figure 7 As shown, from a set of candidate blocks C obtained in step 1, the splicing area ( Figure 7 The similarity of the overlapping areas is calculated by the black area block in the middle, and the candidate blocks with high similarity are used for splicing. To avoid repetition, the similarity scores between adjacent candidate blocks on the original image are reduced. Depending on the position of the area to be spliced, it is necessary to consider that the overlapping areas are different: in the middle part ( Figure 7 When splicing (black box in the middle), you need to consider the overlapping areas on the top and left; when it is the last position in the current row, you need to consider the overlapping areas on the top, left, and first column; when it is the last row, you need to consider the overlapping areas on the top, left, and first row.
[0107] Those skilled in the art will appreciate that all or part of the steps in the method for implementing the above embodiments may be completed by instructing related hardware through a program, and the corresponding program may be stored in a computer-readable storage medium.
[0108] It should be noted that although the method operations of the above embodiments are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted can be performed in a different order. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0109] Embodiment 2:
[0110] like Figure 8As shown, this embodiment provides a four-way continuous texture synthesis device based on template matching, which includes a calibration angle and cycle area determination module 801, a correction module 802, an image extraction module 803 and a splicing module 804, wherein:
[0111] The calibration angle and circulation area determination module 801 is used to establish an image pyramid according to the input image and determine the optimal calibration angle and circulation area size of the input image;
[0112] A correction module 802 is used to perform direction correction on the input image according to the optimal calibration angle to obtain a corrected image;
[0113] An image extraction module 803 is used to extract the corrected image according to the size of the circulation area to obtain a seed block;
[0114] The stitching module 804 is used to select texture synthesis candidate blocks in the corrected image according to the seed blocks; and stitch the texture synthesis candidate blocks to generate a final image.
[0115] The specific implementation of each module in this embodiment can refer to the above-mentioned embodiment 1, which will not be described one by one here; it should be noted that the device provided in this embodiment is only illustrated by the division of the above-mentioned functional modules. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure can be divided into different functional modules to complete all or part of the functions described above.
[0116] Embodiment 3:
[0117] This embodiment provides an electronic device, which may be a computer. Fig. 9 As shown, a processor 902, a memory, an input system 903, a display 904 and a network interface 905 connected via a system bus 901 are provided. The processor is used to provide computing and control capabilities. The memory includes a non-volatile storage medium 906 and an internal memory 907. The non-volatile storage medium 906 stores an operating system, a computer program and a database. The internal memory 907 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the processor 902 executes the computer program stored in the memory, the four-way continuous texture synthesis method of the above-mentioned embodiment 1 is implemented as follows:
[0118] According to the input image, an image pyramid is established to determine the optimal calibration angle and the size of the circulation area of the input image;
[0119] Directionally correcting the input image according to the optimal calibration angle to obtain a corrected image;
[0120] Extracting the corrected image according to the size of the circulation area to obtain a seed block;
[0121] According to the seed block, a texture synthesis candidate block is selected in the corrected image; and the texture synthesis candidate blocks are spliced to generate a final image.
[0122] Embodiment 4:
[0123] This embodiment provides a storage medium, which is a computer-readable storage medium, storing a computer program. When the computer program is executed by a processor, the four-way continuous texture synthesis method of the above embodiment 1 is implemented as follows:
[0124] According to the input image, an image pyramid is established to determine the optimal calibration angle and the size of the circulation area of the input image;
[0125] Directionally correcting the input image according to the optimal calibration angle to obtain a corrected image;
[0126] Extracting the corrected image according to the size of the circulation area to obtain a seed block;
[0127] According to the seed block, a texture synthesis candidate block is selected in the corrected image; and the texture synthesis candidate blocks are spliced to generate a final image.
[0128] It should be noted that the computer-readable storage medium of the present embodiment may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0129] The above is only a preferred embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and inventive concept of the present invention within the scope disclosed by the present invention, which shall fall within the protection scope of the present invention.
Claims
1. A four-way continuous texture synthesis method based on template matching, characterized in that: The method comprises: According to the input image, an image pyramid is established to determine the optimal calibration angle of the input image and the size of the circulation area; Directionally correcting the input image according to the optimal calibration angle to obtain a corrected image; Extracting the corrected image according to the size of the circulation area to obtain a seed block; According to the seed block, a texture synthesis candidate block is selected in the corrected image; the texture synthesis candidate blocks are sequentially spliced from the upper left to the lower right to generate a final image; The step of extracting the corrected image according to the size of the cycle area to obtain a seed block specifically includes: Dividing the corrected image into a plurality of cyclic blocks according to the size of the cyclic region; Calculate the self-joining score of the cycle block and the cycle area size of the cycle block respectively; Compare the self-joining scores of the cyclic blocks, take the cyclic block with the largest self-joining score as the seed block, and use the size of the cyclic region of the cyclic block with the largest self-joining score as the size of the seed block; The calculating of the self-joining score of the cyclic block and the size of the cyclic region of the cyclic block specifically includes: Calculate the best matching score X of the loop block in the X direction score And the width of the loop area, including: starting position in the X direction of the loop block, select a block B h As a template, select an area B near the end of the loop block. t ; Use template B h For area B t Perform template matching and select the matching point corresponding to the maximum score as the best matching point; compare the horizontal coordinate of the best matching point with the template B h The difference between the horizontal coordinates is used as the loop area width of the loop block, and the score X of the best match in the X direction is recorded. score ; Similarly, the best matching score Y of the loop block is calculated in the Y direction score and the height of the circulation area; According to the best matching score X score and Y score , the self-joining score of the loop block is min(X score , Y score ); Using the loop region width and the loop region height as the loop region size of the loop block; Among them, in order to avoid the sense of repetition, the similarity value between adjacent texture synthesis candidate blocks in the corrected image is reduced; The texture synthesis candidate blocks are sequentially spliced from the upper left to the lower right to generate a final image, including: A group of texture synthesis candidate blocks are respectively used to calculate the similarity values of the overlapping areas with the area to be spliced, and the texture synthesis candidate blocks with high similarity values are used for splicing.
2. The method for synthesizing four-way continuous textures according to claim 1, characterized in that: The step of establishing an image pyramid according to the input image and determining the optimal calibration angle of the input image and the size of the circulation area specifically includes: According to the input image, an image pyramid is established, and each layer of images in the pyramid is sorted from small to large to obtain a sorted image; wherein the last image in the sorted image is the input image; The following processing is performed on each layer of the sorted images in turn: The current layer image search calibration angle range is [k best -N i , k best +N i ], divide the range into equal parts, and the angle difference of each interval is d i , get a set of image tilt angles to be searched in the current layer; where k best is the best calibration angle of the previous layer, and k is the top layer best =0,N i The range to be searched for the current layer; Take any image tilt angle k from a set of image tilt angles i , and proceed as follows: Rotate the current layer image by angle k i , and cut off the irregular parts to obtain the cropped image; The template matching algorithm is used to calculate the width and height of the loop area in the X and Y directions of the cropped image, and the score MX at the best match is recorded. score And score MY score ; Final score: ki =min(MX score , MY score ); For the current layer image, select the score S from a set of image tilt angles. ki The largest angle is used as the best calibration angle of the current layer image, and the height and width of the circulation area corresponding to the angle are used as the size of the circulation area of the current layer image; The optimal calibration angle and the size of the circulation area obtained by the last layer of images are the optimal calibration angle and the size of the circulation area of the input image.
3. The method for synthesizing four-way continuous textures according to any one of claims 1 to 2, characterized in that: Depending on the location of the area to be spliced, the overlapping areas that need to be considered include: When splicing the middle part, you need to consider the overlapping areas on the top and left sides; At the last position of the current row, the overlapping areas with the top, left, and first column are considered; When it comes to the last row, the overlapping areas of the top, left, and first rows need to be considered.
4. A four-way continuous texture synthesis device based on template matching, characterized in that: The device comprises: A calibration angle and circulation area determination module is used to establish an image pyramid according to an input image and determine the optimal calibration angle and the size of the circulation area of the input image; A correction module, used for performing direction correction on the input image according to the optimal calibration angle to obtain a corrected image; An image extraction module, used for extracting the corrected image according to the size of the circulation area to obtain a seed block; A splicing module, configured to select a texture synthesis candidate block in the corrected image according to the seed block; and splice the texture synthesis candidate blocks in sequence from the upper left to the lower right to generate a final image; The image extraction module is specifically used to: divide the corrected image into a plurality of cyclic blocks according to the size of the cyclic area; respectively calculate the self-stitching scores of the cyclic blocks and the cyclic area sizes of the cyclic blocks; compare the self-stitching scores of the cyclic blocks, take the cyclic block with the largest self-stitching score as the seed block, and take the cyclic area size of the cyclic block with the largest self-stitching score as the size of the seed block; The step of calculating the self-joining score of the cyclic block and the size of the cyclic region of the cyclic block specifically includes: Calculate the best matching score X of the loop block in the X direction score And the width of the loop area, including: starting position in the X direction of the loop block, select a block of area B h As a template, select an area B near the end of the loop block. t ; Use template B h For area B t Perform template matching and select the matching point corresponding to the maximum score as the best matching point; compare the horizontal coordinate of the best matching point with the template B h The difference between the horizontal coordinates is used as the loop area width of the loop block, and the score X of the best match in the X direction is recorded. score ; Similarly, the best matching score Y of the loop block is calculated in the Y direction score and the height of the circulation area; According to the best matching score X score and Y score , the self-joining score of the loop block is min(X score , Y score ); Using the loop region width and the loop region height as the loop region size of the loop block; Among them, in order to avoid the sense of repetition, the similarity value between adjacent texture synthesis candidate blocks in the corrected image is reduced; The texture synthesis candidate blocks are stitched sequentially from the upper left to the lower right to generate a final image, specifically including: A group of texture synthesis candidate blocks are respectively used to calculate the similarity values of the overlapping areas with the area to be spliced, and the texture synthesis candidate blocks with high similarity values are used for splicing.
5. An electronic device comprising a processor and a memory for storing a program executable by the processor, characterized in that: When the processor executes the program stored in the memory, the four-way continuous texture synthesis method described in any one of claims 1 to 3 is implemented.
6. A storage medium storing a program, characterized in that: When the program is executed by a processor, the four-way continuous texture synthesis method described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Texture optimization-based non-homogeneous image synthesis method
CN102867290A
Processing method for performing intelligent circulation lookup on pictures
CN108280861A