A method, system, terminal and medium for segmenting an image to generate a jigsaw cutting path

By segmenting an image into rectangular elements and obtaining the vertices coordinates and edge concavity/convexity states to generate a cropping path, the problem of traditional jigsaw puzzle software being unable to independently edit elements is solved, achieving efficient cropping and low-cost production.

CN119323579BActive Publication Date: 2026-04-17浪潮智慧科技有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
浪潮智慧科技有限公司
Filing Date
2024-09-29
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Traditional jigsaw puzzle processing software struggles to independently edit each puzzle element and cannot efficiently generate cutting paths, resulting in low generation efficiency and high costs.

Method used

By segmenting the image into rectangular elements, obtaining the vertices coordinates and the concavity/convexity state of each element, and generating a cropping path, individual editing and cropping of any jigsaw puzzle element can be achieved.

Benefits of technology

It improves the cutting efficiency of puzzle pieces, reduces labor and material costs, and enables rapid cutting and efficient production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119323579B_ABST
    Figure CN119323579B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image cropping, specifically disclosing a method, system, terminal, and medium for segmenting an image to generate a jigsaw puzzle cropping path. The method involves initial segmentation of elements based on element parameters, dividing each element into rectangles; these parameters include the number of rows, columns, and image size. The coordinates of the four corners of each element are obtained from the initial segmentation results and stored in a coordinate file. The concavity / convexity state of each edge of each element is configured. A cropping path is generated based on the concavity / convexity state of each edge of each element and the coordinates of its four corners. This invention enables individual editing of any jigsaw puzzle element, thereby generating a cropping path that can be directly applied to the generated image, improving generation efficiency and reducing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image cropping, and more specifically to a method, system, terminal, and medium for segmenting an image to generate a mosaic cropping path. Background Technology

[0002] In the field of digital image processing, image mosaicking is a common image processing method. It not only transforms complex images into easily understandable and manipulable fragments, but also stimulates users' creativity and logical thinking abilities through the process of recombining these fragments.

[0003] Traditional jigsaw puzzle processing software typically focuses on the segmentation and recombination of the overall image, creating a jigsaw puzzle effect on the original image by overlaying and cutting layers. While this method can quickly generate a basic jigsaw puzzle image, it is difficult to independently edit each puzzle element during the processing. It is impossible to modify individual puzzle elements. The traditional layer-based method of generating jigsaw puzzle images is inefficient and cannot edit elements independently. Summary of the Invention

[0004] To address the aforementioned problems, this invention provides a method, system, terminal, and medium for segmenting images to generate jigsaw puzzle cropping paths. This enables individual editing of any jigsaw puzzle element, thereby generating cropping paths that can be directly applied to the generated path, improving generation efficiency and reducing costs.

[0005] In a first aspect, the technical solution of the present invention provides a method for segmenting an image to generate a mosaic cropping path, comprising the following steps:

[0006] The components are initially segmented based on their parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size.

[0007] Based on the initial segmentation results, obtain the coordinate values ​​of the four vertex corners of each element and store them in a coordinate file;

[0008] Configure the bump and concave state of each edge of each component;

[0009] The clipping path is generated based on the concavity / convexity of each edge of each element and the coordinates of the four vertices of each element.

[0010] In an optional implementation, obtaining the coordinate values ​​of the four vertex corners of each element based on the initial element segmentation result includes the following steps:

[0011] Construct a coordinate array for each element. The coordinate array contains four elements, which represent the coordinate values ​​of the four corners of the element.

[0012] Initialize each coordinate array;

[0013] Update the coordinate array based on the actual coordinate values ​​of the four corners of the obtained element.

[0014] In an optional implementation, the concave / convex state of each edge of each element is configured, specifically including:

[0015] Conveyor-bump state array is constructed for each component. The convection-bump state array contains four elements, which represent the convection-bump state of the four sides of the component.

[0016] Initialize each concave / convex state array;

[0017] Configure bump and concave constraints for each component, including that the top edge of the component cannot have bumps or concave surfaces, the right edge of the component cannot have bumps or concave surfaces, the bottom edge of the component cannot have bumps or concave surfaces, and the left edge of the component cannot have bumps or concave surfaces.

[0018] Configure the concave / convex state of each edge of each element based on concave / convex constraints;

[0019] Update the bump state array based on the bump state of each edge of the component.

[0020] In an optional implementation, the concavity / convexity state of each edge of each element is configured based on concavity / convexity constraints, specifically including:

[0021] Iterate through the elements starting from the first element, checking the bump and concave limits of the current element;

[0022] If a certain edge of the current element cannot be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is set to 0, indicating that the concave or convex state of the current edge is a straight line.

[0023] If a certain edge of the current element can be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is randomly configured to 1 or -1, where 1 indicates that the concave or convex state of the current edge is convex and -1 indicates that the concave or convex state of the current edge is concave.

[0024] After traversing all components, the adjacent edges of the components are verified, and the concave-convex state array of the corresponding components is updated again according to the verification results to ensure that the adjacent edges meet the concave-convex pairing.

[0025] In an optional implementation, the element representing the current edge convexity / concave state in the current element's convexity / concave state array is randomly configured to 1 or -1, specifically including:

[0026] The classification threshold is determined based on the range of values ​​generated by the random number generation function;

[0027] Generate a random number using a random number generator function on the current edge;

[0028] Determine whether the generated random number is greater than the classification threshold;

[0029] If so, the element representing the current edge's concavity / convexity state in the current element's concavity / convexity state array will be randomly configured to 1; otherwise, it will be configured to -1.

[0030] In an optional implementation, adjacent edges of the components are verified, and the concave / convex state array of the corresponding components is updated again based on the verification results to ensure that adjacent edges conform to concave / convex pairing. Specifically, this includes:

[0031] Iterate through all elements in turn and check whether the concavity / convexity state of the first edge of the current element is 0;

[0032] If the value is 0, traverse the second edge of the current element;

[0033] If it is not 0, check if the concavity / convexity state of the current edge is 1;

[0034] If it is 1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is -1. If it is, the concave / convex state of the two edges is a concave / convex pair. Otherwise, modify the concave / convex state of the current edge of the current element to -1, or modify the concave / convex state of the corresponding edge of the adjacent element to 1.

[0035] If it is -1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is 1. If it is, the concave / convex state of the two edges matches the concave / convex pairing. Otherwise, change the concave / convex state of the current edge of the current element to 1, or change the concave / convex state of the corresponding edge of the adjacent element to -1.

[0036] In an optional implementation, a clipping path is generated based on the concavity / convexity state of each edge of each element and the coordinate values ​​of the four vertex corners of each element, specifically including:

[0037] Check if the current edge of the current element has an adjacent edge;

[0038] If there are no adjacent edges, execute the edge clipping path procedure, which includes obtaining the coordinate values ​​of the two vertices of the current edge from the coordinate file, detecting the concavity / convexity state of the current edge, and if the concavity / convexity state is 0, using the line drawing function to draw a line segment based on the coordinate values ​​of the two vertices to generate the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; if the concavity / convexity state is 1 or -1, calculating the center coordinate value based on the coordinate values ​​of the two vertices, configuring the drawing direction flag according to the concavity / convexity state, using the arc drawing function to draw a line segment containing an arc based on the coordinate values ​​of the two vertices, the center coordinate value, the drawing direction flag, and a preset radius to generate the clipping path of the current edge, and configuring the path generation flag of the current edge as generated;

[0039] If there are adjacent edges, check whether the path generation identifier of the adjacent edges has been generated;

[0040] If yes, iterate through the next edge of the current edge; otherwise, perform the edge trimming path procedure based on the current edge.

[0041] Secondly, the technical solution of the present invention provides a system for segmenting an image to generate a mosaic cropping path, implemented based on the method described in any one of the above claims, the system comprising:

[0042] Initial segmentation module: Performs initial segmentation of components based on component parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size.

[0043] Coordinate acquisition module: Based on the initial segmentation result of the components, obtain the coordinate values ​​of the four vertex corners of each component and store them in the coordinate file;

[0044] Concave / convex state configuration module: Configures the concave / convex state of each edge of each component;

[0045] The trimming path generation module generates trimming paths based on the concavity and convexity of each edge of each element and the coordinate values ​​of the four vertices of each element.

[0046] Thirdly, the technical solution of the present invention provides a terminal, comprising:

[0047] Memory, used to store the program that segments the image to generate the mosaic cropping path;

[0048] The processor, when executing the program for segmenting the image to generate a jigsaw puzzle cropping path, implements the steps of the method for segmenting the image to generate a jigsaw puzzle cropping path as described in any of the preceding claims.

[0049] Fourthly, the present invention provides a computer-readable storage medium storing a program for segmenting an image to generate a jigsaw puzzle cropping path, wherein when the program for segmenting an image to generate a jigsaw puzzle cropping path is executed by a processor, the program implements the steps of the method for segmenting an image to generate a jigsaw puzzle cropping path as described in any of the preceding claims.

[0050] This invention provides a method, system, terminal, and medium for segmenting images to generate jigsaw puzzle cutting paths. Compared with existing technologies, it has the following advantages: It generates initial jigsaw puzzle elements and their coordinates based on a specified number of rows and columns and image size. Then, it sets the edge concavity / convexity based on the configured concavity / convexity state of each edge of each element. Individual jigsaw puzzle elements can be edited without multiple layers. Furthermore, it automatically generates cutting paths based on the concavity / convexity state. The generated cutting paths can be directly used for user production, effectively improving jigsaw puzzle drawing and cutting efficiency, enabling rapid cutting of a large number of jigsaw puzzle elements, greatly improving production efficiency, and reducing labor costs and material waste. Attached Figure Description

[0051] To more clearly illustrate the technical solutions of 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 are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is a schematic flowchart of a method for segmenting an image to generate a jigsaw puzzle cropping path, provided by an embodiment of the present invention.

[0053] Figure 2 This is a schematic diagram of the generated clipping path.

[0054] Figure 3 This is a schematic diagram of a system structure for segmenting an image to generate a jigsaw puzzle cropping path, provided by an embodiment of the present invention.

[0055] Figure 4 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation

[0056] To enable those skilled in the art to better understand the present invention, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0058] Figure 1 This is a schematic flowchart of a method for segmenting an image to generate a mosaic cropping path according to an embodiment of the present invention. Figure 1 The executing entity can be a system for segmenting an image to generate a jigsaw puzzle cropping path. The method for segmenting an image to generate a jigsaw puzzle cropping path provided in this embodiment of the invention is executed by a computer device; correspondingly, the system for segmenting an image to generate a jigsaw puzzle cropping path runs on the computer device. Depending on different needs, the order of the steps in this flowchart can be changed, and some can be omitted.

[0059] like Figure 1 As shown, the method includes the following steps.

[0060] S1, perform initial component segmentation based on component parameters, dividing each component into rectangles.

[0061] In this embodiment, the component parameters include the number of rows, the number of columns, and the image size. In an optional implementation, the user inputs the number of rows, the number of columns, and the image size on the human-computer interaction interface. The background automatically performs preliminary segmentation of the image based on these parameters, dividing the image into rectangular components with each row multiplied by the number of columns. At this point, all four sides of the rectangular components are straight lines.

[0062] S2: Obtain the coordinate values ​​of the four vertices of each element based on the initial element segmentation result, and store them in the coordinate file.

[0063] S2.1 Construct a coordinate array for each element. The coordinate array contains four elements, which represent the coordinate values ​​of the four corners of the element.

[0064] S2.2, initialize each coordinate array.

[0065] S2.3 Update the coordinate array based on the actual coordinate values ​​of the four vertices of the obtained element.

[0066] In this embodiment, a cropping path is generated based on coordinate values. After generating the initial elements, the coordinate values ​​of the four vertices of each element are generated according to the image size and the number of rows and columns. To facilitate the saving and subsequent retrieval of coordinate values, a coordinate array is constructed for each element. The coordinate array contains four elements, representing the coordinate values ​​of the four corners of the element. For example, the first to fourth elements represent the coordinate values ​​of the top left, top right, bottom right, and bottom left corners, respectively. After construction, the array is first initialized, for example, all values ​​are set to 0. Then, the actual coordinates are updated to the coordinate array. The coordinate array is stored in a coordinate file.

[0067] S3 configures the bump / concave state of each edge of each element.

[0068] It is understood that the four sides of a component can be raised, recessed, or straight. This embodiment determines the shape of the edge by configuring the raised / recessed state of each edge of each component. Specifically, it does so by configuring a raised / recessed state array, where different values ​​represent different shapes. The specific steps include the following steps.

[0069] S3.1, construct a convex / concave state array for each element.

[0070] In this embodiment, the concave-convex state array contains four elements, which respectively represent the concave-convex state of the four sides of the element. For example, the first to fourth elements represent the concave-convex state of the top, right, bottom and left sides, respectively.

[0071] S3.2, initialize each concave / convex state array.

[0072] In this embodiment, after constructing the concave-convex state array, it is initialized and then updated according to the actual configuration. For example, all elements are initialized to 0. The exemplary initialized concave-convex state array is [0,0,0,0].

[0073] S3.3, configure bump and concave constraints for each component.

[0074] The concave / convexity restrictions include that no concave / convexity can appear on the top edge of the component, no concave / convexity can appear on the right side of the component, no concave / convexity can appear on the bottom edge of the component, and no concave / convexity can appear on the left side of the component.

[0075] S3.4 Configure the concave / convex state of each edge of each element based on the concave / convex constraint conditions.

[0076] In this embodiment, 0 represents a straight line, 1 represents a convexity, and -1 represents a concaveness. After initializing the concave-convex state array, random numbers are generated through a random number generation function to generate the concave-convex state. The specific steps include the following steps.

[0077] S3.4.1, start traversing from the first element and detect the bump and concave limits of the current element.

[0078] S3.4.2 If a certain edge of the current element cannot be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is configured to 0, indicating that the concave or convex state of the current edge is a straight line.

[0079] In this embodiment, the concave and convex limits of the components are configured in advance according to the position of the components. Specifically, the concave and convex limits of each side of the components are configured. For example, a concave and convex limit mark is configured for each side of each component. The first mark is unrestricted, the second mark is restricted, and concave and convex limits cannot occur. The side should be a straight line.

[0080] S3.4.3 If a certain edge of the current element can be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is randomly configured to 1 or -1, where 1 indicates that the concave or convex state of the current edge is convex and -1 indicates that the concave or convex state of the current edge is concave.

[0081] In this embodiment, the classification threshold is first determined based on the range of values ​​generated by the random number generation function. Then, a random number is generated for the current edge using the random number generation function. It is then determined whether the generated random number is greater than the classification threshold. If so, the element representing the concave-convex state of the current edge in the concave-convex state array of the current element is randomly configured to 1; otherwise, it is configured to -1.

[0082] For example, starting from the top left element, traverse the four edges of the element in turn, from top to bottom to left. For each edge, use the Math.random() function (this function is a built-in function of the browser script execution environment, which returns a random decimal between 0 and 1 each time it is called) to determine a decimal. Check if the decimal is greater than 0.5. If it is greater than 0.5, the edge is convex; if it is less than or equal to 0.5, the edge is concave.

[0083] S3.4.4 After traversing all components, the adjacent edges of the components are checked, and the concave-convex state array of the corresponding components is updated again according to the check results to make the adjacent edges conform to the concave-convex pairing.

[0084] It should be noted that in this embodiment, the concave and convex states of each edge of each component are first randomly generated, but the concave and convex states of adjacent edges should be configured, that is, one side should be concave and the other side should be convex. Therefore, after random generation, it is necessary to verify the concave and convex states of adjacent edges to ensure that adjacent edges meet the concave and convex pairing.

[0085] S3.4.4.1, iterate through all elements in turn and check whether the concavity / convexity state of the first edge of the current element is 0.

[0086] S3.4.4.1, if it is 0, traverse the second edge of the current element.

[0087] S3.4.4.2, if not 0, check if the concavity / convexity state of the current edge is 1.

[0088] S3.4.4.3, if it is 1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is -1. If it is, the concave / convex state of the two current edges matches the concave / convex pairing. Otherwise, modify the concave / convex state of the current edge of the current element to -1, or modify the concave / convex state of the corresponding edge of the adjacent element to 1.

[0089] S3.4.4.4, if it is -1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is 1. If it is, the concave / convex state of the two current edges matches the concave / convex pairing. Otherwise, modify the concave / convex state of the current edge of the current element to 1, or modify the concave / convex state of the corresponding edge of the adjacent element to -1.

[0090] For example, a simple for loop is used to iterate through and process the elements sequentially. Assume there is element A, with one element adjacent to each of its four sides (if A is at the edge of the puzzle, the corresponding edge has no adjacent element and its state remains straight). The four sides of element A (top, right, bottom, left) and the edge of the adjacent element B are checked. If the edge of A is concave, the corresponding edge of B is convex, and vice versa. This embodiment achieves concave-convex matching by detecting the elements in the concave-convex state array of each element, improving operational convenience and processing efficiency.

[0091] S3.5 Update the bump state array based on the bump state of each edge of the component.

[0092] Finally, the final concave-convex state is updated to the concave-convex state array to obtain the final concave-convex state of each edge of each element that satisfies the concave-convex constraints and the concave-convex matching of adjacent edges.

[0093] S4 generates a clipping path based on the concavity / convexity of each edge of each element and the coordinate values ​​of the four vertices of each element.

[0094] This embodiment is based on the concave-convex state and uses a drawing function to generate a clipping path. The coordinate values ​​of each vertex of the edge are stored in the coordinate file. When drawing the line, the coordinate values ​​in the coordinate file are used for drawing. Specifically, it includes the following steps.

[0095] S4.1, Detect whether the current edge of the current element has an adjacent edge.

[0096] S4.2 If there are no adjacent edges, execute the edge trimming path procedure, including obtaining the coordinate values ​​of the two vertices of the current edge from the coordinate file, detecting the concavity / convexity state of the current edge, if the concavity / convexity state is 0, using the line drawing function to draw a line segment based on the coordinate values ​​of the two vertices, generating the trimming path of the current edge, and configuring the path generation flag of the current edge as generated; if the concavity / convexity state is 1 or -1, calculating the center coordinate value based on the coordinate values ​​of the two vertices, configuring the drawing direction flag according to the concavity / convexity state, using the arc drawing function to draw a line segment containing an arc based on the coordinate values ​​of the two vertices, the center coordinate value, the drawing direction flag, and the preset radius, generating the trimming path of the current edge, and configuring the path generation flag of the current edge as generated.

[0097] S4.3 If there are adjacent edges, check whether the path generation identifier of the adjacent edges has been generated.

[0098] S4.4 If yes, iterate through the next edge of the current edge; otherwise, perform the edge trimming path procedure based on the current edge.

[0099] Figure 2 This is a schematic diagram of the generated clipping path. It should be noted that adjacent edges of adjacent elements only need to be drawn once. Therefore, the process first checks if the current edge has an adjacent edge. If so, it checks if the path of that adjacent edge has already been drawn. If it has, no further drawing is needed; otherwise, the edge clipping path program is executed to generate the clipping path for the current edge. In this embodiment, after generating the clipping path, the current edge path generation flag is configured as "generated" to facilitate subsequent checks on whether adjacent edges have generated clipping paths.

[0100] In one optional implementation, the method for generating jigsaw puzzle clipping paths in this embodiment is used in a web application. The path information includes two types: 1. line segments; 2. line segments with depressions or convexities. The browser script environment provides basic graphics drawing APIs (draw lines: lineTo, draw arcs: arc), and the corresponding drawing can be completed by using the point information belonging to the line.

[0101] Line segment: The position information of two points (x1, y1) and (x2, y2).

[0102] Line segments with indentations or convexities: the center and position of the arc (cx, cy), the arc radius r, the radian length rad, and the identifier direction to indicate whether it is drawn clockwise or counterclockwise. A convex arc can be drawn clockwise, and an indented arc can be drawn counterclockwise.

[0103] In this embodiment, the position information of two points on a line segment refers to the positions of the two endpoints of the current edge, which are also the positions of the corresponding two vertices of the element. For example, the position information of the two points on the top edge refers to the positions of the upper left and upper right vertices. When drawing an arc, the center of the arc is the midpoint between the two endpoints of the current edge, and the arc radius can be preset as needed. The drawing direction indicator is either clockwise or counterclockwise; clockwise draws a convex arc, and counterclockwise draws a concave arc.

[0104] In one optional implementation, the cutting path information is the line segment information and arc information required for drawing the line. The cutting path information is saved as a JSON file, which can be imported into the jigsaw puzzle cutting machine for cutting.

[0105] The foregoing has described in detail an embodiment of a method for segmenting an image to generate a jigsaw puzzle cropping path. Based on the method for segmenting an image to generate a jigsaw puzzle cropping path described in the above embodiment, this invention also provides a system for segmenting an image to generate a jigsaw puzzle cropping path corresponding to the method.

[0106] Figure 3 This is a schematic diagram of a system structure for segmenting an image to generate a jigsaw puzzle cropping path according to an embodiment of the present invention. The system 300 for segmenting an image to generate a jigsaw puzzle cropping path can be divided into multiple functional modules according to its functions. A module, as referred to in this invention, is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory.

[0107] Initial segmentation module 310: Performs initial segmentation of components based on component parameters, dividing each component into rectangles; where component parameters include the number of rows, the number of columns, and the image size.

[0108] Coordinate acquisition module 320: Based on the initial segmentation result of the components, obtain the coordinate values ​​of the four vertex corners of each component and store them in the coordinate file.

[0109] Concave / convex state configuration module 330: Configures the concave / convex state of each edge of each element.

[0110] Cutting path generation module 340: Generates a cutting path based on the concavity / convexity state of each edge of each element and the coordinate values ​​of the four vertices of each element.

[0111] The system for segmenting images to generate jigsaw puzzle cropping paths in this embodiment is used to implement the aforementioned method for segmenting images to generate jigsaw puzzle cropping paths. Therefore, the specific implementation of this system can be found in the embodiment section of the method for segmenting images to generate jigsaw puzzle cropping paths described above. Thus, the specific implementation can be referred to the description of the corresponding embodiments, and will not be elaborated here.

[0112] Furthermore, since the system for segmenting images to generate jigsaw puzzle clipping paths in this embodiment is used to implement the aforementioned method for segmenting images to generate jigsaw puzzle clipping paths, its function corresponds to the function of the above method, and will not be described again here.

[0113] Figure 4 A schematic diagram of a terminal 400 provided in an embodiment of the present invention includes: a processor 410, a memory 420, and a communication unit 430. The processor 410, when implementing a program to generate a mosaic cropping path from a segmented image stored in the memory 420, performs the following steps:

[0114] The components are initially segmented based on their parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size.

[0115] Based on the initial segmentation results, obtain the coordinate values ​​of the four vertex corners of each element and store them in a coordinate file;

[0116] Configure the bump and concave state of each edge of each component;

[0117] The clipping path is generated based on the concavity / convexity of each edge of each element and the coordinates of the four vertices of each element.

[0118] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0119] A computer storage medium stores a program for segmenting an image to generate a jigsaw puzzle cropping path. When the program for segmenting an image to generate a jigsaw puzzle cropping path is executed by a processor, it performs the following steps:

[0120] The components are initially segmented based on their parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size.

[0121] Based on the initial segmentation results, obtain the coordinate values ​​of the four vertex corners of each element and store them in a coordinate file;

[0122] Configure the bump and concave state of each edge of each component;

[0123] The clipping path is generated based on the concavity / convexity of each edge of each element and the coordinates of the four vertices of each element.

[0124] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0125] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0126] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0127] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0128] The above-disclosed embodiments are merely preferred embodiments of the present invention, but the present invention is not limited thereto. Any non-creative variations that can be conceived by those skilled in the art, as well as any improvements and modifications made without departing from the principles of the present invention, should fall within the protection scope of the present invention.

Claims

1. A method for segmenting an image to generate a mosaic clipping path, characterized in that, Includes the following steps: The components are initially segmented based on their parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size. Based on the initial segmentation results, obtain the coordinate values ​​of the four vertex corners of each element and store them in a coordinate file; Configure the bump and concave state of each edge of each component; The clipping path is generated based on the concavity and convexity of each edge of each element and the coordinate values ​​of the four vertices of each element. Obtaining the coordinates of the four vertex corners of each element based on the initial element segmentation results includes the following steps: Construct a coordinate array for each element. The coordinate array contains four elements, which represent the coordinate values ​​of the four corners of the element. Initialize each coordinate array; Update the coordinate array based on the actual coordinate values ​​of the four vertices of the obtained component; Configure the bump and concave state of each edge of each component, specifically including: Conveyor-bump state array is constructed for each component. The convection-bump state array contains four elements, which represent the convection-bump state of the four sides of the component. Initialize each concave / convex state array; Configure bump and recess constraints for each component, where the bump and recess constraints include: no bumps or recesses on the top edge of the component, no bumps or recesses on the right side of the component on the right edge, no bumps or recesses on the bottom edge of the component, and no bumps or recesses on the left side of the component on the left edge. Configure the concave / convex state of each edge of each element based on concave / convex constraints; Update the bump state array based on the bump state of each edge of the component; The concavity / convexity state of each edge of each component is configured based on concavity / convexity constraints, specifically including: Iterate through the elements starting from the first element, checking the bump and concave limits of the current element; If a certain edge of the current element cannot be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is set to 0, indicating that the concave or convex state of the current edge is a straight line. If a certain edge of the current element can be concave or convex, then the element representing the concave or convex state of the current edge in the concave or convex state array of the current element is randomly configured to 1 or -1, where 1 indicates that the concave or convex state of the current edge is convex and -1 indicates that the concave or convex state of the current edge is concave. After traversing all components, the adjacent edges of the components are checked, and the concave-convex state array of the corresponding components is updated again according to the check results to ensure that the adjacent edges meet the concave-convex pairing. Verify the adjacent edges of the components, and update the concave / convex state array of the corresponding components again based on the verification results to ensure that the adjacent edges meet the concave / convex pairing requirements. Specifically, this includes: Iterate through all elements in turn and check whether the concavity / convexity state of the first edge of the current element is 0; If the value is 0, traverse the second edge of the current element; If it is not 0, check if the concavity / convexity state of the current edge is 1; If it is 1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is -1. If it is, the concave / convex state of the two edges is a concave / convex pair. Otherwise, modify the concave / convex state of the current edge of the current element to -1, or modify the concave / convex state of the corresponding edge of the adjacent element to 1. If it is -1, check if the concave / convex state of the corresponding edge of the element adjacent to the current edge is 1. If it is, the concave / convex state of the two edges is a concave / convex pair. Otherwise, modify the concave / convex state of the current edge of the current element to 1, or modify the concave / convex state of the corresponding edge of the adjacent element to -1. Based on the concavity / convexity of each edge of each element and the coordinates of the four vertex corners of each element, a clipping path is generated, specifically including: Check if the current edge of the current element has an adjacent edge; If there are no adjacent edges, execute the edge clipping path procedure, which includes obtaining the coordinate values ​​of the two vertices of the current edge from the coordinate file, detecting the concavity / convexity state of the current edge, and if the concavity / convexity state is 0, using the line drawing function to draw a line segment based on the coordinate values ​​of the two vertices to generate the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; if the concavity / convexity state is 1 or -1, calculating the center coordinate value based on the coordinate values ​​of the two vertices, configuring the drawing direction flag according to the concavity / convexity state, using the arc drawing function to draw a line segment containing an arc based on the coordinate values ​​of the two vertices, the center coordinate value, the drawing direction flag, and a preset radius to generate the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; If there are adjacent edges, check whether the path generation identifier of the adjacent edges has been generated; If yes, iterate through the next edge of the current edge; otherwise, perform the edge trimming path procedure based on the current edge.

2. The method for segmenting an image to generate a mosaic cropping path according to claim 1, characterized in that, Randomly configure the element representing the current edge's concavity / convexity state in the current element's concavity / convexity state array to 1 or -1, specifically including: The classification threshold is determined based on the range of values ​​generated by the random number generation function; Generate a random number using a random number generator function on the current edge; Determine whether the generated random number is greater than the classification threshold; If so, the element representing the current edge's concavity / convexity state in the current element's concavity / convexity state array will be randomly configured to 1; otherwise, it will be configured to -1.

3. A system for segmenting an image to generate a mosaic clipping path, characterized in that, The system is implemented based on the method described in any one of claims 1-2, and includes, Initial segmentation module: Performs initial segmentation of components based on component parameters, dividing each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size. Coordinate acquisition module: Based on the initial segmentation result of the components, obtain the coordinate values ​​of the four vertex corners of each component and store them in the coordinate file; Concave / convex state configuration module: Configures the concave / convex state of each edge of each component; The trimming path generation module generates trimming paths based on the concavity and convexity of each edge of each element and the coordinate values ​​of the four vertices of each element.

4. A terminal, characterized in that, include: Memory, used to store the program that segments the image to generate the mosaic cropping path; The processor, when executing the program for segmenting the image to generate a jigsaw puzzle cropping path, implements the steps of the method for segmenting the image to generate a jigsaw puzzle cropping path as described in any one of claims 1-2.

5. A computer-readable storage medium, characterized in that, The readable storage medium stores a program for segmenting an image to generate a jigsaw puzzle cropping path, which, when executed by a processor, implements the steps of the method for segmenting an image to generate a jigsaw puzzle cropping path as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Cutting path generation method based on greedy algorithm

    CN111753350A

  • Three-dimensional logical puzzle and the method of determining shape of its pieces

    WO2010134828A1