A handwriting erasing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202311272144.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-09-28
AI Technical Summary
[0003]但这种方法存在一些缺陷,首先在运算时需要多次调用图像处理接口去判断是否存在相交的区域,这样非常消耗计算资源,且获取相交区域的算法耗时较长,进一步的,这种方法还需要多次裁剪、拆分笔迹,而拆分笔迹的算法耗时也较长
[0030]本发明提供了一种笔迹的擦除方法、装置、电子设备以及存储介质,其中所述方法,通过获取擦除区域与笔迹区域,并在确定所述擦除区域与待擦除笔迹的笔迹区域存在相交区域、相交区域中存在待擦除笔迹的笔迹节点且所述笔迹区域未完全落入所述擦除区域时,将不在所述擦除区域中的笔迹节点,添加至预设的笔迹集合中;将待擦除笔迹原有的所有笔迹节点删除,并根据所述笔迹集合中的笔迹节点进行渲染,生成擦除后的笔迹。无需对原有的笔迹进行多次裁剪,也无需多次调用图像处理接口获取相交区域,减少了大量的运算时间,也避免了占用过多的系统资源,提高了擦除算法的运算效率,进一步有效地提高了用户的使用体验。
Smart Images

Figure CN117270747B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of handwriting input, and more particularly to a method, apparatus, electronic device, and storage medium for erasing handwriting. Background Technology
[0002] Existing handwriting erasure algorithms typically involve calling an image processing interface to obtain the intersection area between the bounding rectangle of the handwriting and the erasure area, and calculating whether they intersect. If they intersect, the handwriting is divided into two symmetrical parts. The image processing interface is then called again to obtain the intersection area between these two parts of the handwriting and the erasure area, and to calculate whether they still intersect. If they do intersect, the division continues until handwriting areas that do not intersect with the erasure area are identified. Finally, the handwriting in each of these non-intersecting handwriting areas is taken as the erased handwriting.
[0003] However, this method has some drawbacks. First, it requires multiple calls to the image processing interface to determine if intersecting regions exist, which consumes a lot of computing resources. Furthermore, the algorithm for obtaining intersecting regions is time-consuming. Additionally, this method requires multiple cropping and splitting of the handwriting, and the algorithm for splitting handwriting is also time-consuming. Statistics show that if there are one thousand handwriting marks on the screen, using existing erasing algorithms requires approximately two seconds of computation time, which is extremely inefficient and significantly impacts the user experience. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for erasing handwriting, which can effectively improve the computational efficiency of erasing algorithms and further enhance the user experience.
[0005] An embodiment of the present invention provides a method for erasing handwriting, comprising:
[0006] Get the area to be erased and the area of the writing to be erased;
[0007] When it is determined that the erasure area and the handwriting area to be erased intersect, and there are handwriting nodes to be erased in the intersecting area, and the handwriting area does not completely fall into the erasure area, the handwriting nodes not in the erasure area are added to a preset handwriting set.
[0008] Delete all the original stroke nodes of the stroke to be erased, and render the strokes based on the stroke nodes in the stroke set to generate the erased strokes.
[0009] Furthermore, the acquisition of the erasure area and the area of the writing to be erased includes:
[0010] Based on the moving area of the erasing action, the bounding rectangle of the moving area is generated to obtain the erasing area;
[0011] Based on the stroke nodes of the stroke to be erased, the outer matrix of the stroke to be erased is generated to obtain the stroke region.
[0012] Furthermore, the method for erasing handwriting also includes:
[0013] If it is determined that the erasure area and the area of the writing to be erased do not intersect, then the writing to be erased does not need to be erased.
[0014] Furthermore, the method for erasing handwriting also includes:
[0015] If it is determined that the erasure area and the area of the handwriting to be erased intersect, but there are no handwriting nodes of the handwriting to be erased in the intersecting area, it is determined that the handwriting to be erased does not need to be erased.
[0016] Furthermore, the method for erasing handwriting also includes:
[0017] When it is determined that the erasure area and the handwriting area to be erased intersect, and the handwriting area completely falls within the erasure area, all original handwriting nodes of the handwriting to be erased are deleted.
[0018] Furthermore, adding handwriting nodes that are not in the erasure area to a preset handwriting set includes:
[0019] Based on a preset distance interval, extract several spaced stroke nodes from the strokes to be erased;
[0020] When extracting each interval handwriting node, determine whether the extracted interval handwriting node is within the erasure area;
[0021] If not, read the value of the preset first identifier; if the value of the first identifier is determined to be the initial value, take the currently extracted handwriting node as the first marker node and change the value of the first identifier; if the value of the first identifier is determined not to be the initial value, extract the next interval handwriting node.
[0022] If so, the currently extracted interval handwriting node is used as the second marker node, and all handwriting nodes located between the first marker node and the second marker node in the handwriting to be erased are added to the preset handwriting set, and then the value of the first marker is reset to the initial value.
[0023] Another embodiment of the present invention provides a penmanship erasing device, comprising:
[0024] The region acquisition module is used to acquire the erasure region and the region of the writing to be erased;
[0025] The handwriting collection generation module is used to add handwriting nodes that are not in the erasure area to a preset handwriting collection when it is determined that there is an intersection area between the erasure area and the handwriting area of the handwriting to be erased, there are handwriting nodes of the handwriting to be erased in the intersection area, and the handwriting area does not completely fall into the erasure area.
[0026] The erased handwriting generation module is used to delete all the original handwriting nodes of the handwriting to be erased, and to render the erased handwriting based on the handwriting nodes in the handwriting set.
[0027] Another embodiment of the present invention provides an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement a handwriting erasure method as described in the above-described embodiment of the invention.
[0028] Another embodiment of the present invention provides a storage medium including a stored computer program, wherein the computer program, when running, controls the device where the storage medium is located to execute a handwriting erasure method as described in the above-described embodiment of the invention.
[0029] The following benefits can be obtained by implementing the present invention:
[0030] This invention provides a method, apparatus, electronic device, and storage medium for erasing handwriting. The method involves acquiring an erasure area and a handwriting area. When it is determined that the erasure area and the handwriting area to be erased intersect, and the intersecting area contains handwriting nodes of the handwriting to be erased, but the handwriting area does not completely fall within the erasure area, the handwriting nodes not in the erasure area are added to a preset handwriting set. All original handwriting nodes of the handwriting to be erased are deleted, and the erased handwriting is generated based on the handwriting nodes in the handwriting set. This method eliminates the need for multiple cropping of the original handwriting and multiple calls to the image processing interface to obtain the intersecting area, significantly reducing computation time and avoiding excessive system resource consumption. This improves the computational efficiency of the erasure algorithm and further enhances the user experience. Attached Figure Description
[0031] Figure 1 This is a schematic flowchart of a handwriting erasure method provided in an embodiment of the present invention.
[0032] Figure 2 This is a schematic diagram of the structure of a handwriting erasure device provided in an embodiment of the present invention. Detailed Implementation
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only 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.
[0034] See Figure 1 This is a flowchart illustrating a method for erasing handwriting according to an embodiment of the present invention, comprising:
[0035] S1. Obtain the erasure area and the area of the writing to be erased;
[0036] In one embodiment of the present invention, the writing area to be erased is obtained by recognizing the user's handwriting on the screen device through the writing screen device; and the erasure area is obtained by recognizing the user's erasure operation on the screen device through the writing screen device. The writing area to be erased is obtained by recognizing the handwriting on the writing screen device.
[0037] Preferably, the erased area is obtained by generating the bounding rectangle of the moving area based on the moving area of the erasing action;
[0038] Based on the stroke nodes of the stroke to be erased, the outer matrix of the stroke to be erased is generated to obtain the stroke region.
[0039] In one embodiment of the present invention, the erased area is obtained by generating the bounding rectangle of the moving area of the erasing action through a preset image processing interface; and the erased area is obtained by generating the bounding matrix of the handwriting to be erased based on the handwriting nodes of the handwriting to be erased through the image processing interface. Preferably, the image processing interface is a Region object.
[0040] S2. When it is determined that the erasure area and the handwriting area to be erased have an intersection area, there are handwriting nodes to be erased in the intersection area, and the handwriting area does not completely fall into the erasure area, the handwriting nodes not in the erasure area are added to a preset handwriting set.
[0041] In one embodiment of the present invention, when it is determined that the erasing area and the handwriting area of the handwriting to be erased intersect, the intersection area of the erasing area and the handwriting area of the handwriting to be erased is obtained through a preset image processing interface. It is further determined whether there are handwriting nodes of the handwriting to be erased in the intersection area, and simultaneously whether the handwriting area completely falls within the erasing area. If it is determined that the erasing area and the handwriting area of the handwriting to be erased intersect, that there are handwriting nodes of the handwriting to be erased in the intersection area, and that the handwriting area does not completely fall within the erasing area, the handwriting nodes not in the erasing area are added to a preset handwriting set.
[0042] Preferably, when it is determined that the erasure area and the area of the writing to be erased do not intersect, it is determined that the writing to be erased does not need to be erased.
[0043] Preferably, when it is determined that the erasure area and the area of the handwriting to be erased intersect, but there are no handwriting nodes of the handwriting to be erased in the intersecting area, it is determined that the handwriting to be erased does not need to be erased.
[0044] It is understandable that the erasure area and the handwriting area are the outer matrices of the erasure path and the handwriting to be erased, respectively. There may be cases where the two outer matrices intersect, but the actual handwriting to be erased does not intersect with the erasure path. Therefore, it is necessary to further determine whether there are handwriting nodes of the handwriting to be erased in the intersecting area. If not, it is directly determined that the handwriting to be erased does not need to be erased. This further improves the computational efficiency of the erasure algorithm.
[0045] Preferably, when it is determined that the erasure area and the handwriting area to be erased intersect, and the handwriting area completely falls within the erasure area, all original handwriting nodes of the handwriting to be erased are deleted.
[0046] In one embodiment of the present invention, by obtaining the coordinate positions of the four vertices of the handwriting region and determining whether the four vertices are located in the erasure region, if so, it indicates that the handwriting to be erased has been erased, and all the original handwriting nodes of the handwriting to be erased are directly deleted. This further improves the computational efficiency of the erasure algorithm.
[0047] Preferably, adding handwriting nodes that are not in the erasure area to a preset handwriting set includes:
[0048] Based on a preset distance interval, extract several spaced stroke nodes from the strokes to be erased;
[0049] In one embodiment of the present invention, the spaced-out handwriting nodes are extracted one by one, starting from the first handwriting node of the handwriting to be erased, according to a preset distance interval; preferably, the handwriting node is a plurality of pixels that make up the handwriting to be erased, and the distance interval is set to 1 pixel unit. It is understood that increasing the distance interval improves the computational efficiency of the erasure algorithm, but correspondingly, it sacrifices the recognition accuracy of the erasure algorithm.
[0050] When extracting each interval handwriting node, determine whether the extracted interval handwriting node is within the erasure area;
[0051] In one embodiment of the present invention, the coordinates of the currently extracted interval handwriting node are determined to determine whether the extracted interval handwriting node is within the erasure area.
[0052] If not, read the value of the preset first identifier; if the value of the first identifier is determined to be the initial value, take the currently extracted handwriting node as the first marker node and change the value of the first identifier; if the value of the first identifier is determined not to be the initial value, extract the next interval handwriting node.
[0053] In one embodiment of the present invention, when it is detected that the currently extracted interval handwriting node is not located in the erasure area, a preset first identifier is used to confirm whether the currently extracted interval handwriting node is the first handwriting node of a segment of handwriting that is not currently being erased.
[0054] When the first identifier is the initial value, if the currently extracted interval handwriting node is the first handwriting node of the current non-erasable handwriting segment, then the currently extracted interval handwriting node is used as the first marker node, and the value of the first identifier is changed; if the first identifier is not the initial value, then if the currently extracted interval handwriting node is not the first handwriting node of the current non-erasable handwriting segment, then the next interval handwriting node is extracted.
[0055] If so, the currently extracted interval handwriting node is used as the second marker node, and all handwriting nodes located between the first marker node and the second marker node in the handwriting to be erased are added to the preset handwriting set, and then the value of the first marker is reset to the initial value.
[0056] In one embodiment of the present invention, when it is detected that the currently extracted interval handwriting node is located within the erasure area, the currently extracted interval handwriting node is designated as a second marker node, and all handwriting nodes located between the first marker node and the second marker node in the handwriting to be erased are added to a preset handwriting set as a segment of handwriting that will not be erased. Then, the value of the first marker is reset to its initial value. It can be understood that if the next extracted interval handwriting node is not located within the erasure area, then the next extracted interval handwriting node is the first handwriting node of the next segment of handwriting that will not be erased.
[0057] This invention extracts the stroke nodes of the handwriting to be erased one by one according to a preset distance interval, determining each small segment of the handwriting that has not been erased. This avoids the use of multiple handwriting cropping algorithms and multiple calls to image processing interfaces to obtain intersecting regions, significantly reducing computation time and effectively improving the computational efficiency of the erasure algorithm.
[0058] S3. Delete all the original stroke nodes of the stroke to be erased, and render the stroke nodes in the stroke set to generate the erased stroke.
[0059] In one embodiment of the present invention, the final erased handwriting is generated by replacing all the original handwriting nodes of the original handwriting to be erased with all the handwriting nodes in the handwriting set.
[0060] This invention provides a method for erasing handwriting. By acquiring an erasure region and a handwriting region, and determining that the erasure region intersects with the handwriting region to be erased, and that the intersecting region contains handwriting nodes of the handwriting to be erased, but the handwriting region does not completely fall within the erasure region, the handwriting nodes not in the erasure region are added to a preset handwriting set. All original handwriting nodes of the handwriting to be erased are deleted, and the erased handwriting is generated based on the handwriting nodes in the handwriting set. This method eliminates the need for multiple cropping of the original handwriting and multiple calls to image processing interfaces to obtain the intersecting region, significantly reducing computation time and avoiding excessive system resource consumption. This improves the computational efficiency of the erasure algorithm and further enhances the user experience.
[0061] See Figure 2 This is a schematic diagram of the structure of a handwriting erasure device according to an embodiment of the present invention, comprising:
[0062] The region acquisition module is used to acquire the erasure region and the region of the writing to be erased;
[0063] The handwriting collection generation module is used to add handwriting nodes that are not in the erasure area to a preset handwriting collection when it is determined that there is an intersection area between the erasure area and the handwriting area of the handwriting to be erased, there are handwriting nodes of the handwriting to be erased in the intersection area, and the handwriting area does not completely fall into the erasure area.
[0064] The erased handwriting generation module is used to delete all the original handwriting nodes of the handwriting to be erased, and to render the erased handwriting based on the handwriting nodes in the handwriting set.
[0065] This invention provides a handwriting erasure device. It acquires an erasure area and a handwriting area, and when it determines that the erasure area and the handwriting area to be erased intersect, and that the intersecting area contains handwriting nodes of the handwriting to be erased, but the handwriting area does not completely fall within the erasure area, the handwriting nodes not in the erasure area are added to a preset handwriting set. All original handwriting nodes of the handwriting to be erased are deleted, and the device is rendered based on the handwriting nodes in the handwriting set to generate the erased handwriting. This eliminates the need for multiple cropping of the original handwriting and multiple calls to the image processing interface to obtain the intersecting area, significantly reducing computation time and avoiding excessive system resource consumption. This improves the computational efficiency of the erasure algorithm and further enhances the user experience.
[0066] The present invention provides an electronic device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the steps of the various method embodiments described above.
[0067] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, 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 can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0068] Those skilled in the art will clearly understand that, for convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0069] Electronic devices can be computing devices such as desktop computers, laptops, handheld computers, and cloud servers. These electronic devices may include, but are not limited to, processors and memory.
[0070] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting all parts of the electronic device via various interfaces and lines.
[0071] The memory can be used to store the computer program. The processor implements various functions of the electronic device by running or executing the computer program stored in the memory and calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0072] This invention provides a storage medium, which is a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and when executed by a processor, the computer program can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0073] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for erasing handwriting, characterized in that, include: Get the area to be erased and the area of the writing to be erased; When it is determined that the erasure area and the handwriting area to be erased intersect, and there are handwriting nodes to be erased in the intersecting area, and the handwriting area does not completely fall into the erasure area, the handwriting nodes not in the erasure area are added to a preset handwriting set. Delete all the original stroke nodes of the stroke to be erased, and render the strokes based on the stroke nodes in the stroke set to generate the erased strokes. The step of adding handwriting nodes that are not in the erasure area to a preset handwriting set includes: Based on a preset distance interval, extract several spaced stroke nodes from the strokes to be erased; When extracting each interval handwriting node, determine whether the extracted interval handwriting node is within the erasure area; If not, read the value of the preset first identifier; if the value of the first identifier is determined to be the initial value, take the currently extracted handwriting node as the first marker node and change the value of the first identifier; if the value of the first identifier is determined not to be the initial value, extract the next interval handwriting node. If so, the currently extracted interval handwriting node is used as the second marker node, and all handwriting nodes located between the first marker node and the second marker node in the handwriting to be erased are added to the preset handwriting set, and then the value of the first marker is reset to the initial value. The step of obtaining the erasure area and the area of the writing to be erased includes: Based on the moving area of the erasing action, the bounding rectangle of the moving area is generated to obtain the erasing area; Based on the stroke nodes of the stroke to be erased, the outer matrix of the stroke to be erased is generated to obtain the stroke region.
2. The method for erasing handwriting as described in claim 1, characterized in that, Also includes: If it is determined that the erasure area and the area of the writing to be erased do not intersect, then the writing to be erased does not need to be erased.
3. The method for erasing handwriting as described in claim 2, characterized in that, Also includes: If it is determined that the erasure area and the area of the handwriting to be erased intersect, but there are no handwriting nodes of the handwriting to be erased in the intersecting area, it is determined that the handwriting to be erased does not need to be erased.
4. The method for erasing handwriting as described in claim 3, characterized in that, Also includes: When it is determined that the erasure area and the handwriting area to be erased intersect, and the handwriting area completely falls within the erasure area, all original handwriting nodes of the handwriting to be erased are deleted.
5. A pen-erasing device, characterized in that, include: The region acquisition module is used to acquire the erasure region and the region of the writing to be erased; The handwriting collection generation module is used to add handwriting nodes that are not in the erasure area to a preset handwriting collection when it is determined that there is an intersection area between the erasure area and the handwriting area of the handwriting to be erased, there are handwriting nodes of the handwriting to be erased in the intersection area, and the handwriting area does not completely fall into the erasure area. The erased handwriting generation module is used to delete all the original handwriting nodes of the handwriting to be erased, and to render the erased handwriting based on the handwriting nodes in the handwriting set. The step of adding handwriting nodes that are not in the erasure area to a preset handwriting set includes: Based on a preset distance interval, extract several spaced stroke nodes from the strokes to be erased; When extracting each interval handwriting node, determine whether the extracted interval handwriting node is within the erasure area; If not, read the value of the preset first identifier; if the value of the first identifier is determined to be the initial value, take the currently extracted handwriting node as the first marker node and change the value of the first identifier; if the value of the first identifier is determined not to be the initial value, extract the next interval handwriting node. If so, the currently extracted interval handwriting node is used as the second marker node, and all handwriting nodes located between the first marker node and the second marker node in the handwriting to be erased are added to the preset handwriting set, and then the value of the first marker is reset to the initial value. The step of obtaining the erasure area and the area of the writing to be erased includes: Based on the moving area of the erasing action, the bounding rectangle of the moving area is generated to obtain the erasing area; Based on the stroke nodes of the stroke to be erased, the outer matrix of the stroke to be erased is generated to obtain the stroke region.
6. An electronic device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements a handwriting erasure method as described in any one of claims 1 to 4.
7. A storage medium, characterized in that, The storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device containing the storage medium to perform a handwriting erasure method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Handwriting erasing method and device, storage medium and electronic equipment
CN115705141A
Method, device and equipment for erasing handwriting on electronic whiteboard
CN116774848A