The disclosure relates to image processing techniques, in particular to a method and system for image processing.
In the image processing techniques, editing and batch processing of images are the most basic and commonly used technique. Currently, many image processing tools have functions of single image editing and multi-image batch processing.
Single image editing includes conventionalt adjustments for image appearance such as adjustment of lightness and contrast, as well as some special effects of image processing. When an image is edited by image processing tools, only after one or more editing parameters are chosen, the image will enter editing adjustment phase and there will be an icon and text prompting a user to wait. The user may have to wait a long time before the final result of editing is shown. The reason for the above problems are: for single image editing and when editing parameters are adjusted, if it is required to process the original image in real time and show the result immediately (namely, to perform real time preview), the requirement of real time preview may not be met in terms of efficiency due to slow speed when the original image is large; however, the user will not have a smooth experience without real time preview, and will lack a certain degree of control in the editing and processing of the image.
Batch processing of images is a common technique to improve work efficiency, and is capable of considerably reduce repetitive operations of the user. For batch processing, some image processing tools only provide several edition functions for batch processing, such as format conversion, resizing, renaming of images, which are unrelated to editing of image content. Although some image processing tools do provide batch editing function for batch processing of image content, such as batch addition of image frame, watermark etc., they do not provide real time preview for batch editing, and the result of the batch editing is shown to the user only after the user has chosen a function such as batch generation of images. The speed of batch processing is often slow particularly when the number of the images is large. if the user is not satisfied with the result of the batch editing after a long time of waiting, the user has to iterate and go back to perform the batch editing again, which will increase the burden on the usage and the usage time; furthermore, batch editing provided by some image processing tools does not accept editing parameters from user input, but perform adjusting automatically, nor is real time preview available.
In short, existing image processing techniques have drawbacks in terms of real time image editing and preview, and do not implement real time preview of the result of image batch processing.
Accordingly, the disclosure aims to provide a method and system for image processing, so as to overcome drawbacks of existing image processing techniques in real time editing and preview.
To achieve the objective, the technical solution of the disclosure is implemented as follows.
The disclosure provides a method for image processing, the method includes:
loading and decrypting an image file to obtain an original image, and saving the original image;
shrinking the original image to obtain a pending image with a preset resolution, and saving the pending image;
editing the pending image and previewing the pending image in real time; and editing the original image after the real time preview.
The disclosure further provides a system for image processing, the system includes:
a loading decrypting unit configured to load and decrypt an image file to obtain an original image;
a resizing unit configured to shrink the original image to obtain a pending image with a preset resolution;
a saving unit configured to save the original image and the pending image; and
an editing previewing unit configured to edit the pending image, preview the pending image in real time, and edit the original image after the real time preview.
The method and system for image processing according to the disclosure mainly shrink a large original image, and adopt a way of separate processing of images, and specifically include: first loading and saving the original image; then performing shrink processing on the original image, and performing editing and real time previewing on the shrunken pending image, and only when effect of the preview is satisfying, editing the original image after real time preview is completed. When the real time previewing is performed, the editing is performed on the shrunken pending image, while the final image editing is performed on the original image, therefore this way of separate processing based on image shrink increases efficiency of real time preview. In addition, the original image can be further shrunken so as to assure efficiency of real time preview in the case of batch processing.
As the image processing speed is at the bottleneck of development, in order to increase efficiency of real time preview, the basic concept of the method for image processing with real time editing and preview according to the disclosure is that: the large original image is shrunken, edited and previewed in real time. As shown in
Step 101: loading and decrypting an image file to obtain an original image, and saving the original image.
In image processing of the disclosure, it is first required to load and decrypt the image file, and then save the obtained original image.
Furthermore, if the image supports partial decryption, a part of the image may be decrypted as required when the image is being loaded, and a part of the original image can be obtained.
As the part of the original image obtained by partial decryption is smaller than the entire original image obtained by complete decryption, compared with subsequent shrinking and saving of the entire original image, the time spent in performing the shrinking on the part of the original image is reduced, and the time for saving is also reduced.
Step 102: shrinking the original image to obtain a pending image with a preset resolution, and saving the pending image.
Preferably, the disclosure adopts the interpolation algorithm in image processing to shrink a large original image to a preset resolution, since the image generated by interpolation has a higher fidelity and better visual effect. The implementation of image resizing by interpolation is an existing technique and is not elaborated here. Of course, other image resizing techniques may be adopted depending on the practical requirement.
Wherein, the preset resolution may be set according to the practical application circumstance. In the case of batch processing, as the number of images is large, in order to assure efficiency of real time preview, the original image may be further shrunken. For example, in view of the situation that the resolution of the computer monitor is often smaller than the real size of the original image, the preset resolution may be set to be about 1000×1000, and to be about 500×500 during batch processing.
Step 103: editing and previewing the pending image in real time.
As the pending image, in particular the pending image obtained in the case of partial decryption, is smaller than the original image, therefore, the problem of low efficiency of real time preview caused by an oversized image is avoided when editing is performed on the pending image.
When image editing is performed, a foreground thread adjusts image editing parameters, and triggers a first background thread to perform a corresponding editing operation on the pending image according to the adjusted image editing parameters. An effect image is obtained after the editing operation is completed. The first background thread notifies the foreground thread to perform user interface update, which is mainly about showing the edited effect image on the user interface for real time preview.
Furthermore, during batch processing of images, the first background thread performs a corresponding editing operation on multiple pending images one by one; accordingly, the foreground thread shows the effect image s on the user interface one by one.
Step 104: editing the original image after the real time preview.
After real time preview, the user executes a saving operation via the foreground thread when the effect of image editing is determined to be satisfying according to the effect image previewed in real time, at this time, the foreground thread will trigger a second background thread to perform a corresponding editing operation on the original image according to the editing operation performed on the pending image by the first background thread.
Moreover, during batch processing of images, the second background thread performs a corresponding editing operation on multiple original images one by one.
Since the original image is large and takes long time to be processed, the foreground thread will be in a waiting state, during which operations such as adjustment of the editing parameter cannot be performed. Only after the second background thread completes the editing operation on the original image, does the second background thread notify the foreground thread to leave the waiting state and enter again a state in which the editing parameter is adjustable, so that a new round of image editing and real time previewing can be performed.
According to the method for image processing with real time editing and preview provided by the present disclosure, the process of single image editing is as follows:
According to the method for image processing with real time editing and previewing provided by the present disclosure, the process of batch processing of images is as follows:
In order to implement the method mentioned above, as shown in
a loading decrypting unit configured to load and decrypt an image file to obtain an original image;
a resizing unit configured to shrink the original image to obtain a pending image with a preset resolution;
a saving unit configured to save the original image and the pending image; and
an editing previewing unit configured to edit the pending image and preview the pending image in real time, as well as to edit the original image after the real time preview.
Furthermore, the resizing unit is configured to shrink the original image by an interpolation algorithm to obtain a pending image with a preset resolution;
Furthermore, the loading decrypting unit is configured to load and decrypt the image file corresponding to the original image to obtain the original image before the resizing unit shrinks the original image to obtain a pending image with a preset resolution;
Correspondingly, the saving unit is further configured to save the original image obtained by decryption.
Furthermore, the loading decrypting unit may be configured to decrypt the entire image file or part of the image file.
The editing previewing unit includes a foreground thread subunit and a first background thread subunit, wherein: the foreground thread subunit is configured to adjust mage editing parameters and trigger the first background thread subunit to execute an editing operation; and the first background thread subunit is configured to perform a corresponding editing operation on the pending image according to the adjusted image editing parameters to obtain an effect image, and notify the foreground thread subunit to show the effect image on a user interface for real time preview.
The foreground thread subunit is further configured to execute a saving operation after the real time preview, and trigger a second background thread subunit to execute an editing operation.
Correspondingly, the editing previewing unit further includes the second background thread subunit configured to perform a corresponding editing operation on the original image according to the editing operation performed on the pending image by the first background thread subunit; and correspondingly, the saving unit is further configured to save the edited original image.
What described above is merely the preferred embodiments of the disclosure and is not intended to limit the scope of protection of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201110370980.0 | Nov 2011 | CN | national |
This is a continuation application of International Patent Application No.: PCT/CN2012/084410, filed on Nov. 9, 2012, which claims priority to Chinese Patent Application No.: 2011103709800 filed on Nov. 21, 2011, the disclosure of which is incorporated by reference herein in its entirety.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2012/084410 | Nov 2012 | US |
Child | 14078398 | US |