Image processing method and device, electronic equipment and readable storage medium

By analyzing the proportion of differential image blocks and snapshot chains during the image editing process, and adopting incremental or full snapshot storage methods, the problem of large disk space consumption in image editing is solved, and the efficiency of undo operations is improved.

CN115690235BActive Publication Date: 2026-06-02BEIJING ZITIAO NETWORK TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2021-07-30
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In the existing technology, the snapshot storage of image editing operations uses lossless compression, which results in a large disk space consumption and a long undo operation time.

Method used

By analyzing the proportion of differential image blocks and the types of the last N snapshots in the snapshot chain during the image editing process, the image storage method is determined. Incremental snapshots or full snapshots are used for reasonable storage, reducing disk space usage and optimizing the processing time for undoing edits.

Benefits of technology

It effectively reduces the disk storage space occupied by snapshots, shortens the execution time of undo editing commands, and improves the efficiency of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115690235B_ABST
    Figure CN115690235B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an image processing method and device, electronic equipment and readable storage medium, wherein the method determines the storage mode of the first image by analyzing the proportion of the difference image block corresponding to the first image in the image editing process, and the snapshot type of the last N snapshots in the snapshot chain generated according to the continuous image editing instructions, so as to reasonably reduce the disk storage space occupied by the snapshots and reduce the time consumption of the electronic equipment executing the user inputted undo editing instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, electronic device, and readable storage medium. Background Technology

[0002] With the rapid development of internet technology, users often choose to use applications to perform several operations on images, such as applying stickers, filters, and so on. The application stores a snapshot of each operation, forming a snapshot chain, so that users can undo and restore.

[0003] In existing technologies, snapshots are typically stored using lossless compression. Specifically, the application compresses the processed image obtained from each image editing operation and stores it as a lossless compressed PNG image on disk.

[0004] While using the lossless compression storage method of PNG format can reduce the disk space occupied by snapshots, the compression and decompression process of PNG images is relatively complex and time-consuming. If users want to undo certain operations, they need to wait a considerable amount of time. Therefore, how to reasonably reduce the storage space occupied by image data during image editing is an urgent problem to be solved. Summary of the Invention

[0005] In order to solve the above-mentioned technical problems, or at least partially solve the above-mentioned technical problems, this disclosure provides an image processing method, apparatus, electronic device and readable storage medium.

[0006] In a first aspect, embodiments of this disclosure provide an image processing method, including:

[0007] Obtain an incremental snapshot corresponding to the first image; wherein, the incremental snapshot includes data of the difference image blocks between the first image and the second image, and the first image is obtained by editing the second image according to a first editing instruction;

[0008] Based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time, the storage method corresponding to the first image is determined; where N is an integer greater than or equal to 1;

[0009] Based on the storage method corresponding to the first image, the incremental snapshot or full snapshot corresponding to the first image is stored in the snapshot chain.

[0010] In some possible designs, the storage method of the first image is determined based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged chronologically from back to front, including:

[0011] If the proportion of the differential image blocks included in the incremental snapshot is greater than or equal to a preset threshold, or if all N snapshots are incremental snapshots, then the storage method corresponding to the first image is used to indicate the storage of the full snapshot corresponding to the first image.

[0012] If the proportion of the differential image blocks included in the incremental snapshot is less than the preset threshold, and the N snapshots include the full snapshot, then the storage method corresponding to the first image is used to indicate the storage of the incremental snapshot corresponding to the first image.

[0013] In some possible designs, the incremental snapshot includes data from at least one differential image region; when there are multiple differential image regions, each differential image block between the first image and the second image belongs to one of the multiple differential image regions.

[0014] In some possible designs, the at least one difference image region is determined based on the continuity between difference image blocks between the first image and the second image.

[0015] In some possible designs, the method further includes:

[0016] According to the storage method corresponding to the first image, the incremental snapshot or full snapshot corresponding to the first image is cached in the memory space. The memory space is used to cache M snapshots in the snapshot chain in chronological order from back to front, where M is an integer greater than or equal to 1 and M is less than or equal to N.

[0017] In some possible designs, the method further includes:

[0018] According to the undo edit command for the third image, a target snapshot is obtained from the snapshot chain; the target snapshot includes: a target full snapshot, and all snapshots between the target full snapshot and the snapshot corresponding to the third image; the target full snapshot is the first full snapshot in the snapshot chain in chronological order from back to front, and located before the snapshot corresponding to the third image;

[0019] Based on the target snapshot, a fourth image is restored, wherein the third image is obtained by editing the fourth image according to the second editing instructions.

[0020] In some possible designs, obtaining the target snapshot from the snapshot chain based on the undo edit command for the third image includes:

[0021] If the target snapshot is included in the M snapshots cached in the memory space, then the target snapshot is obtained from the memory space;

[0022] If the M snapshots cached in the memory space do not include a portion of the target snapshot, then the portion of the snapshot is read from the external storage space and written to the memory space.

[0023] In a second aspect, embodiments of this disclosure provide an image processing apparatus, comprising:

[0024] An acquisition module is used to acquire an incremental snapshot corresponding to a first image; wherein, the incremental snapshot includes data of the difference image blocks between the first image and the second image, and the first image is obtained by editing the second image according to a first editing instruction;

[0025] The processing module is configured to determine the storage method corresponding to the first image based on the proportion of the differential image blocks included in the incremental snapshot and / or the N snapshots in the snapshot chain arranged from back to front in time; wherein N is an integer greater than or equal to 1; and to store the incremental snapshot or full snapshot corresponding to the first image into the snapshot chain according to the storage method corresponding to the first image.

[0026] Thirdly, embodiments of this disclosure provide an electronic device, including: a memory, a processor, and computer program instructions;

[0027] The memory is configured to store the computer program instructions;

[0028] The processor is configured to execute the computer program instructions to implement the method as described in any of the first aspects.

[0029] Fourthly, embodiments of this disclosure provide a readable storage medium, including: a program;

[0030] When the program is executed by at least one processor of an electronic device, it implements the method described in any of the first aspects.

[0031] Fifthly, embodiments of this disclosure provide a program product, including: computer program instructions;

[0032] The computer program instructions are stored in a readable storage medium, and at least one processor of the electronic device can read the computer program instructions from the readable storage medium. The at least one processor executes the computer program instructions to cause the electronic device to perform the method as described in any of the first aspects.

[0033] This disclosure provides an image processing method, apparatus, electronic device, and readable storage medium. The method determines the storage method of the first image by analyzing the proportion of the difference image blocks corresponding to the first image during the image editing process and the snapshot types of the last N snapshots in the snapshot chain generated according to the continuous image editing instructions. This aims to reasonably reduce the disk storage space occupied by snapshots and reduce the time consumed by the electronic device to execute the user-inputted undo editing instructions. Attached Figure Description

[0034] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0035] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 A flowchart of the image processing method provided in the embodiments of this disclosure;

[0037] Figures 2a-2c This is a schematic diagram of the structure of the differential image region provided in this disclosure;

[0038] Figures 3a-3c This is a schematic diagram illustrating the relationship between the snapshot chain and the image sequence provided in this disclosure.

[0039] Figure 4 A flowchart of an image processing method provided in another embodiment of this disclosure;

[0040] Figure 5 A flowchart of an image processing method provided in another embodiment of this disclosure;

[0041] Figure 6 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of the present disclosure;

[0042] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0043] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0044] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0045] This disclosure provides an image processing method, apparatus, electronic device, readable storage medium, and program product. The method determines the storage method of the processed image by analyzing the proportion of differential image blocks in the processed image and the snapshot types of the last N snapshots in the snapshot chain generated according to continuous image editing instructions during the image editing process, so as to reasonably reduce the disk storage space occupied by snapshots.

[0046] The image processing method provided in this disclosure can be executed by an electronic device. The electronic device may include a tablet computer, a mobile phone (such as a foldable phone, a large-screen phone, etc.), a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. This disclosure does not impose any limitations on the specific type of electronic device.

[0047] In the following embodiments, an electronic device is used as an example, and an image editing application (hereinafter referred to as "Application 1") is installed on the electronic device to illustrate the image processing method provided in this disclosure in detail.

[0048] Figure 1 A flowchart illustrating an image processing method provided in an embodiment of this disclosure. Please refer to... Figure 1 As shown, the method in this embodiment includes:

[0049] S101. Obtain the incremental snapshot corresponding to the first image.

[0050] In this solution, the first image is obtained by editing the second image according to a first editing instruction. The first editing instruction can be an instruction generated by the electronic device based on any image editing function provided by an image editing application.

[0051] For example, the first editing instruction may be obtained, but is not limited to, in the following ways:

[0052] For example, the electronic device may include a touch screen, and application 1 displays some controls corresponding to image editing functions on the display screen of the electronic device. The user inputs a first image editing command to the electronic device by operating (such as clicking) the controls corresponding to the image editing functions displayed on the touch screen.

[0053] For example, an electronic device is connected to input devices such as a mouse and a keyboard. Application 1 displays some controls corresponding to image editing functions on the display screen of the electronic device. The user inputs a first image editing command to the electronic device by operating the input devices such as the mouse and keyboard and inputting instructions for the controls.

[0054] It should be understood that the embodiments of this disclosure do not limit the specific implementation method of the electronic device obtaining the first editing command. For example, the user can also input the first editing command based on voice.

[0055] The incremental snapshot corresponding to the first image includes data of the difference image blocks between the first image and the second image.

[0056] Optionally, if region merging of the difference image patches is not performed, the incremental snapshot corresponding to the first image may include only the data of all difference image patches. (See also...) Figure 2a As shown, the image is divided into 70 image blocks, each labeled 1-70. Among these, image blocks labeled 9, 18, 19, 24, 31, 32, 37-41, 47, 48, and 52 are considered "discrepant" image blocks. If these discrepant image blocks are not merged, the incremental snapshot of the first image only includes data from these image blocks.

[0057] Optionally, if region merging is performed based on the difference image patches, the incremental snapshot corresponding to the first image may include data for each difference image region determined based on the continuity of the difference image patches. One possible implementation involves determining at least one difference image region and the image patches comprised of each difference image region based on the continuity of the difference image patches.

[0058] Reference Figure 2b As shown, based on the continuity between image blocks labeled 9, 18, 19, 24, 31, 32, 37-41, 47, 48, and 52, four differential image regions can be identified, as shown below. Figure 2b The difference image regions 1 to 4 are shown within the bold rectangular boxes. Figure 2bIt is known that some differential image regions include not only differential image blocks but also regular image blocks. Therefore, in this scheme, all image blocks included in differential image regions 1 to 4 are defined as differential image blocks.

[0059] Another possible implementation is to determine a difference image region based on the smallest bounding box of all difference image patches. For example... Figure 2c The difference image region shown in the bold rectangle is the smallest bounding box of the image blocks identified as 9, 18, 19, 24, 31, 32, 37-41, 47, 48, 52.

[0060] In this solution, by merging the regions of the difference image blocks, the data in the incremental snapshot can also be stored in units of difference image regions. If the user inputs an undo or redo command, the data can be read and written in units of difference image regions, which can reduce the number of I / O (input / output) operations and improve processing efficiency.

[0061] Alternatively, the incremental snapshot corresponding to the first image can be obtained, for example, in the following manner:

[0062] One possible implementation involves the electronic device processing the second image according to the first image editing instructions. First, the second image is divided into blocks according to a preset image segmentation method, and identification information is configured for each image block. Next, the electronic device performs image processing on the second image according to the first image editing instructions, obtaining the processed image (i.e., the first image) and the identification information of the modified image blocks, which are called difference image blocks. Then, based on the position information of these difference image blocks in the first image, the pixels included in the difference image blocks, and whether the difference image blocks need to be merged into a single difference image region, an incremental snapshot corresponding to the first image is generated.

[0063] Another possible implementation involves the electronic device processing the second image according to a first image editing instruction to obtain a processed image (i.e., the first image). Next, the electronic device divides both the first and second images into blocks using a preset image segmentation method. Then, it compares image blocks at the same location in both the first and second images to determine if there are differences. If differences exist, the image block at that location in the second image is marked as a differing image block; otherwise, it is marked as a regular image block. This comparison is performed block by block to identify all differing image blocks. Finally, based on the location information of the differing image blocks in the first image, the number of pixels included in the differing image blocks, and whether the differing image blocks need to be merged, an incremental snapshot corresponding to the first image is generated.

[0064] Optionally, the incremental snapshot corresponding to the first image can be stored in the data format shown in Table 1 below.

[0065] Table 1

[0066] Total number of horizontal image blocks P (4 bytes) The total number of vertical image blocks is Q (4 bytes). Total number of difference image patches W (4 bytes) The identifier of the first difference image patch (4 bytes) Size of the first difference image patch (4 bytes) The data for the first difference image patch (4 bytes) The identifier of the second difference image patch (4 bytes) Size of the second difference image patch (4 bytes) The data for the second difference image patch (4 bytes) …… The identifier (4 bytes) of the Wth difference image patch. Size of the Wth difference image patch (4 bytes) Data of the Wth difference image patch (4 bytes)

[0067] It should be understood that incremental snapshots can also be stored in other data formats in practical applications, and are not limited to the data storage formats shown in Table 1.

[0068] The preset image segmentation method can be determined by combining one or more factors such as image resolution, hardware resource usage of electronic devices, and segmentation method (equal or unequal segmentation).

[0069] For example, the image can be divided into blocks in a relatively fixed manner. For instance, a correspondence between the image resolution, image block size, and block division method can be established in advance. For example, for an image with a resolution of 4096*4096, the block division method is determined to be equal division by querying the above correspondence, and the size of each image block is 128*128.

[0070] Alternatively, the size of the image blocks can be flexibly set. For example, the edge regions of the image can be divided into blocks, with each block being larger; the central region of the image can be divided into blocks, with each block being smaller. Or, key regions of the image can be divided into blocks, with each block being smaller; non-key regions can be divided into blocks, with each block being larger. The key and non-key regions can be determined based on the position of the target object in the two images before and after processing, respectively.

[0071] S102. Based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time, determine the storage method corresponding to the first image; where N is an integer greater than or equal to 1.

[0072] The snapshot types include incremental snapshots and full snapshots. The storage method corresponding to the first image indicates which snapshot type the first image is stored in.

[0073] In this step, by combining the proportion of the difference image blocks corresponding to the first image and the snapshot types of the last N snapshots in the snapshot chain, the data of the first image is stored using a full snapshot method when the proportion of the difference image blocks corresponding to the first image is large and when the last N snapshots in the snapshot chain are all incremental snapshots. In other cases, the data of the first image is stored using an incremental snapshot method.

[0074] One possible implementation is that if the proportion of the differential image blocks included in the incremental snapshot corresponding to the first image is greater than or equal to a preset threshold, or if the last N snapshots in the snapshot chain are all incremental snapshots, i.e., satisfying any of the above conditions, then the storage method corresponding to the first image is to store the full snapshot corresponding to the first image; if the proportion of the differential image blocks included in the incremental snapshot corresponding to the first image is less than a preset threshold, and the N snapshots include a full snapshot, then the storage method corresponding to the first image is to store the incremental snapshot corresponding to the first image.

[0075] Optionally, the preset threshold is equal to 0.5, and N is equal to 3. However, the preset threshold and N can also be set to other values, and this disclosure does not limit their values. For example, the preset threshold and N values ​​can be determined based on the storage resource usage of the electronic device. Of course, other factors besides the storage resource usage of the electronic device can also be considered, and this disclosure does not limit their values.

[0076] By storing incremental and full snapshots appropriately in the snapshot chain, both the disk space occupied by snapshots and the time spent on undoing edit commands are reduced. Specifically, storing incremental snapshots reduces the disk space occupied by snapshots; by storing full snapshots appropriately, when a user enters an undo edit command, the electronic device can read the most recent full snapshot and execute the undo edit command, thus returning the result to the user more quickly and reducing the time spent by the electronic device to execute the user's undo edit command.

[0077] S103. Based on the storage method corresponding to the first image, store the incremental snapshot or full snapshot corresponding to the first image into the snapshot chain.

[0078] Specifically, if the storage method corresponding to the first image indicates storing the full snapshot corresponding to the first image, then the full snapshot corresponding to the first image is stored in the target snapshot node in the snapshot chain.

[0079] If the storage method corresponding to the first image indicates that the incremental snapshot corresponding to the first image is stored, then the incremental snapshot corresponding to the first image is stored in the target snapshot node in the snapshot chain.

[0080] For example, refer to Figure 3a As shown, assuming A1 represents the input original image, the original image can be of any type, such as a natural landscape image, a building image, a food image, a still life image, etc. This disclosure does not limit the content of the original image. The electronic device processes the original image A1 sequentially according to the user's input instructions, applying filters, stickers, and background blurring. (Referring to...) Figure 3aAs shown, snapshot node B1 is used to store the snapshot corresponding to the original image; B2 is used to store the snapshot corresponding to image A2 obtained by applying a filter to A1; B3 is used to store the snapshot corresponding to image A3 obtained by applying a sticker to A2; and B4 is used to store the snapshot corresponding to image A4 obtained by applying background blurring to A3.

[0081] Here we combine Figure 3a The scenario shown illustrates how to store a full or incremental snapshot of the first image into the snapshot chain in the following ways:

[0082] Scenario 1: The user did not enter any undo edit command before entering the first edit command.

[0083] In this case, a new snapshot node is created at the end of the snapshot chain. This new snapshot node is the aforementioned target snapshot node. The full snapshot or incremental snapshot corresponding to the first image is stored in this new snapshot node.

[0084] For example, suppose the user enters a first editing instruction to instruct the addition of a border to image A4; since the user did not enter any undo editing instruction before entering the first editing instruction, therefore, referring to Figure 3b As shown, a new snapshot node B5 is created at the end of the snapshot chain. This new snapshot node B5 is used to store a snapshot of image A5 obtained after adding a border to image A4.

[0085] Scenario 2: Before entering the first editing command, the user entered S undo editing commands and R redo editing commands.

[0086] In this scenario, the order in which the S undo and R redo editing commands are entered is not restricted. For example, a user can enter the S undo commands consecutively, followed by the R redo commands consecutively; alternatively, a user can enter the undo and redo commands in an alternating manner. Of course, other orders can also be used to enter the undo and redo commands, and this disclosure does not impose any restrictions on this.

[0087] In scenario 2, the electronic device can analyze the order of S undo edit instructions and R undo edit instructions to map each instruction to a snapshot node in the snapshot chain, thereby ultimately determining whether the target snapshot node corresponding to the first edit instruction is an existing snapshot node in the snapshot chain or a newly created snapshot node.

[0088] The relationship between the number of undo and redo edit commands affects the location of the target snapshot node. The following examples provide detailed descriptions of two scenarios: when the number of undo edit commands S is greater than the number of redo edit commands R, and when the number of undo edit commands S is equal to the number of redo edit commands R.

[0089] (a) When S is greater than R

[0090] In this case, it is necessary to determine the position of the target snapshot node in the snapshot chain based on the specific circumstances of the undo and redo edit commands.

[0091] For example, suppose the user enters two undo commands before adding a border to the image, and then enters one redo command. Therefore, referring to... Figure 3c As shown, two consecutive undo edit commands can revert to image A2, and then a redo edit command can restore to image A3. That is, the first edit command entered by the user is used to instruct the addition of a border to image A3. Then, the target snapshot node should be snapshot node B4. Adding a border to image A3 will obtain a new image A4', and the full snapshot or incremental snapshot corresponding to image A4' will be stored in snapshot node B4.

[0092] (b) When S equals R

[0093] In this case, since the number of undo and redo editing commands is the same, it is equivalent to the user not entering any undo or redo editing commands before entering the first editing command.

[0094] Therefore, the implementation method of scenario 1 above can be referred to, and will not be repeated here.

[0095] In practical applications, there may be other situations where the implementation principle is similar: each instruction is mapped to a snapshot chain to determine the target snapshot node corresponding to the first editing instruction.

[0096] In this embodiment, by analyzing the proportion of the difference image blocks corresponding to the first image during the image editing process and the snapshot types of the last N snapshots in the snapshot chain generated according to the continuous image editing instructions, the storage method of the first image is determined, so as to reasonably reduce the disk storage space occupied by the snapshots and reduce the time consumed by the electronic device to execute the user-inputted undo editing instructions.

[0097] Figure 4 A flowchart illustrating an image processing method provided in another embodiment of this disclosure. (See also...) Figure 4 As shown, the method in this embodiment includes:

[0098] S201. Obtain the incremental snapshot corresponding to the first image.

[0099] S202. Based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time, determine the storage method corresponding to the first image; where N is an integer greater than or equal to 1.

[0100] S203. Based on the storage method corresponding to the first image, store the incremental snapshot or full snapshot corresponding to the first image into the snapshot chain.

[0101] S204. Based on the storage method corresponding to the first image, cache the incremental snapshot or full snapshot corresponding to the first image into the memory space.

[0102] The memory space is used to cache M snapshots in the snapshot chain in chronological order from back to front, where M is an integer greater than or equal to 1 and less than or equal to N.

[0103] Furthermore, in this embodiment, the execution order of S203 and S204 is not important.

[0104] In this embodiment, by caching some snapshots in the snapshot chain into memory, when the user inputs an undo / edit command, the snapshot used to execute the undo / edit command can be directly retrieved from memory. This simplifies the step of writing some snapshots from the target snapshot into memory from external disk space, improving processing efficiency and reducing user waiting time. Furthermore, the number of snapshots cached in memory can be flexibly set according to memory usage to reduce memory pressure caused by snapshot caching.

[0105] Figure 5 A flowchart illustrating an image processing method provided in another embodiment of this disclosure. (See also...) Figure 5 As shown, the method in this embodiment includes:

[0106] S301. Obtain the target snapshot from the snapshot chain according to the undo edit command for the third image.

[0107] The target snapshot used to execute the undo edit command includes: the target full snapshot, and all snapshots between the target full snapshot and the snapshot corresponding to the third image.

[0108] The target full snapshot is the first full snapshot in the snapshot chain, arranged chronologically from back to front, and preceding the snapshot corresponding to the third image. All snapshots between the target full snapshot and the snapshot corresponding to the third image are incremental snapshots.

[0109] As described above, the memory space stores the last M snapshots in the snapshot chain. If the undo / edit command obtained in this step is the Xth consecutively entered undo / edit command, and if X is an integer greater than M, it means that the M snapshots cached in the memory space only include a portion of the target snapshot. Therefore, the remaining required snapshots can be read from the external disk space and written into the memory space. If X is less than or equal to M, it means that the M snapshots cached in the memory space only include all snapshots of the target snapshot. The M snapshots cached in the memory space can be directly used to execute the undo / edit command, simplifying the step of writing a portion of the target snapshot from the external disk space into the memory space and improving processing efficiency.

[0110] S302. Based on the target snapshot, restore the fourth image, wherein the third image is obtained by editing the fourth image according to the second editing instruction.

[0111] Specifically, all snapshots located between the target full snapshot and the snapshot corresponding to the third image are incremental snapshots, and the image blocks at the corresponding positions are replaced sequentially according to the time sequence.

[0112] Assume the target full snapshot is denoted as Full(1). All snapshots between the target full snapshot Full(1) and the snapshot corresponding to the third image include Diff(1) and Diff(2). First, replace the image block at the corresponding position in Full(1) with Diff(1) to obtain Result(1); then, replace the image block at the corresponding position in Result(1) with Diff(2) to obtain Result(2). Result(2) is the snapshot corresponding to the fourth image. The electronic device restores and displays the fourth image based on Result(2).

[0113] If the user enters the undo edit command multiple times in a row, then S301 to S302 can be executed repeatedly.

[0114] Because full snapshots are appropriately inserted during image storage, this embodiment can quickly restore images based on all snapshots between the nearest target full snapshot and the snapshot corresponding to the current image, effectively reducing user waiting time.

[0115] By way of example, this disclosure also provides an image processing apparatus.

[0116] Figure 6 This is a schematic diagram of the structure of an image processing apparatus provided according to an embodiment of the present disclosure. (Refer to...) Figure 6 As shown, the image processing apparatus 600 provided in this embodiment includes:

[0117] The acquisition module 601 is used to acquire an incremental snapshot corresponding to the first image; wherein, the incremental snapshot includes data of the difference image blocks between the first image and the second image, and the first image is obtained by editing the second image according to a first editing instruction;

[0118] The processing module 602 is configured to determine the storage method corresponding to the first image based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time; wherein N is an integer greater than or equal to 1; and to store the incremental snapshot or full snapshot corresponding to the first image into the snapshot chain according to the storage method corresponding to the first image.

[0119] In some possible designs, the processing module 602 is specifically configured to store the first image as a full snapshot if the proportion of the differential image blocks included in the incremental snapshot is greater than or equal to a preset threshold, or if all N snapshots are incremental snapshots; and if the proportion of the differential image blocks included in the incremental snapshot is less than a preset threshold, and the N snapshots include a full snapshot, then the first image is stored as an incremental snapshot.

[0120] In some possible designs, the incremental snapshot includes data from at least one differential image region; when there are multiple differential image regions, each differential image block between the first image and the second image belongs to one of the multiple differential image regions.

[0121] In some possible designs, the at least one difference image region is determined based on the continuity between difference image blocks between the first image and the second image.

[0122] In some possible designs, the processing module 602 is further configured to cache the incremental snapshot or full snapshot corresponding to the first image into a memory space according to the storage method corresponding to the first image. The memory space is used to cache M snapshots in the snapshot chain in chronological order from back to front, where M is an integer greater than or equal to 1 and M is less than or equal to N.

[0123] In some possible designs, the processing module 602 is further configured to obtain a target snapshot from the snapshot chain according to an undo edit instruction for the third image; the target snapshot includes: a target full snapshot, and all snapshots between the target full snapshot and the snapshot corresponding to the third image; the target full snapshot is the first full snapshot in the snapshot chain arranged in chronological order from back to front, and located before the snapshot corresponding to the third image; and based on the target snapshot, restore the fourth image, the third image being obtained by editing the fourth image according to the second edit instruction.

[0124] In some possible designs, the processing module 602 is specifically configured to: if the M snapshots cached in the memory space include the target snapshot, then obtain the target snapshot from the memory space; if the M snapshots cached in the memory space do not include a partial snapshot of the target snapshot, then read the partial snapshot from the external storage space (i.e., external disk space) and write it into the memory space.

[0125] The image processing apparatus provided in this embodiment can be used to execute the technical solutions of any of the above method embodiments. Its implementation principle and technical effect are similar, and for the sake of brevity, it will not be described again here.

[0126] Figure 7 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present disclosure. (Refer to...) Figure 7 As shown, the electronic device 700 provided in this embodiment includes a memory 701 and a processor 702.

[0127] The memory 701 can be a separate physical unit, connected to the processor 702 via a bus 703. Alternatively, the memory 701 and processor 702 can be integrated together, implemented in hardware, etc.

[0128] The memory 701 is used to store program instructions, and the processor 702 calls the program instructions to execute the operations of any of the above method embodiments.

[0129] Optionally, when some or all of the methods in the above embodiments are implemented by software, the electronic device 700 may also include only the processor 702. The memory 701 for storing programs is located outside the electronic device 700, and the processor 702 is connected to the memory via circuits / wires to read and execute the programs stored in the memory.

[0130] The processor 702 can be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and an NP.

[0131] The processor 702 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0132] The memory 701 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory may also include a combination of the above types of memory.

[0133] This disclosure also provides a computer-readable storage medium (also referred to as a readable storage medium) that includes computer program instructions, which, when executed by at least one processor of an electronic device, perform the technical solutions of any of the above method embodiments.

[0134] This disclosure also provides a program product comprising computer program instructions stored in a readable storage medium. At least one processor of an electronic device can read the computer program instructions from the readable storage medium, and the at least one processor executes the computer program instructions to cause the electronic device to perform the technical solution of any of the above method embodiments.

[0135] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0136] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. 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 this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An image processing method, characterized in that, include: Obtain an incremental snapshot corresponding to the first image; wherein, the incremental snapshot includes data of the difference image blocks between the first image and the second image, and the first image is obtained by editing the second image according to a first editing instruction; Based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time, the storage method corresponding to the first image is determined; where N is an integer greater than or equal to 1; Based on the storage method corresponding to the first image, the incremental snapshot or full snapshot corresponding to the first image is stored in the snapshot chain; According to the undo edit command for the third image, a target snapshot is obtained from the snapshot chain; the target snapshot includes: a target full snapshot, and all incremental snapshots between the target full snapshot and the snapshot corresponding to the third image; the target full snapshot is the first full snapshot in the snapshot chain in chronological order from back to front, and located before the snapshot corresponding to the third image; Based on the target snapshot, all incremental snapshots located between the target full snapshot and the snapshot corresponding to the third image are sequentially replaced with image blocks at corresponding positions in the target full snapshot in chronological order to restore the fourth image. The third image is obtained by editing the fourth image according to the second editing instruction.

2. The method according to claim 1, characterized in that, Based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged chronologically from back to front, the storage method of the first image is determined, including: If the proportion of the differential image blocks included in the incremental snapshot is greater than or equal to a preset threshold, or if all N snapshots are incremental snapshots, then the storage method corresponding to the first image is determined to indicate the storage of the full snapshot corresponding to the first image. If the proportion of the differential image blocks included in the incremental snapshot is less than the preset threshold, and the N snapshots include the full snapshot, then the storage method corresponding to the first image is determined to indicate the storage of the incremental snapshot corresponding to the first image.

3. The method according to claim 1, characterized in that, The incremental snapshot includes data from at least one differential image region; when there are multiple differential image regions, each differential image block between the first image and the second image belongs to one of the multiple differential image regions.

4. The method according to claim 3, characterized in that, The at least one difference image region is determined based on the continuity between difference image blocks between the first image and the second image.

5. The method according to claim 1, characterized in that, The method further includes: According to the storage method corresponding to the first image, the incremental snapshot or full snapshot corresponding to the first image is cached in the memory space. The memory space is used to cache M snapshots in the snapshot chain in chronological order from back to front, where M is an integer greater than or equal to 1 and M is less than or equal to N.

6. The method according to any one of claims 1 to 5, characterized in that, The step of obtaining the target snapshot from the snapshot chain according to the undo edit command for the third image includes: If the target snapshot is included in the M snapshots cached in the memory space, then the target snapshot is obtained from the memory space. If the M snapshots cached in the memory space do not include a portion of the target snapshot, then the portion of the snapshot is read from the external storage space and written to the memory space.

7. An image processing apparatus, characterized in that, include: An acquisition module is used to acquire an incremental snapshot corresponding to a first image; wherein, the incremental snapshot includes data of the difference image blocks between the first image and the second image, and the first image is obtained by editing the second image according to a first editing instruction; The processing module is configured to determine the storage method corresponding to the first image based on the proportion of the differential image blocks included in the incremental snapshot, and / or the N snapshots in the snapshot chain arranged from back to front in time; wherein N is an integer greater than or equal to 1; and to store the incremental snapshot or full snapshot corresponding to the first image into the snapshot chain according to the storage method corresponding to the first image. According to the undo edit command for the third image, a target snapshot is obtained from the snapshot chain; the target snapshot includes: a target full snapshot, and all incremental snapshots between the target full snapshot and the snapshot corresponding to the third image; the target full snapshot is the first full snapshot in the snapshot chain in chronological order from back to front, and located before the snapshot corresponding to the third image; Based on the target snapshot, all incremental snapshots located between the target full snapshot and the snapshot corresponding to the third image are sequentially replaced with image blocks at corresponding positions in the target full snapshot in chronological order to restore the fourth image. The third image is obtained by editing the fourth image according to the second editing instruction.

8. An electronic device, characterized in that, include: Memory, processor, and computer program instructions; The memory is configured to store the computer program instructions; The processor is configured to execute the computer program instructions to implement the method as described in any one of claims 1 to 6.

9. A readable storage medium, characterized in that, include: Computer program instructions, which are executed by at least one processor of an electronic device to implement the method as claimed in any one of claims 1 to 6.