Image processing method and device, storage medium and chip
By adding and processing multiple border watermarks in the image processing method, and supporting multiple storage formats, the problem of a single border watermark in the existing technology is solved, and the diversified image processing capabilities and user experience are improved.
Patent Information
- Application Number
- CN202310190568.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2024-08-23
AI Technical Summary
The border watermarks in the existing technology are relatively single and lack diversification, and cannot meet users' needs for diverse border watermarks.
Provide an image processing method that obtains the original image data, adds a left border watermark, a right border watermark, a top border watermark, and/or a bottom border watermark, and then vertically splices or rotates them before storing them. It supports multiple watermark formats and storage methods. , including JPEG and HEIF formats.
It realizes diversified watermark processing of images, improves user experience, reduces memory overhead and resource occupation, and is suitable for image processing of different formats.
Smart Images

Figure CN118537196A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular to an image processing method, device, storage medium and chip. Background Art
[0002] With the various demands of users for image processing, the demand for adding border watermarks to images has also emerged. However, the border watermarks in related technologies are relatively simple. Therefore, how to improve the diversity of border watermarks has become an urgent problem to be solved. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides an image processing method, device, storage medium and chip.
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image processing method, including:
[0005] Get the original image data;
[0006] In the case where it is determined to add a border watermark to the original image data, a target watermark is added to the original image data to obtain a target image, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark;
[0007] The target image is stored.
[0008] Optionally, the adding a target watermark to the original image data to obtain a target image includes:
[0009] Parsing the original image data into a YUV image in a target YUV format;
[0010] The target watermark is added to the YUV image to obtain a target image.
[0011] Optionally, the target YUV format is I420 format.
[0012] Optionally, before parsing the original image data into a YUV image in a target YUV format, the method further includes:
[0013] When the original image data is not in a one-to-one frame, the original image data is cropped into original image data in a one-to-one frame.
[0014] Optionally, adding the target watermark to the YUV image to obtain the target image includes:
[0015] When the target watermark includes a left border watermark and / or a right border watermark, the YUV image is vertically spliced with the left border watermark and / or the right border watermark in the target watermark to obtain a first target image with the left border watermark and / or the right border watermark added thereto.
[0016] Optionally, adding the target watermark to the YUV image to obtain the target image includes:
[0017] In a case where the target watermark includes a left border watermark and / or a right border watermark, but does not include an upper border watermark and / or a lower border watermark, rotating the first target image to zero degrees to obtain the target image;
[0018] In the case where the target watermark includes a left border watermark and / or a right border watermark, and also includes an upper border watermark and / or a lower border watermark, the first target image is rotated to zero degrees and then output to a target position of the YUV image in the target image; and
[0019] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0020] Optionally, adding the target watermark to the YUV image to obtain the target image includes:
[0021] In the case where the target watermark only includes the upper border watermark and / or the lower border watermark, the YUV image is rotated to zero degrees and then output to the target position of the YUV image in the target image; and
[0022] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0023] Optionally, storing the target image includes:
[0024] Convert the target image into a JPEG format image by using the libjpeg-turbo image codec; or,
[0025] Convert the target image into an image in HEIF format;
[0026] The image in the JPEG format or the image in the HEIF format is stored.
[0027] Optionally, storing the target image includes:
[0028] Determine image watermark information, wherein the image watermark information includes position information of the target watermark in the target image and / or position information of the original image data in the target image;
[0029] The image watermark information is written into the target image and then stored.
[0030] Optionally, the original image data is image data after completing any one or more of the following operations: adding a filter operation, a tilt-shift operation, and a peak focus operation.
[0031] Optionally, the data in the step of acquiring the original image data to the step of storing the target image are all stored in a memory buffer pool, or are all called from the memory buffer pool;
[0032] The method further comprises:
[0033] In response to new data being stored in the memory cache pool, if the memory cache pool is not full, the new data is stored at the top of the list in the memory cache pool; if the memory cache pool is full, the data at the bottom of the list in the memory cache pool is removed and the new data is stored at the top of the list in the memory cache pool;
[0034] In response to the data in the memory cache pool being called, the data is moved to the top of the list in the memory cache pool.
[0035] According to a second aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:
[0036] An acquisition module, configured to acquire raw image data;
[0037] A processing module is configured to add a target watermark to the original image data to obtain a target image when it is determined to add a border watermark to the original image data, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark;
[0038] The storage module is configured to store the target image.
[0039] According to a third aspect of an embodiment of the present disclosure, there is provided an image processing apparatus, including:
[0040] processor;
[0041] a memory for storing processor-executable instructions;
[0042] Wherein, the processor is configured to:
[0043] Get the original image data;
[0044] In the case where it is determined to add a border watermark to the original image data, a target watermark is added to the original image data to obtain a target image, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark;
[0045] The target image is stored.
[0046] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of any one of the methods described in the first aspect of the present disclosure are implemented.
[0047] According to a fifth aspect of an embodiment of the present disclosure, a chip is provided, comprising a processor and an interface; the processor is used to read instructions to execute any one of the methods described in the first aspect of the present disclosure.
[0048] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: by acquiring original image data, adding an upper border watermark, a lower border watermark, a left border watermark and / or a right border watermark to the original image, and storing the target image with the watermark added, the processed image can have more information, ensuring the diversity of border watermarks and improving the user experience.
[0049] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0051] Figure 1 The figure is a flowchart of an image processing method according to an exemplary embodiment.
[0052] Figure 2 The figure is a schematic diagram showing the use of a memory cache according to an exemplary embodiment.
[0053] Figure 3 The figure is a flowchart of an image processing method according to an exemplary embodiment.
[0054] Figure 4 is a block diagram of an image processing apparatus according to an exemplary embodiment.
[0055] Figure 5 is a block diagram of a device for image processing according to an exemplary embodiment. DETAILED DESCRIPTION
[0056] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0057] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located, and with the authorization given by the owner of the corresponding device.
[0058] Figure 1 is a flowchart of an image processing method according to an exemplary embodiment. The execution subject of the method may be, for example, a mobile phone, a tablet, a computer or other electronic device. The electronic device may be any electronic device with image processing capability. The electronic device may also have image shooting capability. Figure 1 As shown, the method includes:
[0059] S101, obtaining original image data.
[0060] In some embodiments, the original image data may be original image data captured by a camera. For example, the original image data may be RGB (red, green, blue) image data, which may include three planes, i.e., data of three dimensions.
[0061] In some other optional embodiments, the original image data is the image data after completing any one or more of the following operations: adding a filter operation, an axis shift operation, and a peak focus operation. For example, based on the RGB image data, a pre-trained neural network model or an image processing module can be input to process the captured image data to obtain the original image data for adding a border watermark. With this solution, by adding a border watermark to the image after performing special effects such as filters, axis shifts, and peak focus before executing steps S102 and S103, there is no need to perform multiple format conversions on the image data, thereby improving image processing efficiency and resource usage.
[0062] S102. When it is determined to add a border watermark to the original image data, a target watermark is added to the original image data to obtain a target image, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark.
[0063] The target watermark may be pre-configured by the user. For example, the target watermark may include shooting time, shooting location, shooting equipment information, shooting parameters, etc. The user may configure the target watermark according to actual needs. In addition, the target watermark may include one or more of the left border watermark, the right border watermark, the upper border watermark, and the lower border watermark, which may also be pre-configured by the user. The present disclosure does not specifically limit this.
[0064] S103: Store the target image.
[0065] It can be understood that the image data used in steps S101 to S102 may be temporarily stored in a memory such as a RAM (Random Access Memory), and step S103 may specifically refer to storing the processed target data in a non-temporary storage medium such as a hard disk, so that the user can access and view the target image in the non-temporary storage medium.
[0066] In the disclosed embodiment, by acquiring the original image data and adding an upper border watermark, a lower border watermark, a left border watermark and / or a right border watermark to the original image, and storing the target image with the watermark added, the processed image can have more information, ensuring the diversity of the border watermark and improving the user experience.
[0067] In some optional embodiments, the step of adding a target watermark to the original image data to obtain a target image includes:
[0068] Parsing the original image data into a YUV image in a target YUV format;
[0069] The target watermark is added to the YUV image to obtain a target image.
[0070] Specifically, YUV data may be parsed from three planes of RGB image data to obtain image data in YUV format.
[0071] Correspondingly, the format corresponding to the target watermark may be the same as the target YUV format. If the target watermark format is a bitmap, the target watermark in the bitmap format may be converted to the target YUV format before adding the border watermark.
[0072] It is worth noting that in the related art, a JPEG format image is usually obtained from a non-temporary storage medium, such as a mobile phone album, and the JPEG format image is decoded into a bitmap, and then the image is processed based on the bitmap to obtain an image with a border added. However, the algorithm for decoding JPEG into a bitmap is slow, and the memory space occupied by the bitmap is also large, making it difficult to achieve fast border watermark addition.
[0073] By adopting the above scheme, before adding a border watermark to the original image data, the original image data is first parsed into a YUV image in YUV format, and a border watermark is added based on the YUV image. Since the image in YUV format occupies little memory, each pixel only occupies 1.5 bytes, it can effectively reduce memory overhead, improve image processing efficiency, and reduce resource usage.
[0074] In some embodiments, the target YUV format is I420 format. In other embodiments, the target YUV format may also be a YUV format commonly used by Android terminals such as NV21, NV12 or YV12.
[0075] Those skilled in the art may make a choice based on their specific needs and image processing flow. In the embodiment of the present disclosure, based on considerations of processing performance and memory, the target YUV format may be set to the I420 format.
[0076] Specifically, NV21 is a common format for Android, and there is an officially supported soft-editing JPEG interface YuvImage. However, considering that HeifWriter only supports the I420 format as the input source, if you choose the NV21 format, although you can use the official soft-editing interface YuvImage to process JPEG photos, when taking HEIF format photos, you need to convert NV21 to I420 first, which will sacrifice some performance and memory; if you choose the I420 format, although HEIF has the best performance and memory, you cannot use the official YuvImage to soft-edit JPEG.
[0077] Based on this, in some optional embodiments, storing the target image includes:
[0078] The target image is converted into an image in JPEG format by using a libjpeg-turbo image codec; or, the target image is converted into an image in HEIF format; and the image in JPEG format or the image in HEIF format is stored.
[0079] Optionally, converting the target image into an image in HEIF format may be implemented through a HeifWriter interface.
[0080] Among them, the libjpeg-turbo image codec can quickly and effectively convert I420 format images to JPEG format, and it also has better performance than the Android YuvImage official interface.
[0081] By adopting the above scheme, the target image is converted into an image in JPEG format through the libjpeg-turbo image codec, or the target image is converted into an image in HEIF format. Not only can the target image be reliably converted into an image in JPEG format, but the target image can also be converted into HEIF format. While ensuring performance, there is no need to convert the image format multiple times, thereby effectively reducing memory usage.
[0082] In some optional embodiments, before parsing the raw image data into a YUV image in a target YUV format, the method further includes:
[0083] When the original image data is not in a one-to-one frame, the original image data is cropped into original image data in a one-to-one frame.
[0084] The method may be implemented by using libyuv library to crop the original image data of non-one-to-one aspect ratio into the original image data of one-to-one aspect ratio.
[0085] Those skilled in the art should know that the image processing method can be applied to image processing chips with different image sizes, such as Qualcomm, which has a relatively high market share. By adopting the above solution, by judging whether the image of the original image data is a one-to-one image and cropping the original image data if the image is not a one-to-one image, the image processing method can be applied to image processing chips with different image sizes, which effectively improves the applicability of the method.
[0086] In some optional embodiments, adding the target watermark to the YUV image to obtain the target image includes:
[0087] When the target watermark includes a left border watermark and / or a right border watermark, the YUV image is vertically spliced with the left border watermark and / or the right border watermark in the target watermark to obtain a first target image with the left border watermark and / or the right border watermark added thereto.
[0088] It is worth noting that when images based on the YUV format are stitched horizontally, the Y components and UV components need to be stitched row by row. When images in the YUV format are stitched vertically, the Y components and UV components can be stitched block by block, which can greatly improve the processing efficiency.
[0089] In addition, those skilled in the art should be aware that when the camera hardware is installed, it is 90 degrees perpendicular to the direction of the mobile phone. That is to say, when the mobile phone takes a photo at 0 degrees, the direction of the photo is 90 degrees, where the direction of the mobile phone is 0 degrees, which can refer to the angle of the mobile phone when the user is facing the front of the mobile phone and the upper frame of the mobile phone is vertically facing upwards. At this time, the upper part of the captured image actually corresponds to the left or right side of the user, which is 90 degrees.
[0090] Therefore, when adding left and right borders to the YUV image, the corresponding matrices of the left and right borders are located on the upper or lower side of the YUV image. Furthermore, the left and right borders can be added to the YUV image by vertical splicing without rotating the YUV image to obtain the first target image.
[0091] Specifically, the rotation of the YUV image or the first target image may be implemented through the libyuv library.
[0092] By adopting the above scheme, when it is determined that a left border watermark and / or a right border watermark needs to be added, the left border watermark and / or the right border watermark can be directly added to the YUV image by vertical splicing without rotating the image, which can greatly improve the efficiency of image processing and reduce memory usage.
[0093] In some further optional embodiments, adding the target watermark to the YUV image to obtain the target image comprises:
[0094] In a case where the target watermark includes a left border watermark and / or a right border watermark, but does not include an upper border watermark and / or a lower border watermark, rotating the first target image to zero degrees to obtain the target image;
[0095] In the case where the target watermark includes a left border watermark and / or a right border watermark, and also includes an upper border watermark and / or a lower border watermark, the first target image is rotated to zero degrees and then output to a target position of the YUV image in the target image; and
[0096] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0097] It can be understood that after rotating the first target image to zero degrees, if there is no need to add an upper border watermark and / or a lower border watermark, the rotated image can be stored, and the rotated image is 0 degrees. If it is necessary to add an upper border watermark and / or a lower border watermark, the upper border watermark and / or the lower border watermark are respectively located on the upper / lower side of the rotated image, and then vertical splicing can be used for splicing.
[0098] By adopting the above scheme, after obtaining the first target image, if there is no need to add an upper border watermark and / or a lower border watermark, the first target image can be rotated to obtain a target image with a left / right border watermark. If it is necessary to add upper and lower border watermarks, the data can be output to the position after splicing while rotating the photo, and then the upper and lower borders can be spliced to the upper or lower part of the first target image by vertical splicing. By rotating the image and splicing the image simultaneously, the image processing speed can be effectively improved and the memory overhead can be reduced.
[0099] In some other optional embodiments, the adding the target watermark to the YUV image to obtain the target image includes:
[0100] In the case where the target watermark only includes the upper border watermark and / or the lower border watermark, the YUV image is rotated to zero degrees and then output to the target position of the YUV image in the target image; and
[0101] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0102] By adopting the above scheme, when it is determined that there is no need to add a left border watermark and / or a right border watermark, the upper / lower border watermark can be added to the YUV image while the YUV image is directly rotated. By rotating the image and stitching the image simultaneously, the image processing speed can be effectively improved and the memory overhead can be reduced.
[0103] In some optional embodiments, storing the target image includes:
[0104] Determine image watermark information, wherein the image watermark information includes position information of the target watermark in the target image and / or position information of the original image data in the target image;
[0105] The image watermark information is written into the target image and then stored.
[0106] Specifically, the image watermark information may be XMP (Extensible Metadata Platform) information. XMP is an ISO standard (ISO 16684-1:2012) that aims to standardize the metadata of digital image data.
[0107] Optionally, the EXIF information may be written into the target image before being stored. The EXIF information may be used to record the attribute information and shooting data of the digital photo.
[0108] By adopting the above scheme, by determining the image watermark information, and writing the watermark position coordinates or the original image position coordinates and other information into the target image through the image watermark information and then storing it, the user can parse out the watermark or original image position information when editing the photo later after adding the watermark, thereby achieving the purpose of removing the watermark, thereby meeting different user needs and improving user experience.
[0109] Based on the above embodiments, although the memory usage can be effectively reduced, however, with the increasing number of photo pixels today, often reaching 64 million or even 100 million pixels, if each pixel occupies 1.5 bytes, a 100 million pixel photo will occupy 150MB of memory, plus some memory overhead generated in the intermediate process, a single photo may very likely use more than 400MB of memory, and if it is continuous shooting, it is more likely to exceed 1GB.
[0110] Therefore, in order to solve the problem of frequent large memory application and release when taking photos quickly or continuously, in some optional embodiments, the data in the step of obtaining the original image data to the step of storing the target image are all stored in the memory cache pool, or are all called from the memory cache pool;
[0111] The method further comprises:
[0112] In response to new data being stored in the memory cache pool, if the memory cache pool is not full, the new data is stored at the top of the list in the memory cache pool; if the memory cache pool is full, the data at the bottom of the list in the memory cache pool is removed and the new data is stored at the top of the list in the memory cache pool;
[0113] In response to the data in the memory cache pool being called, the data is moved to the top of the list in the memory cache pool.
[0114] Specifically, the data from the step of acquiring the original image data to the step of storing the target image may include the original image data, target watermark, target image, YUV image, one-to-one original image data, first target image, first target image rotated to zero degrees, YUV image rotated to zero degrees, image in JPEG format, image in HEIF format, image watermark information, etc. in the above-mentioned embodiments.
[0115] Among them, in this memory cache pool, after a single shot and the addition of a border, the memory occupied in the process will not be released, and the memory will be added to the memory cache pool. When the next photo task needs to apply for memory, it will first search from the memory cache pool to see if the required data exists. If it cannot be obtained in the memory cache pool, it will apply for the memory cache pool.
[0116] In order to make those skilled in the art more understand the scheme, the present disclosure provides Figure 2 A schematic diagram of a memory cache usage according to an exemplary embodiment is shown, referring to Figure 2 , the memory cache pool can store 3 object data, and the memory cache pool can be managed through the cache object list. If object A is newly added to the memory cache pool, object A can be used as the head of the cache object list, that is, stored at the top of the cache object list. If object B and object C are added at the same time, object B and object C can be stored at the top of the cache object list in turn. At this time, object A is moved to the end of the list, that is, the bottom of the list. At this time, if a new object D is added, object A at the bottom of the list is removed, and object D is stored at the top of the cache object list. Further, if it is determined that object B is called, object B can be moved to the top of the list to avoid object B being removed in the near future. Further, if object E is added, object C, which is at the bottom of the list at this time, is removed.
[0117] Based on the same inventive concept, Figure 3 is a flowchart of an image processing method according to an exemplary embodiment. Figure 3 As shown, the method includes:
[0118] S301 , parse I420 image data from three planes of original image data.
[0119] S302: Determine whether the image is a one-to-one image.
[0120] When it is determined that the input image is a one-to-one frame, step S304 to step S305 are executed; otherwise, step S303 to step S305 are executed.
[0121] S303, cropping the I420 image data into a one-to-one frame using libyuv.
[0122] S304: Convert the target watermark in bitmap format into I420 format.
[0123] S305: Determine whether the target watermark includes a left border watermark and / or a right border watermark.
[0124] In the case where it is determined that the target watermark includes the left border watermark and / or the right border watermark, step S306 to step S307 are executed; otherwise, step S307 is executed.
[0125] S306: Add a left border watermark and / or a right border watermark by vertical splicing.
[0126] S307: Determine whether the target watermark includes an upper border watermark and / or a lower border watermark.
[0127] When it is determined that the target watermark includes the upper border watermark and / or the lower border watermark, step S309 to step S311 are executed; otherwise, step S308 and step S310 to step S311 are executed.
[0128] S308, rotating the image to obtain a target image.
[0129] S309: Rotate the image and add an upper border watermark and / or a lower border watermark by vertical splicing to obtain a target image.
[0130] S310, convert to JPEG format through libjpeg-turbo, or convert to HEIF format through HeifWriter.
[0131] S311, write exif and / or XMP and store.
[0132] Among them, the above different steps can be implemented through different threads in the thread pool, that is, after the YUV data is transmitted to the processor, operations such as rotation and splicing watermarks can be performed in the thread pool, and finally soft-encoded into JPEG photos through the libjpeg algorithm library, or converted into HEIF photos through the Android general interface HeifWriter, and finally the exif information and xmp data information that supports album post-processing and watermark removal are written into the JPEG or HEIF photos.
[0133] In addition, in some other optional embodiments, step S307 and step S308 can be executed first, and then step S305 is executed. When it is determined that the target watermark includes a left border watermark and / or a right border watermark, the input image of step S305 is horizontally spliced with the target watermark to obtain the target image, or the input image of step S305 is rotated and vertically spliced, and the spliced image is rotated again to obtain the target image.
[0134] Figure 4 is a block diagram of an image processing device according to an exemplary embodiment. Figure 4 As shown, the image processing device 40 includes:
[0135] An acquisition module 41 is configured to acquire original image data;
[0136] The processing module 42 is configured to add a target watermark to the original image data to obtain a target image when it is determined to add a border watermark to the original image data, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark;
[0137] The storage module 43 is configured to store the target image.
[0138] Optionally, the processing module 42 is configured to:
[0139] Parsing the original image data into a YUV image in a target YUV format;
[0140] The target watermark is added to the YUV image to obtain a target image.
[0141] Optionally, the target YUV format is I420 format.
[0142] Optionally, the image processing device 40 includes:
[0143] The cropping module is configured to crop the original image data into original image data of a one-to-one frame when the original image data is not of a one-to-one frame.
[0144] Optionally, the processing module 42 is configured to:
[0145] When the target watermark includes a left border watermark and / or a right border watermark, the YUV image is vertically spliced with the left border watermark and / or the right border watermark in the target watermark to obtain a first target image with the left border watermark and / or the right border watermark added thereto.
[0146] Optionally, the processing module 42 is configured to:
[0147] In a case where the target watermark includes a left border watermark and / or a right border watermark, but does not include an upper border watermark and / or a lower border watermark, rotating the first target image to zero degrees to obtain the target image;
[0148] In the case where the target watermark includes a left border watermark and / or a right border watermark, and also includes an upper border watermark and / or a lower border watermark, the first target image is rotated to zero degrees and then output to a target position of the YUV image in the target image; and
[0149] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0150] Optionally, the processing module 42 is configured to:
[0151] In the case where the target watermark only includes the upper border watermark and / or the lower border watermark, the YUV image is rotated to zero degrees and then output to the target position of the YUV image in the target image; and
[0152] The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
[0153] Optionally, the storage module 43 is configured to:
[0154] Convert the target image into a JPEG format image by using the libjpeg-turbo image codec; or,
[0155] Convert the target image into an image in HEIF format;
[0156] The image in the JPEG format or the image in the HEIF format is stored.
[0157] Optionally, the storage module 43 is configured to:
[0158] Determine image watermark information, wherein the image watermark information includes position information of the target watermark in the target image and / or position information of the original image data in the target image;
[0159] The image watermark information is written into the target image and then stored.
[0160] Optionally, the original image data is image data after completing any one or more of the following operations: adding a filter operation, a tilt-shift operation, and a peak focus operation.
[0161] Optionally, the data in the step of acquiring the original image data to the step of storing the target image are all stored in a memory buffer pool, or are all called from the memory buffer pool;
[0162] The image processing device 40 comprises:
[0163] A storage control module is configured to, in response to new data being stored in the memory cache pool, store the new data at the top of a list in the memory cache pool if the memory cache pool is not full; if the memory cache pool is full, remove the data at the bottom of the list in the memory cache pool and then store the new data at the top of the list in the memory cache pool;
[0164] The moving module is configured to move the data to the top of the list of the memory cache pool in response to the data in the memory cache pool being called.
[0165] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0166] The present disclosure also provides a computer-readable storage medium on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the image processing method provided by the present disclosure are implemented.
[0167] Figure 5 8 is a block diagram of an apparatus 800 for image processing according to an exemplary embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0168] Reference Figure 5 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output interface 812 , a sensor component 814 , and a communication component 816 .
[0169] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned image processing method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0170] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0171] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0172] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0173] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0174] The input / output interface 812 provides an interface between the processing component 802 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0175] The sensor assembly 814 includes one or more sensors for providing various aspects of the status assessment of the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0176] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0177] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0178] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0179] In addition to being an independent electronic device, the above-mentioned device can also be a part of an independent electronic device. For example, in one embodiment, the device can be an integrated circuit (IC) or a chip, wherein the integrated circuit can be an IC or a collection of multiple ICs; the chip can include but is not limited to the following types: GPU (Graphics Processing Unit), CPU (Central Processing Unit), FPGA (Field Programmable Gate Array), DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), SOC (System on Chip, SoC), etc. The above-mentioned integrated circuit or chip can be used to execute executable instructions (or codes) to implement the above-mentioned image processing method. The executable instructions can be stored in the integrated circuit or chip, or can be obtained from other devices or equipment, such as the integrated circuit or chip includes a processor, a memory, and an interface for communicating with other devices. The executable instruction may be stored in the memory, and when the executable instruction is executed by the processor, the above-mentioned image processing method may be implemented; alternatively, the integrated circuit or chip may receive the executable instruction through the interface and transmit it to the processor for execution, so as to implement the above-mentioned image processing method.
[0180] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned image processing method when executed by the programmable device.
[0181] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0182] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that: include: Get the original image data; In the case where it is determined to add a border watermark to the original image data, a target watermark is added to the original image data to obtain a target image, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark; The target image is stored.
2. The method according to claim 1, characterized in that The step of adding a target watermark to the original image data to obtain a target image comprises: Parsing the original image data into a YUV image in a target YUV format; The target watermark is added to the YUV image to obtain a target image.
3. The method according to claim 2, characterized in that The target YUV format is I420 format.
4. The method according to claim 2, characterized in that: Before parsing the original image data into a YUV image in a target YUV format, the method further includes: When the original image data is not in a one-to-one frame, the original image data is cropped into original image data in a one-to-one frame.
5. The method according to claim 2, characterized in that: The step of adding the target watermark to the YUV image to obtain the target image comprises: When the target watermark includes a left border watermark and / or a right border watermark, the YUV image is vertically spliced with the left border watermark and / or the right border watermark in the target watermark to obtain a first target image with the left border watermark and / or the right border watermark added thereto.
6. The method according to claim 5, characterized in that The step of adding the target watermark to the YUV image to obtain the target image comprises: In a case where the target watermark includes a left border watermark and / or a right border watermark, but does not include an upper border watermark and / or a lower border watermark, rotating the first target image to zero degrees to obtain the target image; In the case where the target watermark includes a left border watermark and / or a right border watermark, and also includes an upper border watermark and / or a lower border watermark, the first target image is rotated to zero degrees and then output to a target position of the YUV image in the target image; and The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
7. The method according to claim 2, characterized in that The step of adding the target watermark to the YUV image to obtain the target image comprises: In the case where the target watermark only includes the upper border watermark and / or the lower border watermark, the YUV image is rotated to zero degrees and then output to the target position of the YUV image in the target image; and, The upper frame watermark and / or the lower frame watermark in the target watermark are vertically spliced to the upper part and / or the lower part of the target position to obtain the target image.
8. The method according to any one of claims 1 to 7, characterized in that: The storing of the target image comprises: Convert the target image into a JPEG format image by using the libjpeg-turbo image codec; or, Convert the target image into an image in HEIF format; The image in the JPEG format or the image in the HEIF format is stored.
9. The method according to any one of claims 1 to 7, characterized in that: The storing of the target image comprises: Determine image watermark information, wherein the image watermark information includes position information of the target watermark in the target image and / or position information of the original image data in the target image; The image watermark information is written into the target image and then stored.
10. The method according to any one of claims 1 to 7, characterized in that: The original image data is image data after completing any one or more of the following operations: adding a filter operation, a tilt-shift operation, and a peak focus operation.
11. The method according to any one of claims 1 to 7, characterized in that: The data in the step of acquiring the original image data to the step of storing the target image are all stored in the memory buffer pool, or are all called from the memory buffer pool; The method further comprises: In response to new data being stored in the memory cache pool, if the memory cache pool is not full, the new data is stored at the top of the list in the memory cache pool; if the memory cache pool is full, the data at the bottom of the list in the memory cache pool is removed and the new data is stored at the top of the list in the memory cache pool; In response to the data in the memory cache pool being called, the data is moved to the top of the list in the memory cache pool.
12. An image processing device, characterized in that: include: An acquisition module, configured to acquire raw image data; A processing module is configured to add a target watermark to the original image data to obtain a target image when it is determined to add a border watermark to the original image data, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark; The storage module is configured to store the target image.
13. An image processing device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: Get the original image data; In the case where it is determined to add a border watermark to the original image data, a target watermark is added to the original image data to obtain a target image, wherein the target watermark includes one or more of a left border watermark, a right border watermark, an upper border watermark, and a lower border watermark; The target image is stored.
14. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 11 are implemented.
15. A chip, characterized in that: The method comprises a processor and an interface; the processor is used to read instructions to execute the method according to any one of claims 1 to 11.
