A method and system for seamless stitching of image slices based on feathering technology
By employing a seamless image slicing method based on feathering technology, which merges and feathers image blocks in pairs, the problem of incomplete elimination of image seams and information loss in existing technologies is solved, achieving high-quality seamless image slicing.
Patent Information
- Application Number
- CN202411651316.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-11-19
AI Technical Summary
Existing technologies cannot completely eliminate image seams, and when processing images with significant color changes or complex textures, the fusion processing of overlapping parts leads to loss of image information, failing to meet the requirements for high-quality seamless integration.
A seamless image slicing method based on feathering technology is adopted. By merging two pairs of image blocks, calculating the overlapping areas and performing feathering processing, until all overlapping areas are completely processed, a seamless image slicing is achieved.
It completely eliminates the seams between image blocks, maintains visual consistency of the image, avoids unnatural color transitions or loss of detail, and achieves high-quality seamless image integration.
Smart Images

Figure CN119693224B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method and system for seamlessly connecting image slices based on feathering technology. Background Technology
[0002] When processing images using super-resolution models or other AI enhancement techniques, image slicing is often necessary. This sliced image then exhibits seam lines during subsequent merging. Current methods for optimizing these seam lines typically employ pixel-level processing, preserving the overlapping portion of each slice during slicing and proportionally adding the pixels of the overlapping portion during merging. While this approach reduces the noticeability of seam lines to some extent, it still suffers from the following drawbacks:
[0003] I. Current image seam optimization methods cannot completely eliminate seams, and the fusion processing of overlapping parts depends on a fixed ratio, which cannot adapt to the characteristics of different images. When processing images with obvious color changes and vivid colors, seams will still be clearly visible.
[0004] Second, when processing images with complex textures or color gradients, the fusion of overlapping parts often leads to the loss of image information, resulting in poor quality of the final synthesized image, which cannot meet the application scenarios that require high-quality and flawless output.
[0005] Therefore, we need to develop a method and system for seamless image slicing based on feathering technology, which can completely eliminate image seams and achieve high-quality seamless image slicing without losing image information and maintaining the overall visual consistency of the image. Summary of the Invention
[0006] The purpose of this invention is to provide a method and system for seamless image slicing based on feathering technology, so as to solve the problems mentioned in the background art that the existing image seam optimization methods cannot completely eliminate seam lines, have poor image optimization quality, and have low applicability.
[0007] To achieve the above objectives, the present invention adopts the following technical solution:
[0008] According to one aspect of the present invention, a method for seamlessly stitching image slices based on feathering technology is provided, the method comprising the following steps:
[0009] The input image is sliced to obtain N blocks, and then the coordinates of the top left corner of each block are calculated.
[0010] The overlapping area of two blocks is determined by merging them in pairs according to the merging direction of the blocks.
[0011] Based on the size of the block and the coordinates of the top left corner, the specific overlapping area is calculated;
[0012] The overlapping region is feathered to obtain two blocks with a smooth transition;
[0013] The steps of determining the range of overlapping regions, calculating overlapping regions, and feathering are repeated iteratively until all overlapping regions are feathered, resulting in a final seamlessly fused image.
[0014] According to another aspect of the present invention, a seamless image slicing system based on feathering technology is provided, the system comprising: an image slicing module, a range determination module, a region calculation module, a feathering processing module, and a repetitive iteration module. Wherein:
[0015] The image slicing module described above is used to slice the input image, obtain N blocks, and then calculate the coordinates of the top left corner of each block.
[0016] The aforementioned range determination module is used to determine the overlapping area range of two blocks by merging them in pairs, based on the merging direction of the blocks.
[0017] The aforementioned region calculation module is used to calculate the specific overlapping region based on the size of the block and the coordinates of the upper left corner;
[0018] The above-mentioned feathering module is used to feather the overlapping area to obtain two blocks with a smooth transition.
[0019] The aforementioned iterative module is used to repeatedly iterate the steps of determining the range of overlapping regions, calculating overlapping regions, and feathering until all overlapping regions are feathered, resulting in a final seamlessly fused image.
[0020] Based on the aforementioned scheme, when slicing the input image, the number of blocks is determined by the number of rows and columns of the slice; wherein, the number of rows and columns of the slice is calculated based on the size of the input image and the input size of the super-resolution model, and the specific calculation formula is as follows:
[0021] R = (H-1+h) / h;
[0022] C = (W-1+w) / w;
[0023] Where R is the number of rows in the slice, C is the number of columns in the slice, H is the height of the input image, W is the width of the input image, h is the height of the input dimension of the super-resolution model, and w is the width of the input dimension of the super-resolution model.
[0024] Based on the aforementioned scheme, when slicing the input image, the horizontal and vertical offsets are calculated based on the number of rows and columns of the slice, the size of the input image, and the input size of the super-resolution model, specifically as follows:
[0025] If W ≤ w, then X = 0;
[0026] If W > w, then X = (W - w) / (C - 1);
[0027] If H ≤ h, then Y = 0;
[0028] If H > h, then Y = (H - h) / (R - 1);
[0029] Where X is the horizontal offset, Y is the vertical offset, W is the width of the input image, w is the input size width of the super-resolution model, H is the height of the input image, h is the input size height of the super-resolution model, R is the number of rows of the slice, and C is the number of columns of the slice.
[0030] Based on the aforementioned scheme, after slicing the input image to obtain N blocks, the top-left corner coordinates of each block are calculated according to the row and column indices, the horizontal offset, and the vertical offset. The specific calculation formula is as follows:
[0031] x = i × X;
[0032] y = j × Y;
[0033] Where x and y represent the horizontal and vertical coordinates of the top left corner of the block, respectively, i is the column index, j is the row index, X is the horizontal offset, and Y is the vertical offset.
[0034] Based on the aforementioned scheme, when merging the N blocks in pairs, a method of merging one by one in the same direction and feathering sequentially is adopted. Specifically, this includes: first, merging all blocks in each row one by one using the row as the reference and the method of merging in pairs; then, merging all blocks in each column one by one using the column as the reference and the method of merging in pairs; or first, merging all blocks in each column one by one using the column as the reference and the method of merging in pairs, and then merging all blocks in each row one by one using the row as the reference and the method of merging in pairs.
[0035] Based on the aforementioned scheme, the overlapping area of two blocks is determined according to the merging direction of the blocks, specifically including:
[0036] If the merging direction is horizontal, then the area formed between the right end of the current block and the left end of the next block in the horizontal direction is the overlapping area.
[0037] If the merging direction is vertical, then the area formed between the bottom of the current block and the top of the next block in the vertical direction is the overlapping area.
[0038] Based on the aforementioned scheme, after determining the overlapping area of the two blocks, the specific overlapping area is calculated according to the size of the current block and the coordinates of its upper left corner. The overlapping area is then feathered. The specific steps are as follows:
[0039] The transparency of the corresponding pixel positions within the overlapping region is calculated using linear interpolation.
[0040] If the merging direction is horizontal, then the transparency of the left and right edges of the overlapping area are respectively:
[0041] Alpha (左) =(W w -P i ) / W w ;
[0042] Alpha (右) =P i / W w ;
[0043] Among them, Alpha (左) Alpha (右) W represents the transparency of the left and right edges of the overlapping region, respectively. w P is the width of the overlapping region. i The pixel position;
[0044] If the merging direction is vertical, then the transparency of the upper and lower edges of the overlapping area are respectively:
[0045] Alpha (上) =(H h -P i ) / H h ;
[0046] Alpha (下) =P i / H h ;
[0047] Among them, Alpha (上) Alpha (下) H represents the transparency of the upper and lower edges of the overlapping region, respectively. h P is the height of the overlapping region. i The pixel position;
[0048] Based on the transparency, the pixel values of the two blocks are blended to obtain two blocks with a smooth transition.
[0049] The pixel values of the two blocks are blended by calculating a new color value for the current pixel position within the overlapping area. The specific calculation formula is as follows:
[0050] P (new) =Alpha (P) ×P (A) +(1-Alpha (P) )×P (B) ;
[0051] Among them, P (new) Alpha is the new color value for the current pixel position within the overlapping region. (P) P represents the transparency at the current pixel position. (A) P (B) These represent the color values of the corresponding pixels in the two blocks to be merged.
[0052] As can be seen from the above technical solution, compared with the prior art, the present invention has at least the following advantages and positive effects:
[0053] (1) By feathering the overlapping area, the present invention can completely eliminate the seam lines between image blocks, so that the image blocks can still maintain a highly consistent visual effect after merging.
[0054] (2) The present invention adopts a two-by-two merging method to gradually calculate the overlapping area between image blocks and perform feathering processing, which can effectively avoid the problem of unnatural color transition or loss of details, and achieve high-quality seamless image connection.
[0055] (3) This invention achieves seamless image slicing through feathering technology, which is easy to operate and can be quickly integrated into existing image processing systems. It can also adapt to various image enhancement tasks, making it highly efficient and easy to use. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below only involve some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 The flowchart illustrates a method for seamlessly stitching image slices based on feathering technology provided in an embodiment of the present invention.
[0058] Figure 2 A flowchart of an image block merging method provided by an embodiment of the present invention is shown;
[0059] Figure 3 The flowchart illustrates a method for feathering overlapping regions provided by an embodiment of the present invention.
[0060] Figure 4 This diagram illustrates the structure of a seamless image slicing system based on feathering technology provided in an embodiment of the present invention.
[0061] in, Figure 4 The annotations in the accompanying drawings are explained as follows:
[0062] 400 - A seamless image slicing system based on feathering technology; 401 - Image slicing module; 4011 - Image slicing processing unit; 4012 - Image coordinate calculation unit; 402 - Range determination module; 403 - Region calculation module; 404 - Feathering processing module; 4041 - Transparency calculation unit; 4042 - Pixel value calculation unit; 405 - Repeated iteration module. Detailed Implementation
[0063] To more clearly explain the purpose, technical solutions, and advantages of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein. On the contrary, these embodiments are provided so that the present invention will be more comprehensive and complete, and fully convey the concept of the exemplary embodiments to those skilled in the art.
[0064] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of the invention. However, those skilled in the art will recognize that the technical solutions of the invention can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of the invention.
[0065] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0066] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0067] The present invention will now be described in detail with reference to specific embodiments:
[0068] Example 1
[0069] like Figure 1 As shown in the figure, this invention provides a method for seamlessly stitching image slices based on feathering technology. The specific steps of this method are as follows:
[0070] S1: Slice the input image to obtain N blocks, and then calculate the coordinates of the top left corner of each block;
[0071] When processing images using super-resolution models or other AI enhancement techniques, it is often necessary to slice the image to fit the model's fixed input format. In this embodiment, before slicing the input image, image segmentation parameters are first calculated based on the size of the input image and the input size of the super-resolution model, so that the number of image segments can be determined subsequently based on these parameters.
[0072] Specifically, in this embodiment, the image segmentation parameters include: the number of rows in the slice, the number of columns in the slice, the horizontal offset, and the vertical offset; wherein, the number of rows and columns in the slice are calculated based on the size of the input image and the input size of the super-resolution model, and the specific calculation formula is as follows:
[0073] R = (H-1+h) / h;
[0074] C = (W-1+w) / w;
[0075] Where R is the number of rows in the slice, C is the number of columns in the slice, H is the height of the input image, W is the width of the input image, h is the height of the input dimension of the super-resolution model, and w is the width of the input dimension of the super-resolution model.
[0076] Furthermore, the horizontal and vertical offsets are calculated based on the number of rows and columns of the slice, the size of the input image, and the input size of the super-resolution model. The specific calculation formula is as follows:
[0077] If W ≤ w, then X = 0;
[0078] If W > w, then X = (W - w) / (C - 1);
[0079] If H ≤ h, then Y = 0;
[0080] If H > h, then Y = (H - h) / (R - 1);
[0081] Where X is the horizontal offset, Y is the vertical offset, W is the width of the input image, w is the input size width of the super-resolution model, H is the height of the input image, h is the input size height of the super-resolution model, R is the number of rows of the slice, and C is the number of columns of the slice.
[0082] Furthermore, after slicing the input image, N original image blocks are obtained; AI processing is performed on the original image blocks to obtain N AI-processed blocks; wherein, the AI processing includes, but is not limited to, super-resolution enhancement, black and white image colorization, image face enhancement, and lossless image magnification.
[0083] In this embodiment, the horizontal offset X and the vertical offset Y will be adjusted proportionally according to the size of the original image blocks and the blocks after AI processing. For example:
[0084] If the size of the original image block is 288*288, and the size of the block after AI processing is 1152*1152, then the size of the block after AI processing is 4 times larger than that of the original image block. Therefore, the horizontal offset X and the vertical offset Y also need to be increased by 4 times.
[0085] Furthermore, the top-left corner coordinates of each block are calculated based on the row and column indices, the horizontal offset, and the vertical offset. The specific calculation formula is as follows:
[0086] x = i × X;
[0087] y = j × Y;
[0088] Where x and y represent the horizontal and vertical coordinates of the top left corner of the block, respectively, i is the column index, j is the row index, X is the horizontal offset, and Y is the vertical offset.
[0089] S2: Using a pairwise merging method, the overlapping area of two blocks is determined according to the merging direction of the blocks;
[0090] Furthermore, the N blocks are merged pairwise. Preferably, in this embodiment, the N blocks are merged pairwise in the same direction, and then feathered sequentially.
[0091] like Figure 2 As shown, the first step is to merge pairs based on behavioral benchmarks, specifically including:
[0092] S201: Using the block in the first row and first column as the starting block of the first row, and taking the row as the reference, the starting block of the first row is merged with the first block to its right in a pairwise merging manner to obtain the first merged block;
[0093] S202: Using the first merged block as a new starting block, and based on the row, merge the new starting block with the first block to its right in a pairwise merging manner to obtain the second merged block;
[0094] S203: Repeat the iterative merging steps until all blocks in the first row are merged to obtain the merged blocks in the first row;
[0095] S204: Using the block in the first column of the second row as the starting block of the second row, and taking the row as the reference, merge the starting block of the second row with the first block to its right in a pairwise merging manner to obtain the third merged block;
[0096] S205: Repeat the iterative merging steps until all blocks in the second row are merged to obtain the merged blocks in the second row;
[0097] S306: Repeat the steps of merging rows based on rows until all rows have been merged.
[0098] S207: Using the column as the reference, take the first row merge block as the first column starting block, and merge the first column starting block with the second row merge block to obtain the first column merge block;
[0099] S208: Repeat the steps of merging within a column as a reference until all blocks within the column are merged to obtain the final merged image.
[0100] Specifically, let's take a specific merging scenario as an example to illustrate the block merging method used in this embodiment. Assume an image is divided into 3 rows and 3 columns, resulting in 9 blocks; the blocks in the first row are A1, A2, and A3; the blocks in the second row are B1, B2, and B3; and the blocks in the third row are C1, C2, and C3. Then, we first merge them pairwise based on the rows:
[0101] For the first row, starting from block A1, merge block A1 with block A2 to get block A12; further, merge block A12 with block A3 to get block A123;
[0102] For the second line, starting from block B1, merge block B1 with block B2 to get block B12; further, merge block B12 with block B3 to get block B123.
[0103] For the third line, starting from block C1, merge block C1 with block C2 to get block C12; further, merge block C12 with block C3 to get block C123.
[0104] Furthermore, after all rows have been merged within each row, pairwise merges are performed based on columns:
[0105] Starting with block A123, merge block A123 with block B123 to obtain block AB123; further, merge block AB123 with block C123 to obtain the final merged image.
[0106] Preferably, in this embodiment, the overlapping area of two blocks is determined according to the merging direction of the blocks, specifically as follows:
[0107] If the merging direction is horizontal, then the area formed between the right end of the current block and the left end of the next block in the horizontal direction is the overlapping area.
[0108] If the merging direction is vertical, then the area formed between the bottom of the current block and the top of the next block in the vertical direction is the overlapping area.
[0109] S3: Based on the size of the block and the coordinates of the upper left corner, the specific overlapping area is calculated;
[0110] Furthermore, after determining the overlapping area of the two blocks, the specific overlapping area is calculated based on the size of the current block and the coordinates of its top-left corner; for example:
[0111] Establish a rectangular coordinate system with the top left corner of the original image (i.e., the input image) as the origin. If the original image size H×W is 800*600, and it is divided into 288*288 blocks, then according to the formula in step S1, the top left corner coordinate of block 1 in the first row and first column is (0,0), and the top left corner coordinate of block 2 in the first row and second column is (156,0). Therefore, the top left corner coordinate of the overlapping area between block 1 and block 2 is (153,0), and the bottom right corner coordinate is (288,288).
[0112] S4: Feather the overlapping region to obtain two blocks with a smooth transition;
[0113] Furthermore, after obtaining the specific overlapping regions, the overlapping regions are feathered; preferably, in this embodiment, linear interpolation is used to smooth the transition during feathering. Figure 3 As shown, feathering is applied to the overlapping regions, specifically including:
[0114] S301: Determine the merging direction of two blocks;
[0115] S302: If the merging direction is horizontal, calculate the transparency of the left and right edges of the overlapping area to obtain the transparency of the corresponding pixel positions of the two blocks; if the merging direction is vertical, calculate the transparency of the top and bottom edges of the overlapping area to obtain the transparency of the corresponding pixel positions of the two blocks.
[0116] S303: Based on the transparency of the corresponding pixel positions of the two blocks, the pixel values of the two blocks are mixed to obtain two blocks with a smooth transition.
[0117] Specifically, in this embodiment, the calculation formulas for the transparency of the left and right edges of the overlapping region are as follows:
[0118] Alpha (左) =(W w -P i ) / W w ;
[0119] Alpha (右) =P i / W w ;
[0120] Among them, Alpha (左) Alpha (右) W represents the transparency of the left and right edges of the overlapping region, respectively. w P is the width of the overlapping region. i The pixel position;
[0121] The calculation formulas for the transparency of the upper and lower edges of the overlapping area are as follows:
[0122] Alpha (上) =(H h -P i ) / H h ;
[0123] Alpha (下) =P i / H h ;
[0124] Among them, Alpha (上) Alpha (下) H represents the transparency of the upper and lower edges of the overlapping region, respectively. h P is the height of the overlapping region. i The pixel position;
[0125] Preferably, in this embodiment, the pixel values of the two blocks are mixed by calculating a new color value for the current pixel position within the overlapping area. The specific calculation formula is as follows:
[0126] P (new) =Alpha (P) ×P (A) +(1-Alpha (P) )×P (B) ;
[0127] Among them, P (new) Alpha is the new color value for the current pixel position within the overlapping region. (P) P represents the transparency at the current pixel position. (A) P (B) These represent the color values of the corresponding pixels in the two blocks to be merged.
[0128] S5: Repeat the steps of determining the range of overlapping regions, calculating overlapping regions, and feathering until all overlapping regions are feathered to obtain the final seamlessly fused image.
[0129] In this embodiment, whenever two blocks are merged, the steps of determining the overlapping area, calculating the overlapping area, and feathering are required. The two blocks to be merged are then smoothly transitioned before the next merge is performed. This process continues until the last block is merged and the feathering is completed, resulting in a final seamlessly fused image.
[0130] The seamless image slicing method described in this invention calculates the overlapping area between image blocks step by step and performs feathering processing by merging them in pairs. This not only effectively avoids problems such as unnatural color transitions or loss of detail, but also completely eliminates the seams between image blocks, so that the merged image blocks can still maintain a highly consistent visual effect and achieve high-quality seamless image slicing.
[0131] Example 2
[0132] like Figure 4 As shown, this embodiment of the invention provides a seamless image slicing system 400 based on feathering technology. The system includes: an image slicing module 401, a range determination module 402, a region calculation module 403, a feathering processing module 404, and a repetitive iteration module 405; wherein:
[0133] Image slicing module 401 is used to slice the input image, obtain N blocks, and then calculate the coordinates of the top left corner of each block;
[0134] In this embodiment, before slicing the input image, it is first necessary to calculate the image segmentation parameters based on the size of the input image and the input size of the super-resolution model, so that the number of image segments can be determined according to the image segmentation parameters. The image segmentation parameters include: the number of rows of the slice, the number of columns of the slice, the horizontal offset, and the vertical offset.
[0135] Image slicing module 401 includes: image slicing processing unit 4011 and image coordinate calculation unit 4012; wherein:
[0136] The image slicing processing unit 4011 described above is configured to slice the input image to obtain N blocks;
[0137] The aforementioned image coordinate calculation unit 4012 is configured to calculate the coordinates of the upper left corner of each block based on the image block parameters.
[0138] The range determination module 402 is used to determine the overlapping area range of two blocks by merging them in pairs according to the merging direction of the blocks.
[0139] Preferably, in this embodiment, when merging the N blocks pairwise, a method of merging one by one in the same direction and feathering sequentially is adopted; the overlapping area of two blocks is determined according to the merging direction of the blocks, specifically as follows:
[0140] If the merging direction is horizontal, then the area formed between the right end of the current block and the left end of the next block in the horizontal direction is the overlapping area.
[0141] If the merging direction is vertical, then the area formed between the bottom of the current block and the top of the next block in the vertical direction is the overlapping area.
[0142] The region calculation module 403 is used to calculate the specific overlapping region based on the size of the block and the coordinates of the upper left corner;
[0143] Furthermore, after determining the overlapping area of the two blocks, the region calculation module 403 calculates the specific overlapping area based on the size of the current block and the coordinates of the upper left corner, so that the overlapping area can be feathered in a targeted manner in the future.
[0144] Feathering module 404 is used to feather the overlapping area to obtain two blocks with smooth transition;
[0145] Furthermore, after obtaining the specific overlapping region, the overlapping region is feathered by the feathering processing module 404; preferably, in this embodiment, linear interpolation is used to perform a smooth transition when feathering.
[0146] Feathering processing module 404 includes: transparency calculation unit 4041 and pixel value blending unit 4042; wherein:
[0147] The aforementioned transparency calculation unit 4041 is configured to: calculate the transparency of corresponding pixel positions within the overlapping area using linear interpolation;
[0148] The aforementioned pixel value mixing unit 4042 is configured to: mix the pixel values of the two blocks based on the transparency of the corresponding pixel position to obtain two blocks with a smooth transition.
[0149] The iterative module 405 is used to iteratively determine the range of the overlapping region, calculate the overlapping region, and perform feathering until all the overlapping regions are feathered, resulting in a final seamlessly fused image.
[0150] In this embodiment, whenever two blocks are merged, the steps of determining the overlapping area, calculating the overlapping area, and feathering are required. The two blocks to be merged are then smoothly transitioned before the next merge is performed. This process continues until the last block is merged and the feathering is completed, resulting in a final seamlessly fused image.
[0151] In this embodiment, the overlapping area range is determined by the range determination module 402, the specific overlapping area is calculated by the region calculation module 403, and the overlapping area is feathered by the feathering processing module 404. This allows for targeted processing of the overlapping areas between blocks, effectively avoiding unnatural color transitions or loss of detail. At the same time, the linear interpolation method is used to achieve a smooth transition, which can completely eliminate the seams between image blocks, so that the image blocks can still maintain a highly consistent visual effect after merging, achieving high-quality seamless image connection. It is also easy to operate, adaptable to various image enhancement tasks, and is highly efficient and easy to use.
[0152] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the claims. It should be understood that the invention is not limited to the precise structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A method for seamlessly stitching image slices based on feathering technology, characterized in that, Includes the following steps: The input image is sliced to obtain N blocks, and then the coordinates of the top left corner of each block are calculated. The overlapping area of two blocks is determined by merging them in pairs according to the merging direction of the blocks. Based on the size of the block and the coordinates of the upper left corner, the specific overlapping area is calculated; The overlapping region is feathered to obtain two smoothly transitioned blocks; specifically including: The transparency of the corresponding pixel positions within the overlapping area is calculated using linear interpolation. Based on the transparency, the pixel values of the two blocks are blended to obtain two blocks with a smooth transition; The calculation of the transparency of corresponding pixel positions within the overlapping region is performed using the height or width of the overlapping region, specifically including: If the merging direction is horizontal, then the transparency of the left and right edges of the overlapping area are respectively: ; ; in, , The transparency of the left and right edges of the overlapping region are respectively. The width of the overlapping region. The pixel position; If the merging direction is vertical, then the transparency of the upper and lower edges of the overlapping area are respectively: ; ; in, , The transparency of the upper and lower edges of the overlapping area are respectively. The height of the overlapping region. The pixel position; The steps of determining the range of overlapping regions, calculating overlapping regions, and feathering are repeated iteratively until all overlapping regions are feathered, resulting in a final seamlessly fused image.
2. The method for seamlessly connecting image slices according to claim 1, characterized in that, When slicing the input image, the number of slices is determined by the number of rows and columns of the slices; the number of rows and columns of the slices is calculated based on the size of the input image and the input size of the super-resolution model, and the specific calculation formula is as follows: ; ; Where R is the number of rows in the slice, C is the number of columns in the slice, H is the height of the input image, W is the width of the input image, h is the height of the input dimension of the super-resolution model, and w is the width of the input dimension of the super-resolution model.
3. The method for seamlessly connecting image slices according to claim 1, characterized in that, When slicing the input image, the horizontal and vertical offsets are calculated based on the number of rows and columns of the slice, the size of the input image, and the input size of the super-resolution model. Specifically: like ≤ ,but ; like > ,but ; like ≤ ,but ; like > ,but ; Where X is the horizontal offset, Y is the vertical offset, W is the width of the input image, w is the input size width of the super-resolution model, H is the height of the input image, h is the input size height of the super-resolution model, R is the number of rows of the slice, and C is the number of columns of the slice.
4. The method for seamlessly connecting image slices according to claim 1, characterized in that, The calculation of the top-left corner coordinates of each block is based on the row and column indices, the horizontal offset, and the vertical offset, using the following formula: ; ; Where x and y represent the horizontal and vertical coordinates of the top left corner of the block, respectively, i is the column index, j is the row index, X is the horizontal offset, and Y is the vertical offset.
5. The method for seamlessly connecting image slices according to claim 1, characterized in that, When merging the N blocks in pairs, the merging is performed one by one in the same direction and feathering is performed sequentially.
6. The method for seamlessly connecting image slices according to claim 1, characterized in that, Determining the overlapping area of two blocks based on the merging direction of the blocks specifically includes: If the merging direction is horizontal, then the area formed between the right end of the current block and the left end of the next block in the horizontal direction is the overlapping area. If the merging direction is vertical, then the area formed between the bottom of the current block and the top of the next block in the vertical direction is the overlapping area.
7. The method for seamlessly connecting image slices according to claim 1, characterized in that, The pixel values of the two blocks are blended by calculating a new color value for the current pixel position within the overlapping area. The specific calculation formula is as follows: ; in, The new color value for the current pixel position within the overlapping region. The transparency at the current pixel position. , These represent the color values of the corresponding pixels in the two blocks to be merged.
8. A seamless image slicing system based on feathering technology, characterized in that, include: The image slicing module is used to slice the input image, obtain N blocks, and then calculate the top-left corner coordinates of each block. The range determination module is used to determine the overlapping area range of two blocks by merging them in pairs according to the merging direction of the blocks; The region calculation module is used to calculate the specific overlapping region based on the size of the block and the coordinates of the upper left corner; The feathering module is used to feather the overlapping region to obtain two smoothly transitioned blocks; specifically, it includes: The transparency of the corresponding pixel positions within the overlapping area is calculated using linear interpolation. Based on the transparency, the pixel values of the two blocks are blended to obtain two blocks with a smooth transition; The calculation of the transparency of corresponding pixel positions within the overlapping region is performed using the height or width of the overlapping region, specifically including: If the merging direction is horizontal, then the transparency of the left and right edges of the overlapping area are respectively: ; ; in, , The transparency of the left and right edges of the overlapping region are respectively. The width of the overlapping region. The pixel position; If the merging direction is vertical, then the transparency of the upper and lower edges of the overlapping area are respectively: ; ; in, , The transparency of the upper and lower edges of the overlapping area are respectively. The height of the overlapping region. The pixel position; The iterative module is used to repeatedly iterate the steps of determining the range of overlapping regions, calculating overlapping regions, and feathering until all the overlapping regions are feathered, resulting in a final seamlessly fused image.
Citation Information
Patent Citations
Outline-based transparency gradient image matting method
CN105976371A
Picture enhancement method and device, equipment and medium
CN116630191A