Image processing method, device and electronic device
The automated image processing method addresses inefficiencies in existing methods by calculating scaling factors and adjusting coordinates to resize and crop images, enhancing efficiency and content retention.
Patent Information
- Application Number
- CN201910744345.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-13
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2039-08-13
AI Technical Summary
In the prior art, the image processing efficiency is low and the effect is poor, and the batch processing cannot be achieved by manual adjustment of the image size and editing area, resulting in the problem of incomplete picture content.
By calculating the original and target editing sizes of the picture, obtain the proportion coefficient, identify the main content of the picture, use the smartcrop.js plug-in to determine the starting point coordinates of the upper left corner, and perform scaling and cropping to generate a picture that meets the target size.
It significantly improves the efficiency of image processing, avoids the problem of incomplete subject content, and realizes batch processing and efficient editing of multi-size pictures.
Smart Images

Figure CN112396669B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and more particularly, to an image processing method, a dynamic video processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium. Background Art
[0002] In some scenarios, such as Internet operation, it is necessary to place picture-like materials. Therefore, it is necessary to process the pictures to meet the size requirements for placement. In the existing methods, usually, operators manually adjust the editing size of the pictures and select the editing area of the pictures, and then edit the pictures for placement accordingly. This manual processing method has low efficiency and cannot achieve batch processing of pictures. In addition, if existing picture editing plugins are directly used, there will be problems such as incomplete content in the processed pictures, and it is difficult to achieve satisfactory effects.
[0003] Therefore, how to improve the efficiency and effect of image processing simultaneously has become a problem to be solved. Summary of the Invention
[0004] An object of an embodiment of the present invention is to provide a new technical solution for image processing.
[0005] According to a first aspect of the present invention, there is provided an image processing method, including:
[0006] Obtaining a proportionality coefficient representing the size change according to the original size of the picture and the target editing size of the picture;
[0007] Obtaining the original upper left starting coordinate for editing the picture according to the target editing size, and obtaining the final upper left starting coordinate for editing the picture according to the proportionality coefficient and the upper left starting coordinate;
[0008] Processing the picture according to the final upper left starting coordinate and the target editing size, and obtaining and outputting a processing result.
[0009] Optionally, the obtaining the original upper left starting coordinate for editing the picture according to the target editing size includes:
[0010] Sending the picture and the target editing size to the smartcrop.js plugin;
[0011] Invoking the smartcrop.js plugin to perform an operation of determining the original upper left starting coordinate for editing the picture according to the target editing size;
[0012] Obtain the original upper left starting coordinate returned by the smartcrop.js plugin after performing the operation.
[0013] Optionally, before obtaining the scale factor for scaling the picture according to the original size of the picture and the target editing size of the picture, the method further includes:
[0014] In response to an operation of inputting a target editing size, provide an input entry for inputting the target editing size;
[0015] Obtain the target editing size input through the input entry.
[0016] Optionally, providing the input entry for inputting the target editing size includes:
[0017] Provide an input entry that supports inputting multiple target editing sizes.
[0018] Optionally, before obtaining the scale factor for scaling the picture according to the original size of the picture and the target editing size of the picture, the method further includes:
[0019] In response to a request for uploading picture information of the picture, provide an upload entry for uploading the picture information;
[0020] Obtain the picture information uploaded through the upload entry;
[0021] Obtain the original size of the picture according to the picture information.
[0022] Optionally, the picture information is the URL address of the picture corresponding to object storage; obtaining the original size of the picture according to the picture information includes:
[0023] According to the URL address of the picture, request the object storage server to provide the original size of the picture;
[0024] Obtain the original size of the picture returned by the object storage server according to the request.
[0025] Optionally, processing the picture according to the final upper left starting coordinate and the target editing size includes:
[0026] Starting from the final upper left starting coordinate, crop to the edge of the picture along the horizontal and vertical directions respectively to obtain a cropped picture;
[0027] Scale the cropped picture to the target editing size.
[0028] Optionally, the step of scaling the cropped picture to the target editing size includes:
[0029] Scaling the cropped picture in a way of equal proportion according to the target editing size to obtain a scaled picture, where the size of the scaled picture in at least one of the horizontal and vertical directions is equal to the size of the target editing size in the corresponding direction, and the area of the scaled picture is not less than the area corresponding to the target editing size;
[0030] Centrally cropping the scaled picture according to the target editing size to scale the cropped picture to the target editing size.
[0031] Optionally, before obtaining the final upper left starting coordinate for editing the picture according to the proportionality coefficient and the upper left starting coordinate, the method further includes:
[0032] In response to an operation of setting the final upper left starting coordinate, providing an input entry for inputting a correction coefficient of the final upper left starting coordinate;
[0033] Obtaining the correction coefficient input through the input entry;
[0034] The step of obtaining the final upper left starting coordinate for editing the picture according to the proportionality coefficient and the upper left starting coordinate includes:
[0035] Obtaining the final upper left starting coordinate according to the proportionality coefficient, the upper left starting coordinate, and the correction coefficient.
[0036] Optionally, the step of processing the picture according to the final upper left starting coordinate and the target editing size includes:
[0037] Obtaining a processing scheme for processing the picture according to the final upper left starting coordinate and the target editing size;
[0038] Generating a processing instruction for executing the processing scheme through an object storage server;
[0039] Taking the processing instruction as a parameter carried by the URL address corresponding to the object storage of the picture, and generating a parameter-carrying URL address instructing the object storage server to process the picture according to the processing scheme, so as to process the picture through the parameter-carrying URL address.
[0040] Optionally, the step of processing the picture according to the final upper left starting coordinate and the target editing size further includes:
[0041] Start the object storage server to process the picture according to the processing solution based on the parameterized URL address;
[0042] Obtain the processed picture returned by the object storage server as the processing result.
[0043] According to the second aspect of the present invention, there is also provided a picture processing method, including:
[0044] Obtain the picture to be processed and the target editing size of the picture;
[0045] Start the editing module to process the picture according to the target editing size, and obtain and output the processing result;
[0046] Wherein, the editing module processes the picture according to the target editing size, including:
[0047] Obtain a scale factor representing the size change according to the original size of the picture and the target editing size of the picture;
[0048] Obtain the original upper left starting coordinate for editing the picture according to the target editing size, and obtain the final upper left starting coordinate for editing the picture according to the scale factor and the upper left starting coordinate;
[0049] Process the picture according to the final upper left starting coordinate and the target editing size.
[0050] Optionally, obtaining the target editing size of the picture includes: obtaining multiple target editing sizes of the picture.
[0051] Optionally, the starting the editing module to process the picture according to the target editing size includes:
[0052] Start the editing module to process the picture for each target editing size in parallel.
[0053] According to the third aspect of the present invention, there is also provided a dynamic video processing method, including:
[0054] Obtain the static pictures that make up the dynamic video;
[0055] Obtain a scale factor representing the size change according to the original size of the dynamic image and the target editing size of the dynamic image;
[0056] Obtain the original upper left starting coordinate for editing the static picture according to the target editing size, and obtain the final upper left starting coordinate for editing the static picture according to the scale factor and the upper left starting coordinate;
[0057] Process the static picture according to the final upper left corner starting coordinate and the target editing size;
[0058] Connect the processed static pictures together in sequence to obtain an edited dynamic image. According to a fourth aspect of the present invention, there is also provided an image processing apparatus, including:
[0059] A scale factor acquisition module for obtaining a scale factor representing the size change according to the original size of the picture and the target editing size of the picture;
[0060] A starting coordinate acquisition module for obtaining the original upper left corner starting coordinate for editing the picture according to the target editing size, and obtaining the final upper left corner starting coordinate for editing the picture according to the scale factor and the upper left corner starting coordinate;
[0061] A processing module for processing the picture according to the final upper left corner starting coordinate and the target editing size, and obtaining and outputting a processing result.
[0062] According to a fifth aspect of the present invention, there is also provided an electronic device, including the apparatus described in the second aspect of the present invention; alternatively, the electronic device includes:
[0063] A memory for storing executable commands;
[0064] A processor for executing the method described in the first aspect or the second aspect of the present invention under the control of the executable commands.
[0065] According to a sixth aspect of the present invention, there is also provided a computer-readable storage medium storing executable instructions, and when the executable instructions are executed by a processor, the method described in the first aspect or the second aspect of the present invention is executed.
[0066] The beneficial effects of the embodiments of the present invention are as follows: It can automatically process pictures through steps such as recognition, scaling, and cropping to obtain a processing result that meets the target size requirements, significantly improving the picture processing efficiency compared with the manual processing method. In addition, this method performs scaling processing on the original upper left corner starting coordinate for editing, which is beneficial to overcoming problems such as incomplete main content when editing according to the original upper left corner starting coordinate, thereby obtaining a better picture processing effect. Further, based on the method of the embodiments of the present invention, in an application scenario where there are multiple different target editing sizes for the same picture, the picture processing efficiency can be significantly improved, saving a large number of editing operations for the operator. Through the following detailed description of the exemplary embodiments of the present invention with reference to the accompanying drawings, other features and advantages of the present invention will become clear. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The drawings incorporated in and forming a part of the specification illustrate embodiments of the present invention and, together with the description thereof, serve to explain the principles of the present invention.
[0068] Figure 1 It is a schematic diagram of an electronic device that can be used to implement the embodiments of the present invention.
[0069] Figure 2 It is a flowchart of the image processing method provided by the embodiments of the present invention.
[0070] Figure 3 It is a schematic diagram of a specific example provided by the embodiments of the present invention.
[0071] Figure 4 It is a schematic diagram of the comparison of the image processing results provided by the embodiments of the present invention.
[0072] Figure 5 It is a schematic diagram of the process of obtaining object data provided by the embodiments of the present invention.
[0073] Figure 6 It is a flowchart of the image processing method provided by another embodiment of the present invention.
[0074] Figure 7 It is a schematic diagram of the image processing apparatus provided by the embodiments of the present invention.
[0075] Figure 8 It is a schematic diagram of the electronic device provided by the embodiments of the present invention. Detailed Description of the Embodiments
[0076] Now, various exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that: Unless otherwise specifically stated, the relative arrangements, numerical expressions, and numerical values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0077] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way a limitation on the present invention or its application or use.
[0078] Techniques, methods, and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, the techniques, methods, and devices should be considered as part of the specification.
[0079] In all the examples shown and discussed herein, any specific values should be construed as merely exemplary and not as a limitation. Therefore, other examples of the exemplary embodiments may have different values.
[0080] It should be noted that like reference numerals and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0081] <Hardware Configuration>
[0082] Figure 1 The schematic diagram of the hardware device that can be used to implement the embodiments of the present invention is shown. As Figure 1 shown, the relevant hardware devices include a terminal device 100 and a server 200, and a network connection is established between the terminal device 100 and the server 200.
[0083] In this embodiment, the method of the embodiments of the present invention can be implemented by the terminal device 100 invoking the picture storage and / or picture processing resources provided by the server 200, etc.
[0084] In another embodiment, the method of the embodiments of the present invention can also be independently implemented by the terminal device 100, which is not limited herein.
[0085] The above-mentioned terminal device 100 can be a desktop computer, a laptop computer, a tablet computer, a mobile phone, etc., which is not limited herein. The terminal device 100 includes, for example, a processor 110, a memory 120, a communication device 130, an interface device 140, an input device 150, and an output device 160 shown in the figure. The processor 110 is, for example, a central processing unit CPU, a microprocessor MCU, etc. The memory 120 is, for example, a memory including a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The communication device 130 is, for example, used for wired communication or wireless communication. The interface device 140 is, for example, a serial bus interface, a parallel bus interface, a USB interface, etc. The input device 150 includes, for example, a keyboard, a mouse, a touch screen, etc. The output device includes, for example, a display screen, a speaker, etc.
[0086] The above-mentioned server 200 can be an integrated server, or a distributed server across multiple computers or computer data centers. It can be a blade server or a rack server, or a server cluster providing cloud services. The server 200 can be as Figure 3As shown, it includes a processor 210, a memory 220, a communication device 230, and an interface device 240. The processor 210 is, for example, a central processing unit (CPU), a microcontroller unit (MCU), etc. The memory 220 is, for example, a read-only memory (ROM), a random access memory (RAM), a non-volatile memory such as a hard disk, etc. The communication device 230 is used for, for example, wired communication or wireless communication. The interface device 240 includes, for example, a serial bus interface, a parallel bus interface, a USB interface, etc. Although the server 200 may also include an input device and an output device, these devices are not necessary for implementing the present invention, so they are omitted here.
[0087] Figure 1 The hardware devices shown are merely illustrative and are by no means intended to limit the present invention, its applications, or uses.
[0088] <Example 1>
[0089] This embodiment provides an image processing method, which is implemented, for example, by Figure 1 the terminal device 100 in Figure 2 As shown, this method includes the following steps S1100 - S1300:
[0090] Step S1100: Obtain a scale factor representing the size change according to the original size of the image and the target editing size of the image.
[0091] The original size of the above-mentioned image is the initial size of the image before processing, including the horizontal size, i.e., the width, and the vertical size, i.e., the height.
[0092] In one example, the way to obtain the original size of the image is as follows: The terminal device 100 responds to the request for the image information of the user to upload the image, provides an upload entry for uploading the image information, then obtains the image information uploaded through the upload entry, and finally obtains the original size of the image according to the image information.
[0093] The above-mentioned image information can be an image file or a URL address of the image, etc.
[0094] The target editing size of the above-mentioned image is the image size expected to be obtained after processing, and this size also includes the width and the height.
[0095] In one example, the way to obtain the target editing size of the image is as follows: The terminal device 100 responds to the operation of the user inputting the target editing size, provides an input entry for inputting the target editing size, and obtains the target editing size input through the input entry. In this way, it is convenient for the user to input the target editing size.
[0096] The above-mentioned size can be in pixels or in units such as centimeters and millimeters.
[0097] The image processing method in this embodiment not only involves cropping processing, but also involves scaling processing of the size, editing starting point coordinates, etc. of the image. The above proportionality coefficient is used to represent the size change in the processing process and can be applied to the subsequent steps of scaling processing.
[0098] In one example, the implementation manner of obtaining the above proportionality coefficient according to the above original size and the above target editing size is: calculate the ratio of the height in the target editing size to the height in the original size, and use this ratio as the longitudinal proportionality coefficient; calculate the ratio of the width in the target editing size to the width in the original size, and use this ratio as the transverse proportionality coefficient. In other examples, it is also possible to first multiply the relevant sizes by the corresponding scale factors and then calculate the proportionality coefficient.
[0099] After step S1100, perform the following step S1200:
[0100] Step S1200, obtain the original upper left corner starting point coordinates for editing the image according to the target editing size, and obtain the final upper left corner starting point coordinates for editing the image according to the proportionality coefficient and the upper left corner starting point coordinates.
[0101] In this embodiment, a coordinate system is established with the upper left corner of the image before processing as the origin, the horizontal right direction as the positive direction, and the vertical downward direction as the positive direction, and the coordinates of points are calculated based on this coordinate system.
[0102] For the above upper left corner starting point coordinates, starting from this coordinate point, crop a certain length horizontally to the right (for example, crop the set length or crop to the edge), and crop a certain length vertically downward (for example, crop the set length or crop to the edge). Finally, obtain a square image with this coordinate point as the upper left corner point, which is the cropped image.
[0103] In one example, the implementation manner of obtaining the original upper left corner starting point coordinates for editing the image according to the target editing size is: by means of image recognition, identify the main content of the image, such as identifying the people, objects, text, etc. in the image, and in combination with the target size, select an editing area around the main content of the image. The upper left corner coordinates of this editing area are the above original upper left corner starting point coordinates.
[0104] In another example, the implementation of obtaining the original top - left starting coordinates for editing the picture according to the target editing size is as follows: send the picture and the target editing size to the smartcrop.js plugin; call the smartcrop.js plugin to perform the operation of determining the original top - left starting coordinates for editing the picture according to the target editing size; obtain the original top - left starting coordinates returned by the smartcrop.js plugin after performing the operation.
[0105] The above - mentioned smartcrop.js plugin is a js plugin for identifying and cropping pictures. It can identify the main object in the picture and, combined with the target cropping size, provide the top - left starting coordinates and editing size for better cropping. Therefore, it is convenient to obtain the original top - left starting coordinates for editing the picture through the smartcrop.js plugin.
[0106] In this another example, based on the API interface provided by the smartcrop.js plugin, it is possible to interact with the smartcrop.js plugin for data transmission and calling the smartcrop.js plugin.
[0107] The above - mentioned final top - left starting coordinates for editing the picture are obtained by scaling the aforementioned original top - left starting coordinates. Through this scaling, it is beneficial to overcome problems such as incomplete main content when cropping according to the original top - left starting coordinates, thereby obtaining a better picture - processing effect.
[0108] In one example, the implementation of obtaining the final top - left starting coordinates for editing the picture according to the scale factor and the top - left starting coordinates is as follows: multiply the horizontal scale factor by the abscissa in the original top - left starting coordinates, and use the obtained product as the abscissa in the final top - left starting coordinates; multiply the vertical scale factor by the ordinate in the original top - left starting coordinates, and use the obtained product as the ordinate in the final top - left starting coordinates.
[0109] After step S1200, perform the following step S1300:
[0110] Step S1300, process the picture according to the final top - left starting coordinates and the target editing size, and obtain and output the processing result.
[0111] The above - mentioned processing result can be the processed picture file or the URL address of the processed picture.
[0112] In one example, according to the final starting coordinates of the upper left corner and the target editing size, the implementation of processing the picture is as follows: taking the point corresponding to the final starting coordinates of the upper left corner as the starting point, respectively cropping to the picture edge to the right and downwards to obtain the cropped picture, and scaling the cropped picture to the target editing size.
[0113] In one example, the implementation of scaling the cropped picture to the target editing size is as follows: in the horizontal direction, scaling the width of the cropped picture to the width of the target cropping size, and in the vertical direction, scaling the height of the cropped picture to the height of the target size.
[0114] In other examples, the implementation of scaling the cropped picture to the target editing size is as follows: according to the target editing size, scaling the edited picture in a proportional scaling manner to obtain the scaled picture, wherein the size of the scaled picture in at least one of the horizontal and vertical directions is equal to the size of the target editing size in the corresponding direction, and the area of the scaled picture is not less than the area corresponding to the target editing size; according to the target editing size, centering and cropping the scaled picture to scale the cropped picture to the target editing size.
[0115] The above-mentioned size of the scaled picture in at least one of the horizontal and vertical directions is equal to the size of the target editing size in the corresponding direction, and the area of the scaled picture is not less than the area corresponding to the target editing size, which means that the picture after proportional scaling is the smallest picture that can cover the target editing size area.
[0116] The above-mentioned implementation of centering and cropping the scaled picture according to the target editing size is, for example, placing the scaled picture in the center of the target editing size area and cropping off the part exceeding this area.
[0117] In the above method, proportional scaling is adopted, which can ensure that the picture does not deform and is conducive to obtaining a better processing effect.
[0118] The picture processing method in this embodiment can automatically process the picture through steps such as recognition, scaling, and cropping to obtain a processing result that meets the target size requirements, significantly improving the picture processing efficiency compared with the manual processing method. In addition, this method performs scaling processing on the original starting coordinates of the upper left corner for editing, which is conducive to overcoming problems such as incomplete main content when editing according to the original starting coordinates of the upper left corner, thereby obtaining a better picture processing effect.
[0119] In a specific example of this embodiment, the foregoing input entry for inputting the target editing size includes: providing an input entry that supports inputting multiple target editing sizes, where the multiple target editing sizes refer to at least two target editing sizes. That is to say, multiple target editing sizes can be input at one time through this input entry. After that, by executing the foregoing image processing method, the obtained processing results include multiple images corresponding one by one to the multiple target editing sizes, and these images are all obtained from the same original image. In this way, it is beneficial for users to batch obtain multiple images that meet different target size requirements.
[0120] In a specific example of this embodiment, before the method obtains the final upper left starting coordinate for editing the image according to the scale factor and the upper left starting coordinate, it further includes:
[0121] In response to the operation of setting the final upper left starting coordinate, providing an input entry for inputting the correction factor of the final upper left starting coordinate;
[0122] Obtaining the correction factor input through the input entry.
[0123] Correspondingly, in this specific example, the foregoing obtaining the final upper left starting coordinate for editing the image according to the scale factor and the upper left starting coordinate includes:
[0124] Obtaining the final upper left starting coordinate according to the scale factor, the upper left starting coordinate, and the correction factor.
[0125] In this specific example, the user is allowed to customize the positioning method of the final upper left starting point to meet the personalized needs of different users. Specifically, it is to obtain the correction factor input by the user through the relevant entry and adjust the positioning method of the default final upper left starting point through this correction factor.
[0126] In this specific example, the foregoing operation of adjusting the final upper left starting coordinate, for example, is that the user clicks the corresponding adjustment button, or the terminal device defaults that the user has performed this operation according to the preset settings.
[0127] In this specific example, the foregoing correction factor can be directly input. For example, the user directly inputs the numerical value of the correction factor in the relevant entry, such as numerical values like 0.8, 1.2, etc. The foregoing correction factor can also be indirectly input. For example, the user clicks the target position in the preview image where the final upper left starting point is desired to be adjusted, and the terminal device calculates the corresponding correction factor according to this target position.
[0128] The following provides a specific example of implementing the image processing method in this embodiment. See Figure 3, where Figure 3-1 shows the original picture before processing, and the original size of this picture is width a = 24.2 mm and height b = 23.6 mm. Taking the upper left corner point of the original picture as the origin, and taking the horizontal right direction as the positive direction and the vertical downward direction as the positive direction to establish a coordinate system, the coordinate system Oxy in Figure 3 is obtained.
[0129] Refer to Figure 3 Figure 3-2 in it. Assuming that the target editing size is width p = 15 mm and height q = 10 mm, it is easy to understand that in this example, the editing process of the picture is specifically the cropping of the picture. By the method of identifying the main content or through the smartcrop.js plug-in, the original upper left corner starting point for editing the picture is point A1, and the coordinates of this point are (x1, y1), where x1 = 4.99 and y1 = 11.45.
[0130] According to the original size and the target editing size, the scale factor for scaling the picture is calculated. Among them, the horizontal scale factor The vertical scale factor
[0131] Refer to Figure 3 Figure 3-3 in it. According to the above scale factor, the coordinates of the original upper left corner starting point, that is, point A1, are scaled to obtain the final upper left corner starting point A2 for editing, and the coordinates of this point are (x2, y2), where x2 = x1 * scale(x) = 4.99×0.42 = 2.12 and y2 = y1 * scale(y) = 11.45×0.62 = 7.04.
[0132] Refer to Figure 3 Figure 3-4 in it. Taking the final upper left corner starting point A2 as the starting point, crop to the edge in the horizontal and vertical directions respectively to obtain a square picture with point A2 as the upper left corner point, that is, Figure 3-4 the square picture in the lower middle part in
[0133] Refer to Figure 3 Figure 3-5 in it. The dotted box in it is the area corresponding to the target editing size. Scale the square picture cropped in the previous step until the width of this picture is just equal to the width of the target editing size and the height of this picture exceeds the height of the target editing size. Place the scaled picture in the middle of the area corresponding to the target size and crop off the part exceeding this area to obtain the processed picture, as shown in Figure 3 Figure 3-6 in
[0134] Refer to Figure 4, where 4-1 is the picture processed according to the method in this embodiment, and 4-2 is the picture directly edited based on the original upper left corner starting point. It can be seen that the torso of the person in 4-2 is also partially edited out, while the picture in 4-1 better retains the main content of the picture while meeting the target size requirements.
[0135] <Example Two>
[0136] This embodiment provides a picture processing method, which is implemented by the terminal device 100 in Figure 1 according to and / or invoking the picture processing resources provided by the server 200, where the server 200 is an object storage server.
[0137] The above object storage server is an electronic device for providing object storage services. Among them, object storage uses objects as the interface, integrating the advantages of NAS (Network Attached Storage) and SAN (Storage Area Network), and at the same time having the advantages of high-speed direct access of SAN and distributed data sharing of NAS.
[0138] In an example, as Figure 5 shown, the object storage server includes a metadata server (Metadata Server, MDS) 600 and an object-based storage device (OSD) 700. In this example, the process for the user to obtain object data is as follows: The user terminal device 500 sends a request to obtain object data to the metadata server 600. The metadata server 600 parses the request and sends the certificate of the user terminal device 500 to the corresponding object storage device 700. The object storage device 700 sends the object data to the user terminal device 500 according to the certificate, that is, provides a data reading service.
[0139] The picture processing method provided in this embodiment includes the following steps S2100-S2300:
[0140] Step S2100, obtain a proportionality coefficient representing the size change according to the original size of the picture and the target editing size of the picture.
[0141] Step S2200, obtain the original upper left corner starting point coordinates for editing the picture according to the target editing size, and obtain the final upper left corner starting point coordinates for editing the picture according to the proportionality coefficient and the upper left corner starting point coordinates.
[0142] Step S2300, process the picture according to the final upper left corner starting point coordinates and the target editing size, and obtain and output the processing result.
[0143] For the implementation manners of the above steps S2100 - S2300, reference may be made to the description of steps S1100 - S1300 in Embodiment 1. The differences between the image processing method in this embodiment and the image processing method in Embodiment 1 include:
[0144] In this embodiment, the image processing method is based on the object storage mode, and the image information of the image is the URL address corresponding to the object storage of the image. The implementation manner of obtaining the original size of the image according to the image information is: according to the URL address of the image, request the object storage server to provide the original size of the image; obtain the original size of the image returned by the object storage server according to the above request.
[0145] In this embodiment, the implementation manner of processing the image according to the final upper - left starting coordinates and the target editing size is: according to the final upper - left starting coordinates and the target editing size, obtain the processing scheme for processing the image; generate a processing instruction for executing the processing scheme through the object storage server; use the processing instruction as a parameter carried by the URL address corresponding to the object storage of the image, and generate a parameter - carrying URL address indicating the object storage server to process the image according to the processing scheme.
[0146] For example, in the specific example of image processing in Embodiment 1, the URL address of the image before processing is xxx.jpg. In the editing step of the processing scheme, the final upper - left starting coordinates for editing are (x2, y2), the editing method is to crop to the edge, and the processing instruction for this editing is crop,x2,y2. In the scaling step of the processing scheme, the target size for scaling is (p, q), and the scaling method is to scale the image to the smallest image that can fill the target size and then crop it in the center (denoted as m_fill), and the processing instruction for this scaling is resize,m_fill,p,q. Use the above processing instructions as parameters carried by the URL address of the object storage. For example, concatenate the above instructions in order to the URL address of the image before processing, and the obtained concatenated URL address is xxx.jpg?process = image / crop,x2,y2 / resize,m_fill,p,q. This URL address can instruct the object storage server to process the original image according to the above instructions, and achieve the purpose of obtaining the processed image through this parameter - carrying URL address.
[0147] In an example, the method of the embodiment of the present invention outputs the parameter - carrying URL address as the processing result, and the user can request the server to process the image according to this parameter - carrying URL address, and then obtain the processed image.
[0148] In one example, after obtaining the URL address with parameters, the method according to an embodiment of the present invention can further start the object storage server to process the picture according to the above processing solution based on the URL address with parameters, and then obtain the processed picture returned by the object storage server. In this way, the processed picture can be directly obtained without the need to store the pictures in the intermediate stage additionally.
[0149] <Embodiment III>
[0150] This embodiment provides a method for processing dynamic images, and this method is implemented by, for example, Figure 1 the terminal device 100 in. This method can be applied to adjusting the size of dynamic images, including the following steps S3100 - S3300:
[0151] Step S3100, obtain the static pictures that make up the dynamic image.
[0152] In this embodiment, the dynamic image is formed based on the principle of persistence of vision, such as a video, a GIF, etc. The composition of the GIF image can be decomposed into multiple static pictures. For example, a video is composed of each frame of the picture, and a GIF is composed of multiple static pictures.
[0153] Through the above step S3100, the processing of the dynamic image can be converted into the processing of static pictures.
[0154] Step S3200, obtain a scale factor representing the size change according to the original size of the dynamic image and the target editing size of the dynamic image;
[0155] In this embodiment, the same processing is performed on each static picture that makes up the dynamic image. It is easy to understand that the scale factor corresponding to the dynamic image and the scale factor corresponding to each static picture are the same.
[0156] Step S3300, obtain the original upper - left starting coordinate for editing the static picture according to the target editing size, and obtain the final upper - left starting coordinate for editing the static picture according to the scale factor and the upper - left starting coordinate;
[0157] Step S3400, process the static picture according to the final upper - left starting coordinate and the target editing size;
[0158] The above steps S3200 - S3400 can refer to the description of steps S1100 - S1300 in Embodiment I.
[0159] Step S3500, connect the processed static pictures in sequence to obtain the edited dynamic image.
[0160] In the above step S3500, connecting the processed static pictures in sequence may be connecting them together according to the sequence, transition mode, refresh frequency, etc. of the static pictures in the original dynamic video, or connecting them together according to the sequence of the static pictures in the original dynamic video, as well as other selected transition modes and / or refresh frequencies, etc., which is not limited herein.
[0161] Through the dynamic image processing method in this embodiment, intelligent adjustment of the dynamic image size can be achieved. For example, when the camera lens shifts during video shooting, the video can be re-edited by this method to obtain a satisfactory effect.
[0162] <Embodiment Four>
[0163] This embodiment provides a picture processing method, which can be implemented by Figure 1 the terminal device 100 therein. As Figure 6 shown, the picture processing method of this embodiment may include the following steps S6100 and S6200:
[0164] Step S6100, obtain the picture to be processed and the target editing size of the picture.
[0165] In one example, obtaining the picture to be processed in this step S6100 may be obtaining the picture uploaded by the user, and further identifying the original size of the picture.
[0166] In one example, obtaining the picture to be processed in this step S6100 may also be obtaining the URL address corresponding to the object storage of the picture to be processed, so as to obtain the picture according to the URL address, and further request the object storage server to provide the original size of the picture according to the URL address.
[0167] Step S6200, start the editing module to process the picture according to the target editing size, and obtain and output the processing result.
[0168] The editing module may be an editing toolkit, and the editing toolkit may be, for example, a Software Development Kit (SDK).
[0169] In this embodiment, the editing module processes the picture according to the target editing size, which may include: obtaining a proportionality coefficient representing the size change according to the original size of the picture and the target editing size of the picture; obtaining the original upper left starting coordinate for editing the picture according to the target editing size, and obtaining the final upper left starting coordinate for editing the picture according to the proportionality coefficient and the upper left starting coordinate; and processing the picture according to the final upper left starting coordinate and the target editing size.
[0170] For the implementation of each step of processing the picture by the above editing module according to the target editing size, reference can be made to the corresponding parts of Embodiment 1 and / or Embodiment 2, which will not be elaborated here.
[0171] In one embodiment, obtaining the target editing size of the picture in step S6100 may include: obtaining multiple target editing sizes of the picture. In this embodiment, the method according to the embodiments of the present invention can be used to process the picture with multiple different target editing sizes, realizing batch editing of the picture, avoiding manual processing of each picture according to multiple different target editing sizes, effectively improving the processing efficiency, and improving the processing accuracy.
[0172] In one embodiment, when multiple target editing sizes are obtained in step S6100, starting the editing module to process the picture according to the target editing size in the above step S6200 may include: starting the editing module to process the picture for each target editing size in parallel. According to this embodiment, the response speed of picture processing can be further improved. Of course, in other embodiments, it may also be to start the editing module to process the picture for each target editing size sequentially, which is not limited here.
[0173] <Embodiment 5>
[0174] This embodiment provides an image processing apparatus, which is, for example, Figure 7 the image processing apparatus 700 shown in the figure. The apparatus includes a scale factor acquisition module 710, a starting point coordinate acquisition module 720, and a processing module 730.
[0175] The scale factor acquisition module 710 is configured to obtain a scale factor representing the size change according to the original size of the picture and the target editing size of the picture.
[0176] The starting point coordinate acquisition module 720 is configured to obtain the original upper left starting point coordinate for editing the picture according to the target editing size, and obtain the final upper left starting point coordinate for editing the picture according to the scale factor and the upper left starting point coordinate.
[0177] The processing module 730 is configured to process the picture according to the final upper left starting point coordinate and the target editing size, and obtain and output a processing result.
[0178] In a specific example of this embodiment, the starting point coordinate acquisition module 720 may further be configured to: send the picture and the target editing size to the smartcrop.js plugin; call the smartcrop.js plugin to perform an operation of determining the original upper left starting point coordinate for editing the picture according to the target editing size; and obtain the original upper left starting point coordinate returned by the smartcrop.js plugin after performing the operation.
[0179] In a specific example of this embodiment, the image processing device 700 may further include an interaction module. The interaction module may be configured to provide an input entry for inputting a target editing size in response to an operation of inputting the target editing size; and obtain the target editing size input through the input entry.
[0180] In a specific example of this embodiment, the interaction module may further be configured to: provide an input entry that supports inputting multiple target editing sizes.
[0181] In a specific example of this embodiment, the interaction module may further be configured to: provide an upload entry for uploading picture information in response to a request for picture information of an uploaded picture; obtain the picture information uploaded through the upload entry; and obtain the original size of the picture according to the picture information.
[0182] In a specific example of this embodiment, the picture information is the URL address of the picture corresponding to object storage. The interaction module may further be configured to: request the object storage server to provide the original size of the picture according to the URL address of the picture; and obtain the original size of the picture returned by the object storage server according to the request.
[0183] In a specific example of this embodiment, the interaction module may further be configured to: provide an input entry for inputting a correction coefficient of the final upper left starting coordinate in response to an operation of setting the final upper left starting coordinate; and obtain the correction coefficient input through the input entry. So that the starting coordinate acquisition module 720 may further be configured to: obtain the final upper left starting coordinate according to the scale factor, the upper left starting coordinate, and the correction coefficient.
[0184] In a specific example of this embodiment, the processing module 730 may further be configured to: start from the final upper left starting coordinate, respectively crop to the edges of the picture horizontally and vertically to obtain a cropped picture; and scale the cropped picture to the target editing size.
[0185] In a specific example of this embodiment, the processing module 730 may further be configured to: scale the cropped picture by an equal ratio scaling method according to the target editing size to obtain a scaled picture, where the size of the scaled picture in at least one of the horizontal and vertical directions is equal to the size of the target editing size in the corresponding direction, and the area of the scaled picture is not less than the area corresponding to the target editing size; and crop the scaled picture centered according to the target editing size.
[0186] In a specific example of this embodiment, the processing module 730 may further be configured to: obtain a processing solution for processing the picture according to the final top-left starting coordinate and the target editing size; generate a processing instruction for executing the processing solution through the object storage server; and use the processing instruction as a parameter carried by the URL address corresponding to the object storage of the picture, and generate a parameter-carrying URL address instructing the object storage server to process the picture according to the processing solution.
[0187] In a specific example of this embodiment, the processing module 730 may further be configured to: start the object storage server to process the picture according to the parameter-carrying URL address; and obtain the processed picture returned by the object storage server.
[0188] <Embodiment Six>
[0189] This embodiment provides an image processing apparatus, which may include an interaction module, a calling module, and an editing module.
[0190] The interaction module is configured to obtain the picture to be processed and the target editing size of the picture.
[0191] In one example, the interaction module may be configured to obtain the picture to be processed by obtaining a picture uploaded by the user, and further identify the original size of the picture.
[0192] In one example, the interaction module may also be configured to obtain the URL address corresponding to the object storage of the picture to be processed, so as to obtain the picture according to the URL address, and further request the object storage server to provide the original size of the picture according to the URL address.
[0193] The calling module is configured to start the editing module to process the picture according to the target editing size, obtain and output the processing result.
[0194] The editing module may be an editing toolkit, and the editing toolkit may be, for example, a Software Development Kit (SDK).
[0195] In this embodiment, the editing module processes the picture according to the target editing size, which may include: obtaining a scale factor representing the size change according to the original size of the picture and the target editing size of the picture; obtaining the original top-left starting coordinate for editing the picture according to the target editing size, and obtaining the final top-left starting coordinate for editing the picture according to the scale factor and the top-left starting coordinate; and processing the picture according to the final top-left starting coordinate and the target editing size.
[0196] In this embodiment, the editing module may include, for example, the proportional coefficient acquisition module 710, the starting point coordinate acquisition module 720, and the processing module 730 in Embodiment 4.
[0197] For the implementation of the above steps of the editing module for processing the picture according to the target editing size, reference can be made to the corresponding parts of Embodiment 1 and / or Embodiment 2, which will not be elaborated here.
[0198] In one embodiment, the interaction module can be used to obtain multiple target editing sizes of the picture.
[0199] In one embodiment, the calling module can be used to: start the editing module to process the picture in parallel for each target editing size.
[0200] <Embodiment 7>
[0201] This embodiment provides a picture processing device, which includes a picture acquisition module, a proportional coefficient acquisition module, a starting point coordinate acquisition module, a processing module, and a synthesis module.
[0202] The picture acquisition module is used to acquire static pictures that make up the dynamic video.
[0203] The proportional coefficient acquisition module is used to obtain a proportional coefficient representing the size change according to the original size of the dynamic image and the target editing size of the dynamic image.
[0204] The starting point coordinate acquisition module is used to obtain the original upper left starting point coordinate for editing the static picture according to the target editing size, and obtain the final upper left starting point coordinate for editing the static picture according to the proportional coefficient and the upper left starting point coordinate.
[0205] The processing module is used to process the static picture according to the final upper left starting point coordinate and the target editing size.
[0206] The synthesis module is used to connect the processed static pictures in sequence to obtain the edited dynamic video.
[0207] <Embodiment 8>
[0208] This embodiment provides an electronic device, which may include the picture processing device in any one of Embodiments 5, 6, and 7.
[0209] In another embodiment, the electronic device may also be Figure 8 the electronic device 800 shown in the figure. The electronic device 800 includes a memory 810 and a processor 820. The memory 810 is used to store executable commands. The processor 820 is used to execute the picture processing method provided in any one of Embodiments 1 to 4 under the control of the executable commands stored in the memory 810.
[0210] The electronic device may be a terminal device, such as the terminal device 100 in Figure 1 .
[0211] <Example Nine>
[0212] This embodiment provides a computer-readable storage medium storing executable commands. When the executable commands are executed by a processor, any one of the picture processing methods in Embodiments One to Four is executed.
[0213] The present invention may be a system, a method, and / or a computer program product. The computer program product may include a computer-readable storage medium having thereon computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0214] A computer-readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punch card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing. The computer-readable storage medium as used herein is not construed as an instantaneous signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated through a waveguide or other transmission medium (e.g., an optical pulse through an optical fiber cable), or an electrical signal transmitted through a wire.
[0215] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to various computing / processing devices, or downloaded to an external computer or external storage device through a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include a copper transmission cable, an optical fiber transmission, a wireless transmission, a router, a firewall, a switch, a gateway computer, and / or an edge server. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing / processing device.
[0216] The computer program instructions for carrying out the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state-setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider). In some embodiments, by using the state information of the computer-readable program instructions to customize an electronic circuit, such as a programmable logic circuit, a field-programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute the computer-readable program instructions to implement various aspects of the present invention.
[0217] Aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0218] These computer-readable program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, when executed by the processor of the computer or other programmable data processing apparatus, create a means for implementing the functions / acts specified in one or more blocks of the flowchart illustrations and / or block diagrams. These computer-readable program instructions may also be stored in a computer-readable storage medium, which instructions cause a computer, a programmable data processing apparatus, and / or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises a manufacture, including instructions for implementing various aspects of the functions / acts specified in one or more blocks of the flowchart illustrations and / or block diagrams.
[0219] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, causing a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process such that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in one or more boxes of the flowchart and / or block diagram.
[0220] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a segment of code, or a portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two consecutive blocks may in fact be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or by combinations of special purpose hardware and computer instructions. As will be apparent to those of ordinary skill in the art, implementations using hardware, software, or a combination of software and hardware are all equivalent.
[0221] The embodiments of the present invention have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the market, or to enable other ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. An image processing method, comprising: Obtaining a scale factor representing the size change according to the original size of the image and the target editing size of the image; wherein, the scale factor includes a horizontal scale factor and a vertical scale factor, the vertical scale factor is the ratio of the height in the target editing size to the height in the original size, and the horizontal scale factor is the ratio of the width in the target editing size to the width in the original size; Obtaining the original top - left starting coordinate for editing the image according to the target editing size, and obtaining the final top - left starting coordinate for editing the image according to the scale factor and the top - left starting coordinate; wherein, the original top - left starting coordinate and the final top - left starting coordinate are calculated in a coordinate system with the top - left corner of the image as the origin, the positive direction to the right horizontally and the positive direction down vertically. The original top - left starting coordinate is the top - left coordinate of the editing area determined according to the main content of the image and the target editing size. The main content of the image is determined by performing image recognition on the image. The abscissa in the final top - left starting coordinate is obtained by multiplying the horizontal scale factor by the abscissa in the original top - left starting coordinate, and the ordinate in the final top - left starting coordinate is obtained by multiplying the vertical scale factor by the ordinate in the original top - left starting coordinate; Processing the image according to the final top - left starting coordinate and the target editing size, and obtaining and outputting a processing result; The processing the image according to the final top - left starting coordinate and the target editing size includes: Starting from the final top - left starting coordinate, cropping to the edges of the image horizontally and vertically respectively to obtain a cropped image; Scaling the cropped image to the target editing size.
2. The method according to claim 1, wherein The obtaining the original top - left starting coordinate for editing the image according to the target editing size includes: Sending the image and the target editing size to the smartcrop.js plugin; Invoking the smartcrop.js plugin to perform an operation of determining the original top - left starting coordinate for editing the image according to the target editing size; Obtaining the original top - left starting coordinate returned by the smartcrop.js plugin after performing the operation.
3. The method according to claim 1, wherein, Before the method obtains the scale factor for scaling the image according to the original size of the image and the target editing size of the image, it further includes: Responding to an operation of inputting the target editing size, providing an input entry for inputting the target editing size; Obtaining the target editing size input through the input entry.
4. The method according to claim 3, wherein The providing an input entry for inputting the target editing size includes: Providing an input entry that supports inputting multiple target editing sizes.
5. The method according to claim 1, wherein Before obtaining a scale factor for scaling the picture according to the original size and the target editing size of the picture, the method further includes: In response to a request for uploading picture information of the picture, providing an upload entry for uploading the picture information; Obtaining the picture information uploaded through the upload entry; Obtaining the original size of the picture according to the picture information; 6. The method according to claim 5, wherein The picture information is a URL address corresponding to the object storage of the picture; The obtaining the original size of the picture according to the picture information includes: Requesting the object storage server to provide the original size of the picture according to the URL address of the picture; Obtaining the original size of the picture returned by the object storage server according to the request; 7. The method according to claim 1, wherein The scaling the cropped picture to the target editing size includes: Scaling the cropped picture in a way of equal ratio scaling according to the target editing size to obtain a scaled picture, wherein the size of the scaled picture in at least one of the horizontal and vertical directions is equal to the size of the target editing size in the corresponding direction, and the area of the scaled picture is not less than the area corresponding to the target editing size; Centrally cropping the scaled picture according to the target editing size to scale the cropped picture to the target editing size; 8. The method according to claim 1, wherein, Before obtaining the final upper left starting coordinate for editing the picture according to the scale factor and the upper left starting coordinate, the method further includes: In response to an operation of setting the final upper left starting coordinate, providing an input entry for inputting a correction factor of the final upper left starting coordinate; Obtaining the correction factor input through the input entry; The obtaining the final upper left starting coordinate for editing the picture according to the scale factor and the upper left starting coordinate includes: Obtaining the final upper left starting coordinate according to the scale factor, the upper left starting coordinate and the correction factor; 9. The method according to any one of claims 1 to 8, wherein The processing the picture according to the final upper left starting coordinate and the target editing size includes: Obtaining a processing scheme for processing the picture according to the final upper left starting coordinate and the target editing size; Generating a processing instruction for executing the processing scheme by the object storage server; Taking the processing instruction as a parameter carried by the URL address corresponding to the object storage of the picture, and generating a parameterized URL address instructing the object storage server to process the picture according to the processing scheme, so as to process the picture through the parameterized URL address; 10. The method according to claim 9, wherein, The processing the picture according to the final upper left starting coordinate and the target editing size further includes: Starting the object storage server to process the picture according to the processing scheme according to the parameterized URL address; Obtaining the processed picture returned by the object storage server as the processing result; 11. A picture processing method, including: Obtaining a picture to be processed and the target editing size of the picture; The startup editing module processes the picture according to the target editing size, and obtains and outputs a processing result; Among them, the editing module processes the picture according to the target editing size, including: Obtaining a scale factor representing the size change according to the original size of the picture and the target editing size of the picture; wherein, the scale factor includes a horizontal scale factor and a vertical scale factor, the vertical scale factor is the ratio of the height in the target editing size to the height in the original size, and the horizontal scale factor is the ratio of the width in the target editing size to the width in the original size; Obtaining the original upper left starting coordinate for editing the picture according to the target editing size, and obtaining the final upper left starting coordinate for editing the picture according to the scale factor and the upper left starting coordinate; wherein, the original upper left starting coordinate and the final upper left starting coordinate are calculated in a coordinate system established with the upper left corner of the picture as the origin, the horizontal rightward direction as the positive direction, and the vertical downward direction as the positive direction, the original upper left starting coordinate is the upper left coordinate of the editing area determined according to the main content of the picture and the target editing size, the main content of the picture is determined by performing image recognition on the picture, the abscissa in the final upper left starting coordinate is obtained by multiplying the horizontal scale factor by the abscissa in the original upper left starting coordinate, and the ordinate in the final upper left starting coordinate is obtained by multiplying the vertical scale factor by the ordinate in the original upper left starting coordinate; Processing the picture according to the final upper left starting coordinate and the target editing size; The processing the picture according to the final upper left starting coordinate and the target editing size includes: Starting from the final upper left starting coordinate, cropping to the edge of the picture along the horizontal and vertical directions respectively to obtain a cropped picture; Scaling the cropped picture to the target editing size.
12. The method according to claim 11, wherein, Obtaining the target editing size of the picture includes: obtaining multiple target editing sizes of the picture.
13. The method according to claim 12, wherein The startup editing module processes the picture according to the target editing size, including: The startup editing module processes the picture for each target editing size in parallel.
14. A dynamic image processing method, including: Obtaining static pictures constituting the dynamic image; Obtaining a scale factor representing the size change according to the original size of the static picture and the target editing size of the static picture; wherein, the scale factor includes a horizontal scale factor and a vertical scale factor, the vertical scale factor is the ratio of the height in the target editing size to the height in the original size, and the horizontal scale factor is the ratio of the width in the target editing size to the width in the original size; According to the target editing size, obtain the original upper-left starting coordinate for editing the static picture, and according to the scale factor and the upper-left starting coordinate, obtain the final upper-left starting coordinate for editing the static picture; wherein, the original upper-left starting coordinate and the final upper-left starting coordinate are calculated in a coordinate system established with the upper-left corner of the static picture as the origin, the horizontal rightward direction as the positive direction, and the vertical downward direction as the positive direction. The original upper-left starting coordinate is the upper-left coordinate of the editing area determined according to the main content of the static picture and the target editing size. The main content of the static picture is determined by performing image recognition on the static picture. The abscissa in the final upper-left starting coordinate is obtained by multiplying the horizontal scale factor by the abscissa in the original upper-left starting coordinate, and the ordinate in the final upper-left starting coordinate is obtained by multiplying the vertical scale factor by the ordinate in the original upper-left starting coordinate; Process the static picture according to the final upper-left starting coordinate and the target editing size; Connect the processed static pictures in sequence to obtain an edited dynamic image; The processing the static picture according to the final upper-left starting coordinate and the target editing size includes: Starting from the final upper-left starting coordinate, crop to the edge of the static picture along the horizontal and vertical directions respectively to obtain a cropped static picture; Scale the cropped static picture to the target editing size.
15. A picture processing device, comprising: A scale factor acquisition module, configured to obtain a scale factor representing size change according to the original size of the picture and the target editing size of the picture; wherein, the scale factor includes a horizontal scale factor and a vertical scale factor. The vertical scale factor is the ratio of the height in the target editing size to the height in the original size, and the horizontal scale factor is the ratio of the width in the target editing size to the width in the original size; A starting point coordinate acquisition module, configured to obtain the original upper left starting point coordinate for editing the picture according to the target editing size, and obtain the final upper left starting point coordinate for editing the picture according to the scale factor and the upper left starting point coordinate; wherein, the original upper left starting point coordinate and the final upper left starting point coordinate are calculated in a coordinate system established with the upper left corner of the picture as the origin, the horizontal rightward direction as the positive direction, and the vertical downward direction as the positive direction. The original upper left starting point coordinate is the upper left corner coordinate of the editing area determined according to the main content of the picture and the target editing size. The main content of the picture is determined by performing image recognition on the picture. The abscissa in the final upper left starting point coordinate is obtained by multiplying the horizontal scale factor by the abscissa in the original upper left starting point coordinate, and the ordinate in the final upper left starting point coordinate is obtained by multiplying the vertical scale factor by the ordinate in the original upper left starting point coordinate; A processing module, configured to process the picture according to the final upper left starting point coordinate and the target editing size, and obtain and output a processing result; Specifically, the processing module is configured to use the final upper left starting point coordinate as a starting point, and respectively crop to the edges of the picture along the horizontal and vertical directions to obtain a cropped picture; and scale the cropped picture to the target editing size.
16. An electronic device, comprising the device as described in claim 15; Alternatively, the electronic device includes: A memory, configured to store executable commands; A processor, configured to execute the method according to any one of claims 1-14 under the control of the executable commands.
17. A computer-readable storage medium storing executable instructions, which when executed by a processor, execute the method according to any one of claims 1-14.
Citation Information
Patent Citations
Picture processing method and system and related devices
CN106157239A