Method and system for segmenting image to generate jigsaw cutting path, terminal and medium

By segmenting images and generating puzzle cutting paths, the problem of traditional puzzle processing software being difficult to independently edit puzzle elements is solved, enabling efficient editing and cutting of puzzle elements, improving production efficiency and reducing costs.

CN119323579AActive Publication Date: 2025-01-17浪潮智慧科技有限公司 +1
View PDF 16 Cites 0 Cited by

Patent Information

Application Number
CN202411372208.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-17
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

Traditional puzzle processing software is difficult to edit each puzzle component independently, cannot modify a single puzzle component, is inefficient and cannot edit components independently.

Method used

A method of segmenting an image to generate a puzzle clipping path, including initial segmentation of components based on component parameters, segmenting each component into rectangles, obtaining the coordinate values ​​of the four vertex corners of each component, and configuring each edge of each component The concave and convex state finally generates a clipping path.

Benefits of technology

It realizes the independent editing of any puzzle components, improves the generation efficiency, reduces the cost, and can quickly cut a large number of puzzle components, improves production efficiency, and reduces labor costs and material waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119323579A_ABST
    Figure CN119323579A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image cutting, and particularly discloses a method and system for segmenting an image to generate a jigsaw cutting path, a terminal and a medium, and the method comprises the steps: carrying out the initial segmentation of elements according to element parameters, and segmenting each element into a rectangle; wherein the element parameters comprise the number of rows, the number of columns and the image size; obtaining coordinate values of four vertex angles of each element according to an element initial segmentation result, and storing the coordinate values in a coordinate file; configuring the concave-convex state of each edge of each element; and generating a cutting path according to the concave-convex state of each edge of each element and the coordinate values of the four vertex angles of each element. According to the method, independent editing of any jigsaw elements is realized, so that the cutting path which can be directly applied to generation is generated, the generation efficiency is improved, and the cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image clipping, and in particular to a method, system, terminal and medium for segmenting an image to generate a puzzle clipping path. Background Art

[0002] In the field of digital image processing, jigsaw puzzle processing is a common way of image processing. It can not only transform complex images into fragments that are easy to understand and operate, but also stimulate the user's creativity and logical thinking ability through the process of reassembling the fragments.

[0003] Traditional puzzle processing software usually focuses on the segmentation and reorganization of the entire image, creating a puzzle effect on the original image by superimposing and cutting layers. Although this method can quickly generate basic puzzle images, it is difficult to edit each puzzle component independently during the processing process, and it is impossible to modify a single puzzle component. The traditional method of generating puzzle images based on layers is inefficient and cannot edit components independently. Summary of the invention

[0004] To solve the above problems, the present invention provides a method, system, terminal and medium for segmenting an image to generate a puzzle clipping path, which enables individual editing of any puzzle element, and then generates a clipping path that can be directly applied to the generation, thereby 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 puzzle clipping path, comprising the following steps: Perform initial component segmentation according to component parameters, and segment each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size; According to the initial segmentation result of the component, the coordinate values ​​of the four vertices of each component are obtained and stored in the coordinate file; Configure the concave and convex state of each edge of each component; A clipping path is generated according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

[0006] In an optional implementation, obtaining the coordinate values ​​of the four vertex corners of each element according to the initial segmentation result of the element includes the following steps: Construct a coordinate array for each component. The coordinate array contains four elements, which represent the coordinate values ​​of the four corners of the component respectively. Initialize each coordinate array; Update the coordinate array according to the actual coordinate values ​​of the four corners of the component.

[0007] In an optional implementation, configuring the concave-convex state of each edge of each element specifically includes: Construct a concave-convex state array for each element. The concave-convex state array contains four elements, which respectively represent the concave-convex states of the four sides of the element. Initialize each concave and convex state array; Configure concave-convex restriction conditions for each component, where the concave-convex restriction conditions include that the upper edge of the component cannot have concave-convexity, the right side of the component at the right edge cannot have concave-convexity, the lower edge of the component cannot have concave-convexity, and the left side of the component at the left edge cannot have concave-convexity; Configure the concave-convex state of each edge of each component based on the concave-convex constraint condition; Update the concave and convex state array according to the concave and convex state of each edge of the component.

[0008] In an optional implementation, configuring the concave-convex state of each edge of each element based on the concave-convex restriction condition specifically includes: Start traversing from the first component and check the concave and convex limits of the current component; If a certain edge of the current component cannot be concave or convex, the element representing the concave or convex state of the current edge in the concave or convex state array of the current component is configured to 0, indicating that the concave or convex state of the current edge is a straight line; If a certain edge of the current component can be concave or convex, the element representing the concave or convex state of the current edge in the concave or convex state array of the current component is randomly configured to 1 or -1, 1 means that the concave or convex state of the current edge is convex, and -1 means 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 and convex state arrays of the corresponding components are updated again according to the check results so that the adjacent edges meet the concave and convex pairing.

[0009] In an optional implementation, 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 or -1, specifically including: Determine the classification threshold according to the generated value range of the random number generation function; Generate a random number for the current edge using a random number generation function; Determine 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.

[0010] In an optional implementation, 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 result so that the adjacent edges meet the concave-convex pairing, which specifically includes: Traverse all components in turn and check whether the concave-convex state of the first edge of the current component is 0; If it is 0, traverse the second edge of the current element; If it is not 0, check whether the concave and convex state of the current edge is 1; If it is 1, check whether the concave-convex state of the corresponding side of the component adjacent to the current side is -1. If so, the concave-convex state of the current two sides meets the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current component to -1, or modify the concave-convex state of the corresponding side of the adjacent component to 1. If it is -1, check whether the concave-convex state of the corresponding side of the component adjacent to the current side is 1. If so, the concave-convex state of the current two sides conforms to the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current component to 1, or modify the concave-convex state of the corresponding side of the adjacent component to -1.

[0011] In an optional implementation, the clipping path is generated according to the concave-convex state of each edge of each element and the coordinate values ​​of the four vertex corners of each element, specifically including: Check whether the current edge of the current component has an adjacent edge; If there is no adjacent edge, the edge clipping path program is executed, including obtaining the coordinate values ​​of the two vertices of the current edge from the coordinate file, detecting the concave-convex state of the current edge, and if the concave-convex state is 0, using the line drawing function to draw a line segment based on the two vertex coordinate values, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; if the concave-convex state is 1 or -1, calculating the center coordinate value based on the two vertex coordinate values, configuring the drawing direction flag according to the concave-convex state, using the arc drawing function to draw a line segment containing an arc based on the two vertex coordinate values, the center coordinate value, the drawing direction flag and the preset radius, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; If there is an adjacent edge, check whether the path generation flag of the adjacent edge is generated; If yes, traverse the next edge of the current edge; if no, execute the edge clipping path procedure based on the current edge.

[0012] In a second aspect, the technical solution of the present invention provides a system for segmenting an image to generate a puzzle clipping path, which is implemented based on any of the above methods, and the system includes: Initial segmentation module: performs initial segmentation of components according to component parameters, dividing each component into rectangles; component parameters include the number of rows, the number of columns, and the image size; Coordinate acquisition module: obtains the coordinate values ​​of the four vertex corners of each component according to the initial segmentation result of the component, and stores them in the coordinate file; Concave and convex state configuration module: configure the concave and convex state of each edge of each component; Clipping path generation module: Generates a clipping path based on the concave and convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

[0013] In a third aspect, the technical solution of the present invention provides a terminal, including: a memory for storing a program for segmenting an image to generate a jigsaw puzzle clipping path; A processor is used to implement the steps of the method for segmenting an image to generate a jigsaw puzzle clipping path as described in any of the above items when executing the program for segmenting an image to generate a jigsaw puzzle clipping path.

[0014] In a fourth aspect, the technical solution of the present invention provides a computer-readable storage medium, on which is stored a program for segmenting an image to generate a puzzle clipping path. When the program for segmenting an image to generate a puzzle clipping path is executed by a processor, the steps of the method for segmenting an image to generate a puzzle clipping path as described in any of the above items are implemented.

[0015] The method, system, terminal and medium for segmenting an image to generate a puzzle clipping path provided by the present invention have the following beneficial effects compared with the prior art: initial puzzle elements and related coordinates of each element are generated according to the specified number of rows and columns and image size, and then the edge concave-convex setting is realized according to the concave-convex state of each edge of each element, and any puzzle element is edited separately without the need to superimpose multiple layers, and a clipping path is further automatically generated according to the concave-convex state. The generated clipping path can be directly produced by the user, effectively improving the efficiency of puzzle drawing and clipping, realizing the rapid clipping of a large number of puzzle elements, greatly improving production efficiency, and reducing labor costs and material waste. BRIEF DESCRIPTION OF THE DRAWINGS In order to more clearly illustrate the embodiments of the present invention or the technical solutions of 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 these drawings without paying creative work.

[0016] Figure 1 It is a flowchart of a method for segmenting an image to generate a puzzle clipping path provided by an embodiment of the present invention.

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

[0018] Figure 3 It is a schematic diagram of the structure of a system for segmenting an image to generate a jigsaw clipping path provided by an embodiment of the present invention.

[0019] Figure 4 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0022] Figure 1 1 is a flow chart of a method for segmenting an image to generate a jigsaw clipping path provided by an embodiment of the present invention. Figure 1 The execution subject may be a system for segmenting an image to generate a jigsaw clipping path. The method for segmenting an image to generate a jigsaw clipping path provided in an embodiment of the present invention is executed by a computer device, and accordingly, the system for segmenting an image to generate a jigsaw clipping path runs in the computer device. According to different requirements, the order of the steps in the flowchart may be changed, and some may be omitted.

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

[0024] S1, perform initial component segmentation according to component parameters, and segment each component into rectangles.

[0025] 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 enters the number of rows, the number of columns, and the image size on the human-computer interaction interface, and the background automatically performs a preliminary segmentation of the image based on these parameters, and segments the image into rectangular components with the number of rows and columns, and the four sides of the rectangular components are all straight lines.

[0026] S2, obtaining the coordinate values ​​of the four vertices of each component according to the initial segmentation result of the component, and storing them in a coordinate file.

[0027] S2.1, construct a coordinate array for each component, the coordinate array contains four elements, which respectively represent the coordinate values ​​of the four vertex corners of the component.

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

[0029] S2.3, updating the coordinate array according to the actual coordinate values ​​of the four vertex corners of the obtained component.

[0030] In this embodiment, the clipping path is generated according to the coordinate values. After the initial element is generated, the coordinate values ​​of the four vertices of each element are generated according to the image size and the number of rows and columns. In order to facilitate the storage and subsequent retrieval of the coordinate values, a coordinate array is constructed for each element. The coordinate array contains four elements, which respectively represent the coordinate values ​​of the four vertex corners of the element. For example, the first to fourth elements represent the coordinate values ​​of the upper left corner, the upper right corner, the lower right corner, and the lower left corner, respectively. After construction, it is first initialized, for example, all are configured to 0, and then the actual coordinates are updated to the coordinate array. The coordinate array is stored in the coordinate file.

[0031] S3, configure the concave-convex state of each edge of each component.

[0032] It can be understood that the four sides of the element are either convex, concave or straight, and the embodiment determines the shape of the side by configuring the concave-convex state of each side of each element, specifically by configuring a concave-convex state array, in which different values ​​are configured to represent different shapes. Specifically, the following steps are included.

[0033] S3.1, construct a concave-convex state array for each element.

[0034] In this embodiment, the concave-convex state array includes four elements, which respectively represent the concave-convex states of the four sides of the element. Exemplarily, the first to fourth elements represent the concave-convex states of the top, right, bottom and left sides respectively.

[0035] S3.2, initializing each concave-convex state array.

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

[0037] S3.3, configure concave and convex constraints for each component.

[0038] The concave-convex restriction conditions include that the upper edge of the component cannot have concave-convexity on the top, the right side of the component on the right edge cannot have concave-convexity on the bottom, and the left side of the component on the left edge cannot have concave-convexity on the left.

[0039] S3.4, configuring the concave-convex state of each edge of each component based on the concave-convex constraint condition.

[0040] In this embodiment, 0 represents a straight line, 1 represents a convexity, and -1 represents a concaveness. After the concave-convex state array is initialized, a random number is generated by a random number generation function to generate a random number and then generate the concave-convex state, which specifically includes the following steps.

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

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

[0043] In this embodiment, the component concave-convex restrictions are pre-configured according to the position of the component, specifically the concave-convex restrictions of each side of the component. For example, a concave-convex restriction mark is configured for each side of each component, the first mark is unlimited, the second mark is restricted, and no concave-convexity can appear, and it should be a straight line.

[0044] 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, 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.

[0045] In this embodiment, the classification threshold is first determined based on the generation value range of the random number generation function, and then the random number generation function is used to generate a random number for the current edge to determine 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.

[0046] For example, the traversal starts from the upper left corner component, and the upper, right, lower and left edges of the component are processed in turn. A decimal is determined for each edge through the Math.random() function (this function is a built-in function of the browser script execution environment, and each call returns a random decimal between 0 and 1), and a check is made to see whether the decimal is greater than 0.5. If it is greater than 0.5, the edge is convex, and if it is less than or equal to 0.5, the edge is concave.

[0047] S3.4.4, after traversing all components, verify the adjacent edges of the components, and update the concave-convex state array of the corresponding components again according to the verification results, so that the adjacent edges meet the concave-convex pairing.

[0048] It should be noted that this embodiment first randomly generates the concave and convex states of each edge of each component, but the concave and convex states of adjacent edges should be configured, that is, if one side is concave, the other side should be convex. Therefore, after random generation, the concave and convex states of adjacent edges need to be verified to ensure that the adjacent edges meet the concave and convex pairing.

[0049] S3.4.4.1, traverse all components in turn and check whether the concave-convex state of the first edge of the current component is 0.

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

[0051] S3.4.4.2, if it is not 0, check whether the concave and convex state of the current edge is 1.

[0052] S3.4.4.3, if it is 1, check whether the concave-convex state of the corresponding side of the element adjacent to the current side is -1. If so, the concave-convex state of the current two sides conforms to the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current element to -1, or modify the concave-convex state of the corresponding side of the adjacent element to 1.

[0053] S3.4.4.4, if it is -1, check whether the concave-convex state of the corresponding side of the element adjacent to the current side is 1. If so, the concave-convex state of the current two sides conforms to the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current element to 1, or modify the concave-convex state of the corresponding side of the adjacent element to -1.

[0054] Exemplarily, a simple for loop is used to traverse and process the components in sequence. Assuming there is a component A, each of its four sides has an adjacent component (if A is at the edge of the entire puzzle, there is no adjacent component on the corresponding edge, and the state of its edge is always straight), the upper, right, lower, left and right sides of component A and the edge of the adjacent component B are checked. If the edge of A is concave, the corresponding edge of B is convex, and vice versa. This embodiment realizes concave-convex matching by detecting the element array in the concave-convex state array of each component, thereby improving the convenience of operation and the processing efficiency.

[0055] S3.5, updating the concave-convex state array according to the concave-convex state of each edge of the component.

[0056] 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 restriction and the concave-convex matching of adjacent edges.

[0057] S4, generating a clipping path according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

[0058] This embodiment uses a drawing function to generate a clipping path based on the concave-convex state, stores the coordinate values ​​of the vertices of each edge in a coordinate file, and uses the coordinate values ​​of the coordinate file to draw the line, which specifically includes the following steps.

[0059] S4.1, detect whether the current edge of the current component has an adjacent edge.

[0060] S4.2, if there is no adjacent edge, execute the edge clipping path program, including obtaining the two vertex coordinate values ​​of the current edge from the coordinate file, detecting the concave and convex state of the current edge, if the concave and convex state is 0, using the line drawing function to draw a line segment based on the two vertex coordinate values, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; if the concave and convex state is 1 or -1, calculating the center coordinate value based on the two vertex coordinate values, configuring the drawing direction flag according to the concave and convex state, using the arc drawing function to draw a line segment containing an arc based on the two vertex coordinate values, the center coordinate value, the drawing direction flag and the preset radius, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated.

[0061] S4.3, if there is an adjacent edge, check whether the path generation flag of the adjacent edge is generated.

[0062] S4.4, if yes, traverse the next edge of the current edge; if no, execute the edge clipping path procedure based on the current edge.

[0063] Figure 2 It is a schematic diagram of the generated clipping path. It should be noted that the adjacent edges of adjacent elements only need to be drawn once, so firstly detect whether the current edge has an adjacent edge. If so, detect whether the path of the adjacent edge has been drawn. If it has been drawn, it does not need to be drawn again. Otherwise, execute the edge clipping path program to generate the clipping path of the current edge. In this embodiment, after the clipping path is generated, the current edge path generation flag is configured as generated to facilitate the subsequent detection of whether the adjacent edge generates a clipping path.

[0064] In an optional implementation, the method for generating a puzzle clipping path of this embodiment is used in the form of a Web program, and the path information includes two types: 1. line segments; 2. line segments with depressions or protrusions. The browser script environment provides a basic graphics drawing API (drawing lines: lineTo, drawing arcs: arc), and the corresponding drawing can be completed through the point information belonging to the line.

[0065] Line segment: the position information of two points (x1, y1), (x2, y2).

[0066] Concave or convex line segments: the center and position (cx, cy) of the arc, the arc radius r, the arc rad, and the identifier direction used to indicate whether it is drawn clockwise or counterclockwise. A convex arc can be drawn clockwise, and a concave arc can be drawn counterclockwise.

[0067] In this embodiment, the position information of the two points of the line segment is the position of the two endpoints of the current edge, which is also the position of the corresponding two vertices of the element. For example, the position information of the two points of the upper edge is the position of the upper left and upper right vertices. When drawing an arc, the center of the arc is the position between the two endpoints of the current edge, and the arc radius can be pre-set as needed. The drawing direction mark is clockwise drawing or counterclockwise drawing. A convex arc is drawn clockwise, and a concave arc is drawn counterclockwise.

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

[0069] An embodiment of a method for segmenting an image to generate a puzzle clipping path is described in detail above. Based on the method for segmenting an image to generate a puzzle clipping path described in the above embodiment, an embodiment of the present invention also provides a system for segmenting an image to generate a puzzle clipping path corresponding to the method.

[0070] Figure 3 3 is a schematic diagram of a system structure for segmenting an image to generate a jigsaw clipping path provided by an embodiment of the present invention. The system 300 for segmenting an image to generate a jigsaw clipping path can be divided into multiple functional modules according to the functions performed by the system. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory.

[0071] Initial segmentation module 310: performs initial segmentation of components according to component parameters, and segments each component into rectangles; wherein the component parameters include the number of rows, the number of columns, and the image size.

[0072] Coordinate acquisition module 320: acquires the coordinate values ​​of the four vertices of each component according to the initial component segmentation result, and stores them in a coordinate file.

[0073] Concave-convex state configuration module 330: configures the concave-convex state of each edge of each element.

[0074] Clipping path generation module 340: Generates a clipping path according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

[0075] The system for segmenting images to generate a jigsaw clipping path in the present embodiment is used to implement the aforementioned method for segmenting images to generate a jigsaw clipping path. Therefore, the specific implementation of the system can be seen in the embodiment section of the method for segmenting images to generate a jigsaw clipping path in the previous text. Therefore, its specific implementation can refer to the description of the corresponding embodiments of each part, which will not be introduced in detail here.

[0076] In addition, since the system for segmenting an image to generate a jigsaw clipping path in this embodiment is used to implement the aforementioned method for segmenting an image to generate a jigsaw clipping path, its function corresponds to that of the aforementioned method and will not be described in detail here.

[0077] Figure 4 A schematic diagram of the structure 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 is used to implement the following steps when implementing the program stored in the memory 420 to segment an image to generate a puzzle clipping path: Perform initial component segmentation according to component parameters, and segment each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size; According to the initial segmentation result of the component, the coordinate values ​​of the four vertices of each component are obtained and stored in the coordinate file; Configure the concave and convex state of each edge of each component; A clipping path is generated according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

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

[0079] The computer storage medium stores a program for segmenting an image to generate a jigsaw puzzle clipping path, and when the program for segmenting an image to generate a jigsaw puzzle clipping path is executed by a processor, the following steps are implemented: Perform initial component segmentation according to component parameters, and segment each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size; According to the initial segmentation result of the component, the coordinate values ​​of the four vertices of each component are obtained and stored in the coordinate file; Configure the concave and convex state of each edge of each component; A clipping path is generated according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component. Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.

[0080] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0082] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0083] The above disclosure is only a preferred embodiment of the present invention, but the present invention is not limited thereto. Any non-creative changes that can be thought of by a person skilled in the art, as well as several improvements and modifications made without departing from the principle 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 jigsaw puzzle clipping path, characterized in that: The following steps are involved: Perform initial component segmentation according to component parameters, and segment each component into rectangles; the component parameters include the number of rows, the number of columns, and the image size; According to the initial segmentation result of the component, the coordinate values ​​of the four vertices of each component are obtained and stored in the coordinate file; Configure the concave and convex state of each edge of each component; A clipping path is generated according to the concave-convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

2. The method for segmenting an image to generate a jigsaw clipping path according to claim 1, characterized in that: Obtaining the coordinate values ​​of the four vertex corners of each component according to the initial segmentation result of the component includes the following steps: Construct a coordinate array for each component. The coordinate array contains four elements, which represent the coordinate values ​​of the four corners of the component respectively. Initialize each coordinate array; Update the coordinate array according to the actual coordinate values ​​of the four corners of the component.

3. The method for segmenting an image to generate a jigsaw clipping path according to claim 2, characterized in that: Configure the concave and convex state of each edge of each component, including: Construct a concave-convex state array for each element. The concave-convex state array contains four elements, which respectively represent the concave-convex states of the four sides of the element. Initialize each concave and convex state array; Configure concave-convex restriction conditions for each component, where the concave-convex restriction conditions include that the upper edge of the component cannot have concave-convexity, the right side of the component at the right edge cannot have concave-convexity, the lower edge of the component cannot have concave-convexity, and the left side of the component at the left edge cannot have concave-convexity; Configure the concave-convex state of each edge of each component based on the concave-convex constraint condition; Update the concave and convex state array according to the concave and convex state of each edge of the component.

4. The method for segmenting an image to generate a jigsaw clipping path according to claim 3, characterized in that: Configure the concave and convex state of each edge of each component based on the concave and convex constraints, including: Start traversing from the first component and check the concave and convex limits of the current component; If a certain edge of the current component cannot be concave or convex, the element representing the concave or convex state of the current edge in the concave or convex state array of the current component is configured to 0, indicating that the concave or convex state of the current edge is a straight line; If a certain edge of the current component can be concave or convex, the element representing the concave or convex state of the current edge in the concave or convex state array of the current component is randomly configured to 1 or -1, 1 means that the concave or convex state of the current edge is convex, and -1 means 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 and convex state arrays of the corresponding components are updated again according to the check results so that the adjacent edges meet the concave and convex pairing.

5. The method for segmenting an image to generate a jigsaw clipping path according to claim 4, characterized in that: The elements representing the concave and convex states of the current edge in the concave and convex state array of the current element are randomly configured to 1 or -1, specifically including: Determine the classification threshold according to the generated value range of the random number generation function; Generate a random number for the current edge using a random number generation function; Determine 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.

6. The method of segmenting an image to generate a jigsaw clipping path according to claim 4, characterized in that: Verify the adjacent edges of the components, and update the concave-convex state array of the corresponding components again according to the verification results, so that the adjacent edges meet the concave-convex pairing, specifically including: Traverse all components in turn and check whether the concave-convex state of the first edge of the current component is 0; If it is 0, traverse the second edge of the current element; If it is not 0, check whether the concave and convex state of the current edge is 1; If it is 1, check whether the concave-convex state of the corresponding side of the component adjacent to the current side is -1. If so, the concave-convex state of the current two sides meets the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current component to -1, or modify the concave-convex state of the corresponding side of the adjacent component to 1. If it is -1, check whether the concave-convex state of the corresponding side of the component adjacent to the current side is 1. If so, the concave-convex state of the current two sides conforms to the concave-convex pairing. Otherwise, modify the concave-convex state of the current side of the current component to 1, or modify the concave-convex state of the corresponding side of the adjacent component to -1.

7. The method for segmenting an image to generate a jigsaw clipping path according to claim 6, characterized in that: Generate a clipping path based on the concave and convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component, including: Check whether the current edge of the current component has an adjacent edge; If there is no adjacent edge, the edge clipping path program is executed, including obtaining the coordinate values ​​of the two vertices of the current edge from the coordinate file, detecting the concave-convex state of the current edge, and if the concave-convex state is 0, using the line drawing function to draw a line segment based on the two vertex coordinate values, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; if the concave-convex state is 1 or -1, calculating the center coordinate value based on the two vertex coordinate values, configuring the drawing direction flag according to the concave-convex state, using the arc drawing function to draw a line segment containing an arc based on the two vertex coordinate values, the center coordinate value, the drawing direction flag and the preset radius, generating the clipping path of the current edge, and configuring the path generation flag of the current edge as generated; If there is an adjacent edge, check whether the path generation flag of the adjacent edge is generated; If yes, traverse the next edge of the current edge; if no, execute the edge clipping path procedure based on the current edge.

8. A system for segmenting an image to generate a jigsaw puzzle clipping path, characterized in that: The method according to any one of claims 1 to 7 is implemented, the system comprising: Initial segmentation module: performs initial segmentation of components according to component parameters, dividing each component into rectangles; component parameters include the number of rows, the number of columns, and the image size; Coordinate acquisition module: obtains the coordinate values ​​of the four vertex corners of each component according to the initial segmentation result of the component, and stores them in the coordinate file; Concave and convex state configuration module: configure the concave and convex state of each edge of each component; Clipping path generation module: Generates a clipping path based on the concave and convex state of each edge of each component and the coordinate values ​​of the four vertex corners of each component.

9. A terminal, characterized in that: include: a memory for storing a program for segmenting an image to generate a jigsaw puzzle clipping path; A processor is used to implement the steps of the method for segmenting an image to generate a jigsaw clipping path as described in any one of claims 1 to 7 when executing the program for segmenting an image to generate a jigsaw clipping path.

10. A computer-readable storage medium, characterized in that: The readable storage medium stores a program for segmenting an image to generate a puzzle clipping path. When the program for segmenting an image to generate a puzzle clipping path is executed by a processor, the steps of the method for segmenting an image to generate a puzzle clipping path as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Panorama image stitching method and device

    CN105389787A

  • Image processing method and device

    CN105513008A

  • Picture clipping method

    CN110189250A

  • Smooth image generation method and device based on adaptive threshold segmentation algorithm

    CN110378922A

  • Cutting path generation method based on greedy algorithm

    CN111753350A