Image cutting method and device, electronic device and storage medium
By automatically calculating possible vertices in the picture and assisting front-end map cutting, the problem of graph cutting in the existing technology relying on manual operations is solved, and the automation and standardization of graph cutting is realized, and the efficiency of graph cutting is improved.
Patent Information
- Application Number
- CN202111279778.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-10-29
AI Technical Summary
The existing front-end graph cutting process relies entirely on manual operations and lacks standardization, resulting in graph cutting effects being limited by the developer's capabilities and inefficient.
By extracting the outline diagram of the original image to be cut, automatically calculate and determine the lines and vertices that meet the preset conditions, assisting front-end developers in cutting the image and generating the source code for cutting the image.
The front-end picture cutting is automated and standardized, and the picture cutting efficiency is improved, making the picture cutting process more efficient and standardized.
Smart Images

Figure CN114035873B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for cutting images, an electronic device, and a storage medium. Background Art
[0002] In Internet development, the common development process is to design a product prototype, then the front-end performs UI design on the prototype, and then cuts the picture according to the UI design, decomposing the picture into multiple page data area blocks, so as to obtain dynamic data from the background and put it into different page data area blocks.
[0003] However, the current front-end image slicing has the following flaws: first, the image is manually decomposed into multiple page data area blocks; second, there is no fixed standard for how to slice the image into multiple data area blocks. Therefore, the current image slicing effect depends entirely on the ability of the front-end developer. Summary of the Invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, embodiments of the present disclosure provide a method and device for slicing images, an electronic device, and a storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for slicing a graph, comprising the following steps:
[0006] Extracting a contour image of the original image to be cut, and extracting lines that meet preset conditions from the contour image of the original image to be cut;
[0007] A plurality of possible vertices are determined on the extracted lines, and the plurality of possible vertices are displayed on the original image to be cut.
[0008] In a possible implementation, after determining a plurality of possible vertices on the extracted line, the method further includes:
[0009] Taking the possible vertex as the center and a length of a preset number of pixels as the radius, determine the range where the possible vertex is located;
[0010] Determine whether the number of pixels within the range is greater than 1:
[0011] When the number of pixels within the range is greater than 1, performing the step of displaying the multiple possible vertices on the original image to be cut;
[0012] When the number of pixels within the range is less than or equal to 1, the possible vertex is discarded.
[0013] In a possible implementation, extracting a contour image of the original image to be cut includes:
[0014] Read the RGB values of all pixels of the original image to be cut;
[0015] For the pixel point of the original image to be cut, determine whether the absolute value of the difference between the RGB value of the current pixel point and each of its adjacent pixels is less than a preset threshold:
[0016] When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is less than a preset threshold, the current pixel is discarded;
[0017] When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is not less than a preset threshold, the current pixel is retained;
[0018] The outline of the original image to be cut is composed of the retained pixel points in the original image to be cut.
[0019] In a possible implementation, extracting lines that meet preset conditions from the contour image of the original image to be cut includes:
[0020] Establishing a pixel coordinate system in the contour map of the original image to be cut;
[0021] Traversing the pixel horizontal axis and the pixel vertical axis on the pixel coordinate system respectively, determining the number of pixel vertical coordinates corresponding to each pixel horizontal coordinate and the number of pixel horizontal coordinates corresponding to each pixel vertical coordinate;
[0022] Retain the pixel points that meet the preset conditions in the contour map of the original image to be cut, wherein the pixel points with the preset conditions are all pixel points whose number of pixel vertical coordinates corresponding to the pixel horizontal coordinates exceeds a first preset number threshold, or all pixel points whose number of pixel horizontal coordinates corresponding to the pixel vertical coordinates exceeds a second preset number threshold.
[0023] In a possible implementation, determining a plurality of possible vertices on the extracted line includes:
[0024] Pixel points whose number of pixel ordinates corresponding to their pixel abscissas exceeds a first preset number threshold and whose number of pixel abscissas corresponding to their pixel ordinates exceeds a second preset number threshold are regarded as possible vertices.
[0025] In a possible implementation, the method further includes the following steps:
[0026] Labeling a plurality of possible vertices displayed on the original image to be cut, so as to select a designated vertex from the plurality of possible vertices;
[0027] The data region corresponding to the specified vertex is exported from the original image to be cut.
[0028] In one possible implementation, the method further includes:
[0029] Configuring the data area, and generating a source code for cutting the image based on the configured data area;
[0030] The front end uses the image cutting source code to carry out the next stage of development.
[0031] In a second aspect, an embodiment of the present disclosure provides a device for cutting a picture, comprising:
[0032] An extraction module, which is used to extract the contour map of the original image to be cut, and extract lines that meet preset conditions from the contour map of the original image to be cut;
[0033] The determination module is used to determine a plurality of possible vertices on the extracted lines and display the plurality of possible vertices on the original image to be cut.
[0034] The plurality of possible vertices displayed on the original image to be cut are numbered. In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0035] Memory for storing computer programs;
[0036] The processor is configured to implement the above-mentioned image slicing method when executing the program stored in the memory.
[0037] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned image slicing method when executed by a processor.
[0038] The above technical solutions provided by the embodiments of the present disclosure have at least some or all of the following advantages compared to the prior art:
[0039] The method and device for cutting images described in the embodiments of the present disclosure automatically calculate possible vertices in an image, thereby changing the front-end cutting process from manual to configuration adjustment, and greatly improving the efficiency of cutting images through auxiliary automation.
[0040] The method and device for cutting graphs described in the embodiments of the present disclosure cut out different data areas by selecting designated vertices from determined possible vertices, so that the cutting graphs of UI designs become standardized, and basic cutting graphs can be completed by simply selecting multiple starting and ending points. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0042] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 The following schematically shows a flow chart of a method for cutting a picture according to an embodiment of the present disclosure;
[0044] Figure 2 The following schematically shows a flow chart of a method for cutting a picture according to another embodiment of the present disclosure;
[0045] Figure 3 The following schematically shows a flow chart of a method for cutting a picture according to another embodiment of the present disclosure;
[0046] Figure 4 The following schematically shows a flow chart of a method for cutting a picture according to another embodiment of the present disclosure;
[0047] Figure 5 The following schematically shows a structural block diagram of a device for cutting a picture according to an embodiment of the present disclosure;
[0048] Figure 6 A schematic diagram of creating a new image slicing project in a system for image slicing according to an embodiment of the present disclosure is shown schematically;
[0049] Figure 7 Schematically shows a weather forecast image to be cut in a system for cutting an image according to an embodiment of the present disclosure;
[0050] Figure 8 A schematic diagram of a management interface of a picture cutting item table in a system for picture cutting according to an embodiment of the present disclosure is schematically shown;
[0051] Figure 9 Schematically illustrating a weather forecast image with possible vertices in a system for image slicing according to an embodiment of the present disclosure;
[0052] Figure 10 The following schematically illustrates a flow chart of a method for calculating coordinates of possible vertices in a system for graph slicing according to an embodiment of the present disclosure;
[0053] Figure 11 Schematically illustrating an outline diagram of a weather forecast image diagram in a system for image slicing according to an embodiment of the present disclosure;
[0054] Figure 12 Schematically showing a line diagram of a weather forecast image diagram in a system for image slicing according to an embodiment of the present disclosure;
[0055] Figure 13 Schematically illustrates a line diagram in a special case of a system for cutting a picture according to an embodiment of the present disclosure;
[0056] Figure 14 Schematically illustrating a line diagram with false vertices in a system for cutting a graph according to an embodiment of the present disclosure;
[0057] Figure 15 Schematically illustrating a line diagram with possible vertices in a system for graph slicing according to an embodiment of the present disclosure;
[0058] Figure 16 Schematically shows a management interface diagram of a div image slicing sub-table in a system for image slicing according to an embodiment of the present disclosure;
[0059] Figure 17 Schematically shows a schematic diagram of a management interface of a div image slicing sub-table after a new data area block is added in a system for image slicing according to an embodiment of the present disclosure;
[0060] Figure 18 Schematically shows a display interface diagram of a configured data area block in a system for slicing images according to an embodiment of the present disclosure; and
[0061] Figure 19 The structural block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0062] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0063] See also Figure 1 , an embodiment of the present disclosure provides a method for cutting a graph, comprising the following steps:
[0064] S11, extracting a contour image of the original image to be cut, and extracting lines that meet preset conditions from the contour image of the original image to be cut;
[0065] S12, determining a plurality of possible vertices on the extracted line;
[0066] S13, determining a range where the possible vertex is located, with the possible vertex as the center and a length of a preset number of pixels as the radius;
[0067] In practical applications, the preset number of pixels is any value between 5 and 20.
[0068] S14, determining whether the number of pixels within the range is greater than 1:
[0069] If yes, proceed to step S15;
[0070] If not, proceed to step S16;
[0071] S15, displaying the possible vertices on the original image to be cut;
[0072] S16, discarding the possible vertex;
[0073] S17, labeling a plurality of possible vertices displayed on the original image to be cut, so as to select a designated vertex from the plurality of possible vertices;
[0074] In practical applications, the designated vertex can be determined by inputting a number, or by clicking corresponding positions of the multiple possible vertices. When selecting the designated vertex, two diagonal vertices can be selected.
[0075] S18, exporting the data region corresponding to the specified vertex from the original image to be cut;
[0076] S19, configuring the data area, and generating a source code for cutting the image based on the configured data area, and the front end uses the source code for cutting the image to carry out the next stage of development.
[0077] In this embodiment, see Figure 2 In step S1, extracting the contour of the original image to be cut includes:
[0078] S21, read the RGB values of all pixels of the original image to be cut;
[0079] S22: For the pixel of the original image to be cut, determine whether the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is less than a preset threshold:
[0080] If yes, proceed to step S23;
[0081] If not, proceed to step S24;
[0082] In practical applications, when the absolute value of the difference between the R value, G value and B value of the current pixel and each of its adjacent pixels is less than the preset threshold, it is considered that the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is less than the preset threshold.
[0083] S23, discard the current pixel;
[0084] S24, retain the current pixel;
[0085] S25 , forming a contour map of the original image to be cut using the retained pixel points in the original image to be cut.
[0086] In this embodiment, see Figure 3 In step S1, extracting lines that meet preset conditions from the contour image of the original image to be cut includes:
[0087] S31, establishing a pixel coordinate system in the contour map of the original image to be cut;
[0088] S32, traversing the pixel horizontal axis and the pixel vertical axis on the pixel coordinate system respectively, and determining the number of pixel vertical coordinates corresponding to each pixel horizontal coordinate and the number of pixel horizontal coordinates corresponding to each pixel vertical coordinate;
[0089] S33, retaining the pixel points that meet the preset conditions in the contour map of the original image to be cut, wherein the pixel points with the preset conditions are all pixel points whose number of pixel vertical coordinates corresponding to the pixel horizontal coordinates exceeds a first preset number threshold, or all pixel points whose number of pixel horizontal coordinates corresponding to the pixel vertical coordinates exceeds a second preset number threshold.
[0090] In practical applications, the first preset quantity threshold and the second preset quantity threshold may be the same or different.
[0091] In this embodiment, see Figure 4 In step S2, the step of determining a plurality of possible vertices on the extracted line includes:
[0092] S41 , taking pixel points whose number of pixel ordinates corresponding to their horizontal coordinates exceeds a first preset number threshold and whose number of pixel horizontal coordinates corresponding to their vertical coordinates exceeds a second preset number threshold as possible vertices.
[0093] The numbering of multiple possible vertices displayed on the original image to be cut is based on the same inventive concept, referring to Figure 5 As shown, the second exemplary embodiment of the present disclosure provides a device for cutting a graph, including: an extraction module 11, a determination module 12, a labeling module 13, an export module 14, a configuration module 15 and a graph cutting module 16.
[0094] In this embodiment, the extraction module 11 is used to extract the contour of the original image to be cut, and extract lines that meet preset conditions from the contour of the original image to be cut;
[0095] In this embodiment, the determination module 12 is configured to determine a plurality of possible vertices on the extracted lines, and display the plurality of possible vertices on the original image to be cut.
[0096] In this embodiment, the labeling module 13 is used to label multiple possible vertices displayed on the original image to be cut, so as to select a specified vertex from the multiple possible vertices;
[0097] In this embodiment, the export module 14 is used to export the data area corresponding to the specified vertex from the original image to be cut;
[0098] In this embodiment, the configuration module 15 is used to configure the data area and generate the image cutting source code based on the configured data area;
[0099] In this embodiment, the image cutting module 16 is used for the front end to use the image cutting source code to carry out the next stage of development.
[0100] In some embodiments, the extraction module 11 is further configured to:
[0101] Read the RGB values of all pixels of the original image to be cut;
[0102] For the pixel point of the original image to be cut, determine whether the absolute value of the difference between the RGB value of the current pixel point and each of its adjacent pixels is less than a preset threshold:
[0103] When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is less than a preset threshold, the current pixel is discarded;
[0104] When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is not less than a preset threshold, the current pixel is retained;
[0105] The outline of the original image to be cut is composed of the retained pixel points in the original image to be cut.
[0106] In some embodiments, the extraction module 11 is further configured to:
[0107] Establishing a pixel coordinate system in the contour map of the original image to be cut;
[0108] Traversing the pixel horizontal axis and the pixel vertical axis on the pixel coordinate system respectively, determining the number of pixel vertical coordinates corresponding to each pixel horizontal coordinate and the number of pixel horizontal coordinates corresponding to each pixel vertical coordinate;
[0109] Retain the pixel points that meet the preset conditions in the contour map of the original image to be cut, wherein the pixel points with the preset conditions are all pixel points whose number of pixel vertical coordinates corresponding to the pixel horizontal coordinates exceeds a first preset number threshold, or all pixel points whose number of pixel horizontal coordinates corresponding to the pixel vertical coordinates exceeds a second preset number threshold.
[0110] In some embodiments, the determination module 12 is further configured to:
[0111] Pixel points whose number of pixel ordinates corresponding to their pixel abscissas exceeds a first preset number threshold and whose number of pixel abscissas corresponding to their pixel ordinates exceeds a second preset number threshold are regarded as possible vertices.
[0112] In some embodiments, the determination module 12 is further configured to:
[0113] Taking the possible vertex as the center and a length of a preset number of pixels as the radius, determine the range where the possible vertex is located;
[0114] Determine whether the number of pixels within the range is greater than 1:
[0115] When the number of pixels within the range is greater than 1, performing the step of displaying the multiple possible vertices on the original image to be cut;
[0116] When the number of pixels within the range is less than or equal to 1, the possible vertex is discarded.
[0117] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0118] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein 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 across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present invention. A person of ordinary skill in the art can understand and implement the present invention without inventive work.
[0119] The working principle of the image cutting device is explained by taking a weather forecast image as an example.
[0120] 1. Design a local data table to store the basic data of weather forecast images. Table 1 below is a data table used to store weather forecast images provided by UI designers. Treat each weather forecast image as a new cut-out item. The constructed div cut-out item table is shown in Table 1 below. Among them, div is a tag used in HTML to identify page data area blocks. Different divs are used to divide the page, and different divs are used to divide different data areas.
[0121] Table 1
[0122]
[0123]
[0124] 2. Design a local data table to store the basic data of the weather forecast image after it is cut. Table 2 below is the specific data used to store the div after the weather forecast image is cut into multiple different divs as a UI design drawing. The constructed div cutting sub-table is shown in Table 2 below.
[0125] Table 2
[0126] Field Name Field Type illustrate id int(11) primary key id project_id int(11) Affiliated Projects left_top int(11) Upper left coordinate number right_down int(11) Lower right coordinate number x1 int(11) Upper left x coordinate y1 int(11) Upper left y coordinate x2 int(11) Lower right x coordinate y2 int(11) Lower right y coordinate mark_id varchar(255) div English id logo Zindex int(11) Level Numbers Creator varchar(255) Creator created_time datetime Creation time modified_time timestamp Modification time
[0127] 3. Based on the div cut project table, such as Figure 6 As shown, the new cut-image project is uploaded as follows Figure 7 Weather forecast image shown
[0128] 4. After uploading the image, store the width and height of the image and store it, and construct something like Figure 8 The management interface shown
[0129] 5. When you click [Show Intersection], Figure 9 As shown, the coordinates of possible vertices in the calculated UI design diagram are displayed
[0130] like Figure 10 As shown, the coordinates of possible vertices are calculated as follows
[0131] A) Contour calculation
[0132] 1) Read all pixels of the image
[0133] 2) Set the discard difference dt, for example dt = 5
[0134] 3) Traverse the width horizontal coordinate
[0135] 4) Traverse the height ordinate
[0136] 5) If the absolute value of the difference between the RGB value of the current pixel and the RGB values of the four surrounding points above, below, left, and right is less than dt (the absolute value of the difference between the R value is less than dt, the absolute value of the difference between the G value is less than dt, and the absolute value of the difference between the B value is less than dt)
[0137] Then discard this point and think it cannot be a vertex.
[0138] 6) The image after contour calculation is as follows Figure 11 shown.
[0139] B) Line calculation
[0140] 1) In Figure 10 In the image shown, the upper left corner is the origin, the horizontal coordinate is x, and the vertical coordinate is y. Statistics are performed on all data points.
[0141] a) Initialize xArr to record the graph. For each horizontal axis, calculate the number of data points on the vertical axis.
[0142] b) Initialize yArr for recording on the graph. For each vertical coordinate, calculate the number of data points it has on the horizontal coordinate.
[0143] c) Traverse the x-axis
[0144] d) Traverse the y-axis
[0145] e) If ($x, $y) has data, then
[0146] $xArr[$x]++
[0147] $yArr[$y]++
[0148] 2) Keep the top 10 x-coordinates with the largest number of xArrs, and keep them as xTopArr, which represent the 10 vertical lines on the graph that are most likely to pass through the vertex.
[0149] 3) Keep the top 10 y-coordinates with the largest number of yArrs, and keep them as yTopArr, which represents the 10 horizontal lines on the graph that are most likely to pass through the vertices.
[0150] The horizontal and vertical lines after retention are as follows Figure 12 shown.
[0151] C) Intersection point calculation
[0152] 1) Traverse xTopArr
[0153] 2) Traverse yTopArr
[0154] 3) If no RGB data is obtained for the intersection point (x, y) and the 10 pixels above, below, left, and right, it means it is not a vertex and is discarded.
[0155] The reason for abandonment is: when the horizontal and vertical line graph is as follows Figure 13 In the case shown, you may get Figure 14 The vertex of midpoint A is actually inappropriate, so it needs to be discarded. The discarding method is to calculate whether there are other data points in the four directions of up, down, left and right. Among them, 10 pixels is a self-determined empirical value.
[0156] like Figure 15 As shown, draw the vertices on the horizontal and vertical line graphs.
[0157] 4) Draw the remaining intersections and add a number to the vertices, such as Figure 9 shown
[0158] The above are the possible vertices calculated. For example, when 12 and 22 are selected, the position of the div that needs to be cut can be determined.
[0159] 6. Click [div cut image], you will see the following Figure 16 The interface shown
[0160] 1) Fill in the vertex numbers on the top left and bottom right, and after submitting, add a divided data area block.
[0161] 2) For example, if you fill in
[0162] Top left 8, bottom right 19
[0163] Top left 9, bottom right 23
[0164] Top left 12, bottom right 22
[0165] Get as Figure 17 The interface shown.
[0166] 3) Determine the vertex coordinates of the data area block to be divided according to the coordinates of each vertex
[0167] 4) According to the vertex coordinates of the data area block, construct the div, click [div display], and get the following Figure 18 The interface shown
[0168] The display has configured the divided data area blocks so that other data can be filled in. The front-end staff only needs to
[0169] Further transformation and data filling are sufficient, which greatly speeds up the front-end cutting speed.
[0170] Among them, the front-end cutting source code generated above can be
[0171] <! DOCTYPE html PUBLIC"- / / W3C / / DTD XHTML 1.0Transitional / / EN"
[0172] "http: / / *** / TR / xhtml1 / DTD / xhtml1-transitional.dtd">
[0173]
[0174]
[0175] <title> New data< / title>
[0176] <meta http-equiv="Content-Type"content="text html;charset=UTF-8">
[0177]
[0178]
[0179] <div style="border:1px solid red;position:absolute;top:170px;left:151px;width:897px;height:244px"> div16 <div style="border:1px solid red;position:absolute;top:427px;left:151px;width:897px;height:273px"> div17 <div style="border:1px solid red;position:absolute;top:0px;left:151px;width:897px;height:749px"> div18
[0180]
[0181] The disclosed system for cutting pictures calculates the vertices of the UI design picture and assists in dividing the div so that the front end can
[0182] It can quickly obtain the source code of the image cutting process, which greatly increases the speed of the front-end image cutting.
[0183] Based on the same invention concept, Figure 19 As shown, the third exemplary embodiment of the present disclosure provides an electronic device,
[0184] The system includes a processor 1110, a communication interface 1120, a memory 1130 and a communication bus 1140, wherein the processor 1110, the communication interface 1120 and the memory 1130 communicate with each other via the communication bus 1140;
[0185] Memory 1130, for storing computer programs;
[0186] The processor 1110 is configured to implement the following image slicing method when executing the program stored in the memory 1130:
[0187] Extracting a contour image of the original image to be cut, and extracting lines that meet preset conditions from the contour image of the original image to be cut;
[0188] A plurality of possible vertices are determined on the extracted lines, and the plurality of possible vertices are displayed on the original image to be cut.
[0189] The processor 1110 further implements the following method for slicing an image:
[0190] Labeling a plurality of possible vertices displayed on the original image to be cut obtained according to the above-mentioned cutting method, so as to select a specified vertex from the plurality of possible vertices;
[0191] The data region corresponding to the specified vertex is exported from the original image to be cut.
[0192] The communication bus 1140 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the figure shows only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0193] The communication interface 1120 is used for communication between the electronic device and other devices.
[0194] The memory 1130 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk storage. Alternatively, the memory 1130 may be at least one storage device located away from the processor 1110.
[0195] The above-mentioned processor 1110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0196] Based on the same inventive concept, a fourth exemplary embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described image slicing method or a method for image slicing.
[0197] The computer-readable storage medium may be included in the device / apparatus described in the above embodiments, or may exist independently without being incorporated into the device / apparatus. The computer-readable storage medium carries one or more programs, which, when executed, implement the image slicing method or method for image slicing according to the embodiments of the present disclosure.
[0198] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, such as, but not limited to, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0199] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0200] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not to be limited to the embodiments shown herein, but is to be construed in the broadest manner consistent with the principles and novel features claimed herein.
Claims
1. A method for cutting a picture, characterized in that: The following steps are involved: Extracting a contour image of the original image to be cut, and extracting lines that meet preset conditions from the contour image of the original image to be cut; Determine multiple possible vertices on the extracted lines, and display the multiple possible vertices on the original image to be cut, The extracted lines include pixel points that meet a preset condition, wherein the pixel points meeting the preset condition are all pixel points whose number of pixel ordinates corresponding to their abscissas exceeds a first preset number threshold, or all pixel points whose number of pixel abscissas corresponding to their ordinates exceeds a second preset number threshold, where the first preset number threshold and the second preset number threshold are the same or different; The step of determining a plurality of possible vertices on the extracted line comprises: Pixels whose number of pixel ordinates corresponding to their horizontal coordinates exceeds a first preset number threshold, and whose number of pixel horizontal coordinates corresponding to their vertical coordinates exceeds a second preset number threshold, are considered possible vertices. Determine the specified vertex by clicking corresponding positions of the multiple possible vertices; or Labeling a plurality of possible vertices displayed on the original image to be cut, so as to select a designated vertex from the plurality of possible vertices; The data region corresponding to the specified vertex is exported from the original image to be cut.
2. The method according to claim 1, characterized in that After determining a plurality of possible vertices on the extracted line, the method further includes: Taking the possible vertex as the center and a length of a preset number of pixels as the radius, determine the range where the possible vertex is located; Determine whether the number of pixels within the range is greater than 1: When the number of pixels within the range is greater than 1, performing the step of displaying the multiple possible vertices on the original image to be cut; When the number of pixels within the range is less than or equal to 1, the possible vertex is discarded.
3. The method according to claim 1, characterized in that The step of extracting the contour of the original image to be cut includes: Read the RGB values of all pixels of the original image to be cut; For the pixel point of the original image to be cut, determine whether the absolute value of the difference between the RGB value of the current pixel point and each of its adjacent pixels is less than a preset threshold: When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is less than a preset threshold, the current pixel is discarded; When the absolute value of the difference between the RGB value of the current pixel and each of its adjacent pixels is not less than a preset threshold, the current pixel is retained; The outline of the original image to be cut is composed of the retained pixel points in the original image to be cut.
4. The method according to claim 1, wherein The extracting of lines that meet preset conditions from the contour image of the original image to be cut includes: Establishing a pixel coordinate system in the contour map of the original image to be cut; Traversing the pixel horizontal axis and the pixel vertical axis on the pixel coordinate system respectively, determining the number of pixel vertical coordinates corresponding to each pixel horizontal coordinate and the number of pixel horizontal coordinates corresponding to each pixel vertical coordinate; Pixel points that meet preset conditions in the contour image of the original image to be cut are retained.
5. The method according to claim 1, wherein The method further comprises: Configuring the data area, and generating a source code for cutting the image based on the configured data area; The front end uses the image cutting source code to carry out the next stage of development.
6. A device for cutting a picture, characterized in that: include: An extraction module, which is used to extract the contour map of the original image to be cut, and extract lines that meet preset conditions from the contour map of the original image to be cut; A determination module is used to determine multiple possible vertices on the extracted lines and display the multiple possible vertices on the original image to be cut. The extracted lines include pixel points that meet a preset condition, wherein the pixel points meeting the preset condition are all pixel points whose number of pixel ordinates corresponding to their abscissas exceeds a first preset number threshold, or all pixel points whose number of pixel abscissas corresponding to their ordinates exceeds a second preset number threshold, where the first preset number threshold and the second preset number threshold are the same or different; The step of determining a plurality of possible vertices on the extracted line comprises: Pixels whose number of pixel ordinates corresponding to their horizontal coordinates exceeds a first preset number threshold, and whose number of pixel horizontal coordinates corresponding to their vertical coordinates exceeds a second preset number threshold, are considered possible vertices. a labeling module, configured to determine a designated vertex by clicking corresponding positions of the plurality of possible vertices; or to label the plurality of possible vertices displayed on the original image to be cut, so as to select a designated vertex from the plurality of possible vertices; The export module is used to export the data area corresponding to the specified vertex from the original image to be cut.
7. An electronic device, characterized in that: The processor, the communication interface, the memory and the communication bus are connected to each other via the communication bus. Memory for storing computer programs; A processor, configured to implement the image slicing method according to any one of claims 1 to 5 when executing a program stored in a memory.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for cutting a graph according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and device for generating interface, computer equipment and storage medium
CN108304243A
Image data processing method, device and equipment and medium
CN112052839A