WO2021121162A1 - 一种图片处理方法、装置、电子设备及存储介质 - Google Patents

一种图片处理方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2021121162A1
WO2021121162A1 PCT/CN2020/135761 CN2020135761W WO2021121162A1 WO 2021121162 A1 WO2021121162 A1 WO 2021121162A1 CN 2020135761 W CN2020135761 W CN 2020135761W WO 2021121162 A1 WO2021121162 A1 WO 2021121162A1
Authority
WO
WIPO (PCT)
Prior art keywords
picture
pictures
template
grid
predetermined number
Prior art date
Application number
PCT/CN2020/135761
Other languages
English (en)
French (fr)
Inventor
张韵叠
胡靓
Original Assignee
荣耀终端有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 荣耀终端有限公司 filed Critical 荣耀终端有限公司
Priority to EP20902823.2A priority Critical patent/EP4040376B1/en
Publication of WO2021121162A1 publication Critical patent/WO2021121162A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4038Image mosaicing, e.g. composing plane images from plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/54Browsing; Visualisation therefor

Definitions

  • This application relates to the field of computers, and in particular to an image processing method, device, electronic equipment, and storage medium.
  • the photos are stitched together as a picture display.
  • the user needs to manually select the appropriate puzzle template according to the number of pictures, and fill in the grids of the puzzle template in the order in which the user selects the pictures to complete the puzzle.
  • the number puzzle template when each grid in the puzzle template is loaded into the picture selected by the user, it is loaded correspondingly in the order in which the user selects the picture. If the size of the grid in the puzzle template is the same as Corresponding to the large difference in the size of the loaded pictures, it will cause the pictures to be over-cropped.
  • the embodiments of the present application provide a picture processing method, device, electronic device, and storage medium, which eliminates the need for a user to manually select a puzzle template, and avoids the problem of excessive cropping of pictures.
  • an embodiment of the present application provides a picture processing method.
  • the picture processing method includes: selecting a predetermined number of pictures; determining a first template set based on the predetermined number, and the first template set includes a plurality of users.
  • each template includes the predetermined number of picture grids for accommodating pictures; sorting the predetermined number of pictures based on a predetermined order describing the size ratio of the picture size;
  • For each of the templates in the first template set sort the predetermined number of picture grids based on the predetermined order describing the size ratio of the picture grids; for each of the first template set Calculating the cropping amount of each of the templates, the cropping amount of the template is the sum of the cropping amounts required for correspondingly loading each picture into the same picture grid in the predetermined order according to the predetermined order; From the first template set, the template with the smallest cropping amount is selected as the target template for the predetermined number of pictures.
  • a picture processing method disclosed in an embodiment of the present application, after a user selects a predetermined number of pictures, based on the predetermined number of pictures, correspondingly select templates with the same number of picture grids for accommodating the pictures as the predetermined number, and each template constitutes the first A collection of templates.
  • the specific template to be selected as the target template can be determined based on the picture grid of the template corresponding to the total cropping amount after the picture is loaded. Specifically, the pictures are determined in a predetermined order that describes the size ratio of the picture.
  • Sort sort the picture grids in each template in the same predetermined order according to the size ratio describing the size of the picture grid, load the pictures into the corresponding picture grids of each template in the same predetermined order, and accumulate the various pictures of the template Relative to the total cropping amount of the loaded picture, each template corresponds to a total cropping amount, and the template with the smallest cropping amount is selected as the target template.
  • the template with the smallest cropping amount is selected as the target template.
  • sorting the predetermined number of pictures includes: sorting each of the pictures in a predetermined order of the aspect ratio of each of the pictures.
  • the size ratio based on describing the size of the picture can include the aspect ratio of the picture or the aspect ratio of the picture.
  • the aspect ratio of the picture refers to the ratio of the height to the width of the picture
  • the aspect ratio of the picture refers to the width and the width of the picture.
  • the size ratio of the picture may also be the ratio of the width of the picture to the length of the diagonal of the picture or the ratio of the height of the picture to the length of the diagonal of the picture.
  • the shape of the picture grid may be rectangular or non-rectangular.
  • sorting the predetermined number of picture grids includes: according to the horizontal and vertical dimensions of each of the picture grids.
  • Each of the picture grids is sorted in a predetermined order of comparison.
  • the size ratio based on describing the size of the picture grid can include the aspect ratio of the picture grid or the aspect ratio of the picture grid.
  • the aspect ratio of the picture grid refers to the ratio of the height to the width of the picture grid
  • the aspect ratio of the picture grid refers to the ratio of the height to the width of the picture grid. Is the ratio of the width to the height of the picture grid.
  • the size ratio of the picture grid may also be the ratio of the width of the picture grid to the length of the diagonal of the picture grid or the ratio of the height of the picture grid to the length of the diagonal of the picture grid. It is worth noting that when sorting, the size ratio of the picture and the size ratio of the picture grid should be consistent. For example, when the size ratio of the picture is the aspect ratio, the size ratio of the picture grid should also be horizontal and vertical when sorting. Ratio to ensure the accuracy of matching between the picture and the corresponding picture grid.
  • the aspect ratio of the circumscribed rectangle of the picture grid can be predetermined Order to sort each picture grid.
  • the aspect ratio of the circumscribed rectangle is the ratio of the minor axis to the major axis of the ellipse.
  • the aspect ratio of the circumscribed rectangle is the ratio of the diameter of the circle. .
  • the picture grid when the picture grid is non-rectangular, it refers to the non-rectangular picture grid with a two-dimensional shape in the two-dimensional coordinates, and the maximum abscissa, minimum abscissa, maximum ordinate and minimum of the non-rectangular picture grid
  • the boundary defined by the ordinate is the circumscribed rectangle.
  • the predetermined order of the predetermined number of pictures and the aspect ratio of the picture grids in each template is sorted, which may be in descending order according to the value of the aspect ratio of the predetermined number of pictures
  • the arrangement may also be arranged in ascending order according to the value of the aspect ratio of a predetermined number of pictures.
  • the aspect ratio of the picture includes the ratio of the width to the height of the picture
  • the aspect ratio of the picture grid includes the ratio of the width to the height of the picture grid, and the width and the height are in centimeters.
  • all the selected pictures may have target pictures with the same size ratio describing the picture size.
  • the selection order means that the user selects pictures in order
  • the rest of the target pictures can be postponed sequentially according to the predetermined order of the picture grid to ensure that a predetermined number of pictures are loaded into each picture grid with the smallest amount of cropping.
  • each target template is used to form a second template set, and one with the highest priority is selected from the second template set according to a preset priority.
  • the target template serves as the final target template for the predetermined number of pictures.
  • the preset priority can be customized by the user, that is, the user customizes and selects the target template as the target template with higher priority according to their own use needs, which improves the user experience, or it can be offline.
  • the basic target template used is set to a higher priority template, and the template that can only be used for online download is set to a template with a lower priority than the basic target template.
  • the normalization method is used to calculate the cropping amount of the template, that is, the cropping amount of the picture grid and the corresponding loaded picture is reflected in the form of percentage, and the value of the cropping amount of the picture grid and the corresponding loaded picture is normalized to Within the range of (0,1), wherein the cutting amount of the calculation template is calculated using the following formula:
  • C k is the total cropping amount of the k-th template
  • C ki is the cropping amount of the i-th picture loaded in the i-th picture grid of the k-th template
  • r i is the size describing the i-th picture
  • the size ratio of r ki is the size ratio of the i-th picture grid into the i-th picture describing the k-th template.
  • the corresponding pictures of each picture are loaded into a picture grid with the same predetermined order according to a predetermined order, and the puzzle processing of each picture is completed.
  • the aspect ratio of the first picture is 3/4
  • the aspect ratio of the second picture is 1/2
  • the aspect ratio of the third picture is 1/3.
  • the pictures are arranged in descending order, in order: the first picture ⁇ the second picture ⁇ the third picture; the number of picture grids of the selected target template corresponds to 3, and the aspect ratio of the first picture grid is 5 /12, the aspect ratio of the second picture grid is 5/6, and the aspect ratio of the third picture grid is 7/12.
  • the cropping amount calculation formula is applied, and the total cropping amount for the above 3 pictures is That is, the total cropping amount of 3 pictures is 44.3%. It is worth noting that if the size ratio of the picture and the picture grid is the same, it means that the picture and the picture grid coincide or the picture can be enlarged or reduced in proportion to make the picture and the picture grid coincide, so that the picture with the same size ratio as the picture grid is loaded into the picture The grid may not be cropped, that is, the cropping amount is zero.
  • an embodiment of the present application discloses a picture processing device, including:
  • the selection module is used to select a predetermined number of pictures
  • the determining module is configured to determine a first template set based on the predetermined number, the first template set includes a plurality of templates for the predetermined number of pictures, and each template includes the predetermined number of templates for accommodating the pictures.
  • the first sorting module is configured to sort the predetermined number of pictures based on a predetermined order describing the size ratio of the picture sizes;
  • a second sorting module configured to sort the predetermined number of picture grids based on the predetermined order describing the size ratio of the picture grid size for each of the templates in the first template set;
  • the calculation module is configured to calculate the cropping amount of each template for each of the templates in the first template set, and the cropping amount of the template is to load each picture correspondingly according to the predetermined order The total amount of cropping required in the same picture grid in the predetermined order;
  • the selection module is configured to select the template with the smallest cropping amount from the first template set as the target template for the predetermined number of pictures.
  • the first sorting module includes:
  • the first sorting unit is configured to sort each of the pictures according to a predetermined order of the aspect ratio of each of the pictures.
  • the second sorting module includes:
  • the second sorting unit is configured to sort the picture grids according to a predetermined order of the aspect ratio of each of the picture grids.
  • the second sorting module includes:
  • the third sorting unit is configured to sort the picture grids according to a predetermined order of the aspect ratio of the circumscribed rectangle of the picture grid.
  • an embodiment of the present application discloses an electronic device, and the electronic device includes:
  • Memory used to store processing programs
  • a processor which implements the steps of any one of the above-mentioned image processing methods when the processor executes the processing program.
  • an embodiment of the present application discloses a computer-readable storage medium with a processing program stored on the computer-readable storage medium, and when the processor executes the processing program, the image processing as described in any of the above is realized Method steps.
  • Figures 1(a) to 1(c) are schematic diagrams of a prior art picture puzzle disclosed in an embodiment of the application;
  • FIG. 2 is a schematic flowchart of a picture processing method disclosed in an embodiment of the application.
  • Fig. 3(a) is a schematic diagram of the layout of a set of puzzle templates disclosed in an embodiment of the application;
  • Figure 3(b) is a schematic diagram of an aesthetic spiral layout disclosed in an embodiment of the application.
  • Fig. 4(a) is a schematic flowchart of a method for allocating picture frames to a target picture disclosed in an embodiment of the application;
  • FIG. 4(b) is a schematic flowchart of a method for sorting picture grids disclosed in an embodiment of the application;
  • Fig. 4(c) is a schematic diagram of a circumscribed rectangle of a picture grid disclosed in an embodiment of the application;
  • FIG. 4(d) is a schematic flowchart of a method for calculating the trimming amount of a template disclosed in an embodiment of the application;
  • Figure 4(e) is a schematic flow diagram of a method for selecting an optimal target template disclosed in an embodiment of this application
  • Figure 5 (a) is a schematic diagram of loading a picture grid in the target template disclosed in an embodiment of the application with pictures in the same predetermined order as a picture grid;
  • Fig. 5(b) is a schematic diagram of position adjustment when the picture disclosed in the embodiment of the application is loaded into the picture grid;
  • 5(c) to 5(e) are schematic diagrams of puzzles using a picture processing method disclosed in an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a picture processing device disclosed in an embodiment of the application.
  • FIG. 7 is a schematic structural diagram of an electronic device disclosed in an embodiment of the application.
  • FIG. 8 is a schematic structural diagram of a SOC disclosed in an embodiment of the application.
  • module can refer to or include an application specific integrated circuit (ASIC), an electronic circuit, a processor (shared, dedicated, or group) that executes one or more software or firmware programs, and /Or memory, combinational logic circuits, and/or other suitable hardware components that provide the described functions, or may be part of these hardware components.
  • ASIC application specific integrated circuit
  • processor shared, dedicated, or group
  • processor shared, dedicated, or group
  • combinational logic circuits and/or other suitable hardware components that provide the described functions, or may be part of these hardware components.
  • the processor may be a microprocessor, a digital signal processor, a microcontroller, etc., and/or any combination thereof.
  • the processor may be a single-core processor, a multi-core processor, etc., and/or any combination thereof.
  • the user is required to manually select the appropriate puzzle template according to the number of pictures (that is, the number of pictures corresponding to the selection).
  • the number of picture grids is the same as the number of pictures in the puzzle template), and fill in the grids (picture grids) of the puzzle template in the order in which the user selects the pictures to complete the puzzle.
  • the user manually selects the puzzle template , When each grid in the puzzle template is loaded into the picture selected by the user, it is correspondingly loaded in the order in which the user selects the picture. If the size of the grid in the puzzle template is different from the size of the corresponding loaded picture, then Will cause the picture to be excessively cropped.
  • Figure 1 (a) is a schematic diagram of a puzzle disclosed in the embodiment of the application, a total of 8 pictures .
  • the part of the sample picture in the sample picture grid is kept, and the parts outside the sample picture grid are all cropped.
  • the picture labeled 1 and The picture marked 4 is over-cropped, and the cropping amount exceeds 40%. It is easy to lose important information of the sample picture. If the sample picture is a selfie image of a face that contains a human face, and the face area happens to be in the sample picture grid, according to this cropping method, it is easy to cause a big face problem and affect the user experience.
  • Figure 1(c) contains 4 pictures.
  • the sample template selected by the user is a template with 4 picture grids.
  • the label is 1 and the label is 4
  • the picture of was also excessively cropped, and important information of the pictures labeled 1 and 4 was lost. It can be understood that the pictures labeled 1 and 4 in Figs. 1(c), 1(b) and 1(a) are the same pictures.
  • the embodiments of the present application provide a picture processing method, device, electronic device, and storage medium, which eliminates the need for a user to manually select a puzzle template, and avoids the problem of excessive cropping of pictures.
  • FIG. 2 is a schematic flowchart of an image processing method disclosed in an embodiment of the application.
  • the image processing method shown in FIG. 2 includes:
  • S20 Select N pictures to form a jigsaw grid or a jigsaw pattern based on the deformation of the nine squares grid.
  • N may be an integer.
  • N is 8 as an example for description.
  • These 8 pictures are selected by the user from multiple pictures in the gallery in the mobile phone. That is, the photos that need to be puzzled are selected by the user.
  • 8 pictures are taken as the predetermined number of pictures, and the predetermined number may also be other values, which is not limited in the embodiment of the present application.
  • S21 Determine the first template set based on the selected N pictures, the first template set includes multiple, and the number of picture grids of the templates in each template set is also N, that is, the number of pictures is the same as the number of picture grids. For example, there are 8 templates for 8 pictures, and each template includes 8 picture grids for holding 8 pictures.
  • the puzzle template can be adjusted based on the spiral layout principle in the aesthetic layout. The position and size of the picture grid for layout.
  • Figure 3(a) is a schematic diagram of the layout of a set of puzzle templates disclosed in an embodiment of the application, in which, starting from the picture grid in the center, along the counterclockwise direction, each picture grid is presented Spiral uneven layout
  • Figure 3(b) is a schematic diagram of a spiral layout disclosed in an embodiment of the application
  • Figure 3(a) is based on Figure 3( b)
  • the spiral layout shown in the picture grid is not evenly divided, because the sizes of the selected pictures to be puzzled are different from each other. If the picture grid is laid out evenly, it is very It is easy to cause the picture to be puzzled to be over-cut.
  • S22 Arrange the N pictures in descending order based on the size ratio describing the size of the pictures.
  • the size ratio describing the size of the picture can be the aspect ratio of the picture (the ratio of height to width), the aspect ratio of the picture (the ratio of width to height), the width of the picture and the diagonal of the picture.
  • Each picture can be arranged in descending order of size ratio or in ascending order of size ratio, that is, the 8 pictures can be sorted in descending order or ascending order as a predetermined order.
  • the width and height of the picture it can be in centimeters or pixels.
  • sorting the 8 picture grids includes: sorting the picture grids in descending order according to the aspect ratio of each of the picture grids.
  • the size ratio based on describing the size of the picture grid can include the aspect ratio of the picture grid or the aspect ratio of the picture grid.
  • the aspect ratio of the picture grid refers to the ratio of the height to the width of the picture grid
  • the aspect ratio of the picture grid refers to the ratio of the height to the width of the picture grid. Is the ratio of the width to the height of the picture grid.
  • the size ratio of the picture grid may also be the ratio of the width of the picture grid to the length of the diagonal of the picture grid or the ratio of the height of the picture grid to the length of the diagonal of the picture grid.
  • the size ratio of the picture and the size ratio of the picture grid should be consistent.
  • the size ratio of the picture is the aspect ratio
  • the size ratio of the picture grid should also be horizontal and vertical when sorting. Ratio to ensure the accuracy of matching between the picture and the corresponding picture grid.
  • the shape of the picture grid may be rectangular or non-rectangular.
  • the picture grid is non-rectangular, such as ellipse, circle, pentagon, etc.
  • the 8 pictures selected by the user there may be target pictures with the same size ratio describing the picture sizes.
  • the 8 pictures are arranged in descending order, and the 8 pictures in the template Grids are sorted in descending order.
  • the 8 pictures there are two target pictures with the same size ratio and a sort number of 5.
  • the two target pictures with a sort number of 5 correspond to the 8 picture grids with a sort number of 5 only One, in order to allocate the picture grid to two target pictures while ensuring that the user experience is not degraded, an embodiment of the present application provides a method for allocating picture grids to a target picture.
  • Figure 4(a) is a schematic flowchart of a method for allocating picture frames to a target picture disclosed in an embodiment of the application, and the method includes:
  • S40 Select N pictures to form a jigsaw grid or a jigsaw pattern based on the deformation of the nine grids.
  • N may be an integer. In the embodiment of the present application, N is 8 as an example for description.
  • S41 Determine a first template set based on the selected N pictures, the first template set includes multiple, and the number of picture grids of the templates in each template set is also N, that is, the number of pictures and the number of picture grids are the same. For example, there are 8 templates for 8 pictures, and each template includes 8 picture grids for holding 8 pictures.
  • S42 Arrange the N pictures in descending order based on the size of the aspect ratio describing the picture size.
  • S43 For each template in the first template set, arrange the N picture grids in descending order based on the shape of the picture grid and the aspect ratio describing the size of the picture grid.
  • the shape of the picture grid may be rectangular or non-rectangular.
  • the picture grid is non-rectangular, such as ellipse, circle, pentagon, etc.
  • the size ratio describing the size of the picture grids can be sorted by the method shown in Figure 4(b). Please refer to Figure 4(b).
  • Figure 4(b) is an example of this application.
  • a schematic flow chart of a method for sorting picture grids is disclosed, and the method includes:
  • S430 Determine whether the shape of the picture grid is rectangular, if yes, go to S431, if not, go to S432.
  • S431 Sort the picture grids according to the size of the aspect ratio of the picture grids.
  • the size ratio based on describing the size of the picture grid may include the aspect ratio of the picture grid or the aspect ratio of the picture grid.
  • the aspect ratio of the picture grid refers to the ratio of the height to the width of the picture grid.
  • the aspect ratio of the grid refers to the ratio of the width to the height of the picture grid.
  • the size ratio of the picture grid may also be the ratio of the width of the picture grid to the length of the diagonal of the picture grid or the ratio of the height of the picture grid to the length of the diagonal of the picture grid. It is worth noting that when sorting, the size ratio of the picture and the size ratio of the picture grid should be consistent. For example, when the size ratio of the picture is the aspect ratio, the size ratio of the picture grid should also be horizontal and vertical when sorting. Ratio to ensure the accuracy of matching between the picture and the corresponding picture grid.
  • S432 Sort the picture grids according to the size of the aspect ratio of the circumscribed rectangle of the picture grid.
  • the aspect ratio of the circumscribed rectangle is the ratio of the minor axis to the major axis of the ellipse.
  • the aspect ratio of the circumscribed rectangle is the ratio of the diameter of the circle.
  • the circumscribed rectangle when the picture grid is non-rectangular it refers to the non-rectangular picture grid with a two-dimensional shape in the two-dimensional coordinates, and the maximum abscissa, minimum abscissa, maximum ordinate and minimum of the non-rectangular picture grid The boundary defined by the ordinate is the circumscribed rectangle.
  • Figure 4(c) is a graphic of the circumscribed rectangle of the picture grid disclosed in an embodiment of the application.
  • Schematic diagram where the blackened frame shown in Figure 4(c) is the non-rectangular circumscribed rectangle shown in Figure 4(c), and the circumscribed rectangle is connected to its maximum abscissa and maximum ordinate in two-dimensional coordinates , The smallest abscissa and the smallest ordinate formed a rectangle.
  • the size ratio of the picture and the size ratio of the picture grid should be consistent.
  • the size ratio of the picture is the aspect ratio
  • the size ratio of the picture grid should also be horizontal and vertical when sorting.
  • the picture grids should also be arranged in the descending order of the size ratio.
  • S44 Determine whether there are target pictures with the same aspect ratio among the N pictures, if yes, go to S45, and if not, go to S46.
  • S45 There are two pictures with a sort number of 5, the two pictures with a sort number of 5 are used as target pictures, and the order in which the two target pictures are selected in the step of selecting N pictures is determined.
  • S47 Prioritizing the priority to the two target pictures with the priority of the selection order is the picture grid with the sort number 5 of the target picture with the first selection order and the target picture with the selection order first.
  • the remaining one target picture is allocated to the picture grid with the sort number 6, and the order of the picture grids for the remaining pictures is arranged in descending order, the arrangement number of the picture and the arrangement number of the picture grid are sequentially extended.
  • each picture is correspondingly loaded into the picture grids with the same arrangement number of the N picture grids arranged in the descending order.
  • the aspect ratio of the picture frame may be 1:2, 4:7, 2:3, 8:9, 1:1, 4:3, and so on.
  • the template cropping amount can be calculated by normalization, that is, the cropping amount of the picture grid and the corresponding loaded picture is reflected in the form of percentage, and the picture grid and the corresponding loaded picture are cropped
  • the value of the amount is normalized to the range of (0,1), and the cutting amount of the template can be calculated using the following calculation formula:
  • the number of picture grids satisfies the first set of puzzle templates of the n pictures ⁇ T 1 ,T 2 , whil,T k ⁇ , for the selected n pictures, arrange them in descending order according to the value of the aspect ratio of the pictures to form a picture set ⁇ r 1 ,r 2 , whil,r n ⁇ , correspondingly, for the template T k in the first template set, each picture grid in the template T k is arranged in descending order of the value of the aspect ratio to form a picture
  • step S48 the cropping amount is calculated using a predetermined formula.
  • FIG. 4(d) is a schematic flowchart of a method for calculating the cropping amount of a template disclosed in an embodiment of the application, and the method includes:
  • S480 Determine whether the aspect ratio of the size of the i-th picture is greater than the aspect ratio of the i-th picture grid of the k-th template loaded into the i-th picture. If it is greater than, then proceed to S481, and if the aspect ratio of the size of the i-th picture is smaller than the aspect ratio of the i-th picture frame loaded into the i-th picture of the k-th template, then go to S482.
  • the first template set is the total cutting amount of k templates in ⁇ T 1 , T 2 ,..., T k ⁇ , and the total cutting amount of k templates constitutes the set ⁇ C 1 ,C 2 , whil,C k ⁇ , and select the target template min ⁇ C 1 with the smallest total cutting amount from ⁇ C 1 ,C 2 , whil,C k ⁇ ,C 2 , whil,C k ⁇ .
  • FIG. 4(e) is a schematic flowchart of a method for selecting an optimal target template disclosed in an embodiment of the application, and the method includes:
  • S490 Determine whether there are multiple target templates corresponding to the minimum cutting amount, if yes, go to S491, and if not, go to S492.
  • S491 Use each target template to form a second template set, and use the basic template used offline as the template with the highest priority to select a target template with the highest priority from the second template set as the optimal one for 8 pictures Target template, and then enter S492.
  • the preset priority can be set based on the basic template used offline and the template used for online download.
  • the preset priority can be customized by the user, that is, the user can use it according to his own needs. Customize the selected target template as a higher priority target template, which improves the user experience. It can also be used to set the basic target template that can be used offline as a higher priority template, which can only be used for online download The template is set to a template with a lower priority than the basic target template.
  • each picture is correspondingly loaded into the picture grids with the same arrangement number of the N picture grids arranged in the descending order.
  • S24 For each template in the first template set, calculate the cropping amount of each template.
  • the cropping amount of the template is based on the arrangement number of the N pictures in descending order according to the aspect ratio. The sum of the amount of cropping required in the picture grids with the same arrangement number of the N picture grids arranged in descending order.
  • the amount of cropping for each template means that in each template, the 8 pictures are arranged in descending order and the 8 picture grids are arranged in descending order.
  • each picture is the sum of the area of the picture area outside the corresponding picture grid.
  • the position of each picture in the corresponding picture grid can be adjusted based on the biometric recognition technology and then cropped. It can be understood that the calculation of the cutting amount of each template can be performed by referring to the calculation method shown in Figure 4(d) above.
  • S25 From the first template set, a template with the smallest cropping amount is selected as a target template for N pictures.
  • the corresponding pictures of each picture are loaded into a picture grid with the same predetermined order according to a predetermined order, and the puzzle processing of each picture is completed.
  • the number of picture grids of each template in the first template set selected according to the 3 pictures is also 3, and the aspect ratio of the first picture is 3/4 ,
  • the aspect ratio of the second picture is 1/2, and the aspect ratio of the third picture is 1/3.
  • the 3 pictures Arrange the 3 pictures in descending order, in order: 1st picture ⁇ 2nd picture ⁇ 3 A picture; the number of picture grids of the selected target template corresponds to 3, the aspect ratio of the first picture grid is 5/12, the aspect ratio of the second picture grid is 5/6, and the third picture The aspect ratio of the grid is 7/12, and the 3 picture grids of the target template are arranged in descending order, the second picture grid ⁇ the third picture grid ⁇ the first picture grid. According to the predetermined order of arrangement, the first picture grid will be sorted.
  • the cropping amount calculation formula is applied, and the total cropping amount using 3 pictures as an example is That is, the total cropping amount of 3 pictures is 44.3%. It is worth noting that if the ratio of the size of the picture and the picture grid is the same, it means that the picture and the picture grid coincide or the picture can be enlarged or reduced in proportion to make the picture and the picture grid coincide, so that the picture with the same size ratio and the picture grid is loaded into the picture The grid may not be cropped, that is, the crop amount is zero.
  • FIG. 5(a) is a schematic diagram of loading a picture frame in the target template disclosed in an embodiment of the application with pictures in the same predetermined order as a picture frame.
  • the dashed frame represents the sample picture grid
  • the solid line frame represents the sample picture
  • the area of the picture outside the dashed frame is cropped. Matching the picture grid and the picture according to the technical solution of the present application will ensure that the rectangular shape of the original picture remains unchanged and avoid the picture from being excessively cropped.
  • FIG. 5(b) is the disclosure of the embodiments of this application.
  • the schematic diagram of the position adjustment when the picture is loaded into the picture grid as shown in the legend on the left of Figure 5(b)
  • the size of the sample picture picture is smaller than the size of the picture picture grid of the sample picture, after the picture picture is loaded into the sample picture picture grid , Adjust the size and position of the sample picture in the sample picture picture grid, so that the three edge lines of the sample picture picture coincide with the three edge lines of the sample picture picture grid, adjust the size and position of the sample picture picture in the sample picture picture grid Then, the picture area outside the sample picture grid area can be cropped.
  • FIG. 5(a) and FIG. 5(b) are only illustrations, and do not represent that they can only be of the type shown in FIG. 5(a) and FIG. 5(b), and the embodiments of the present application are not limited herein.
  • FIG. 5(c), Fig. 5(d) and Fig. 5(e), Fig. 5(c) It is a schematic diagram of using a picture processing method disclosed in the embodiments of this application to puzzle pictures.
  • the 8 pictures in Fig. 5(c) correspond to the 8 pictures in Fig. 1(a), which are disclosed in the embodiments of this application.
  • the four pictures in Fig. 5(e) correspond to the 4 pictures in Fig. 1(c), and the technical solution of the above picture processing method provided by the embodiment of this application is adopted.
  • the pictures labeled 1 and 4 are not overly cropped, so the pictures labeled 1 and 4 are retained Important information.
  • FIG. 6 is a schematic structural diagram of a picture processing device disclosed in an embodiment of the application.
  • the picture processing device includes:
  • the selection module 70 is used to select a predetermined number of pictures
  • the determining module 71 is configured to determine a first template set based on a predetermined number, the first template set includes a plurality of templates for a predetermined number of pictures, and each template includes a predetermined number of picture grids for accommodating the pictures;
  • the first sorting module 72 is configured to sort a predetermined number of pictures based on a predetermined order describing the size ratio of the picture sizes;
  • the second sorting module 73 is configured to sort a predetermined number of picture grids based on a predetermined order describing the size ratio of the picture grids for each template in the first template set;
  • the calculation module 74 is used to calculate the cropping amount of each template for each template in the first template set, and the cropping amount of the template is required for correspondingly loading each picture into the same picture grid in the predetermined order according to the predetermined order The sum of the cutting amount;
  • the selection module 75 is configured to select a template with the smallest cropping amount from the first template set as a target template for a predetermined number of pictures.
  • the first sorting module 72 includes:
  • the first sorting unit is used to sort the pictures according to a predetermined order of the aspect ratio of the pictures.
  • the second sorting module 73 includes:
  • the second sorting unit is used for sorting the picture grids according to the predetermined order of the aspect ratio of the picture grids.
  • the second sorting module 73 includes:
  • the third sorting unit is used for sorting the picture grids according to the predetermined order of the aspect ratio of the circumscribed rectangle of the picture grids.
  • FIG. 7 is a schematic structural diagram of an electronic device disclosed in an embodiment of the application.
  • the controller hub 804 communicates with the processor 801 via a multi-drop bus such as a front side bus (FSB), a point-to-point interface such as a fast path interconnect (QPI), or similar connection.
  • the processor 801 executes instructions that control general types of data processing operations.
  • the controller hub 804 includes, but is not limited to, a graphics memory controller hub (GMCH) (not shown in the figure) and an input/output hub (IOH) (which may be on a separate chip) (Not shown in the figure), where the GMCH includes a memory and a graphics controller and is coupled with the IOH.
  • GMCH graphics memory controller hub
  • IOH input/output hub
  • the electronic device 800 may also include a coprocessor 806 and a memory 802 coupled to the controller hub 804.
  • a coprocessor 806 and a memory 802 coupled to the controller hub 804.
  • one or both of the memory 802 and the GMCH may be integrated in the processor 801 (as described in this application), and the memory 802 and the coprocessor 806 are directly coupled to the processor 801 and the controller hub 804, and control
  • the device hub 804 and the IOH are in a single chip.
  • the memory 802 may be, for example, dynamic random access memory (DRAM), phase change memory (PCM), or a combination of the two.
  • the memory 802 may include one or more tangible, non-transitory computer-readable media for storing data and/or instructions.
  • the computer-readable storage medium stores instructions, specifically, temporary and permanent copies of the instructions.
  • the coprocessor 806 is a dedicated processor, such as, for example, a high-throughput MIC processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU, or an embedded processor, etc.
  • a dedicated processor such as, for example, a high-throughput MIC processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU, or an embedded processor, etc.
  • the optional nature of the coprocessor 806 is shown in dashed lines in FIG. 7.
  • the electronic device 800 may further include a network interface (NIC) 803.
  • the network interface 803 may include a transceiver, which is used to provide a radio interface for the device 800 to communicate with any other suitable devices (such as a front-end module, an antenna, etc.).
  • the network interface 803 may be integrated with other components of the electronic device 800.
  • the network interface 803 can realize the function of the communication unit in the above-mentioned embodiment.
  • the electronic device 800 may further include an input/output (I/O) device 805.
  • the input/output (I/O) device 805 may include: a user interface, which is designed to enable a user to interact with the electronic device 800; the design of the peripheral component interface enables the peripheral components to also interact with the electronic device 800; and/or a sensor design To determine environmental conditions and/or location information related to the electronic device 800.
  • FIG. 7 is only exemplary. That is, although FIG. 7 shows that the electronic device 800 includes multiple devices such as the processor 801, the controller hub 804, and the memory 802, in actual applications, the devices using the methods of the present application may only include the electronic device 800. Some of the devices, for example, may only include the processor 801 and the NIC 803. The properties of optional devices in Fig. 7 are shown by dashed lines.
  • the instructions stored in the computer-readable storage medium of the electronic device 800 may include: when executed by at least one unit in the processor, cause the device to implement the image processing method mentioned in FIGS. 2 to 6 Instructions. When the instructions are executed on the computer, the computer executes the image processing methods mentioned in FIGS. 2 to 6.
  • FIG. 8 is a schematic structural diagram of an SOC disclosed in an embodiment of the present application, and shows a block diagram of an SoC (System on Chip) 1000 according to an embodiment of the present application.
  • SoC System on Chip
  • similar parts have the same reference numerals.
  • dashed box is an optional feature of the more advanced SoC.
  • the SoC can be used in an electronic device according to an embodiment of the present application, and corresponding functions can be implemented according to the instructions stored in the SoC.
  • the SoC 1000 includes: an interconnection unit 1002, which is coupled to a processor 1001; a system agent unit 1006; a bus controller unit 1005; an integrated memory controller unit 1003; a group or one or more coprocessors 1007, which may include integrated graphics logic, image processors, audio processors, and video processors; a static random access memory (SRAM) unit 1008; and a direct memory access (DMA) unit 1004.
  • the coprocessor 1007 includes a dedicated processor, such as, for example, a network or communication processor, a compression engine, a GPU, a high-throughput MIC processor, or an embedded processor, etc.
  • a static random access memory (SRAM) unit 1008 may include one or more computer-readable media for storing data and/or instructions.
  • the computer-readable storage medium may store instructions, specifically, temporary and permanent copies of the instructions.
  • the instructions stored in the computer-readable storage medium may include: when executed by at least one unit in the processor, the electronic device will be implemented as mentioned in Figure 2-6 Instructions for the image processing method.
  • the instructions are executed on the computer, the computer is caused to execute the image processing method mentioned in Figures 2-6.
  • the embodiment of the present application also discloses a computer-readable storage medium, and the computer-readable storage medium stores a processing program, and the processing program is executed by the processor to implement the image processing method mentioned in FIGS. 2 to 6.
  • the computer-readable storage medium may be a read-only memory, a random access memory, a hard disk, or an optical disk.
  • the image processing method, device, electronic equipment, and storage medium disclosed in the embodiments of the present application have the following beneficial effects:
  • each template constitutes a first template set.
  • which template to use as the target template can be determined based on the image grid of the template corresponding to the total cropping amount after loading the image.
  • the images are selected in a predetermined order describing the size ratio of the image size.
  • Sort sort the picture grids in each template in the same predetermined order according to the size ratio describing the size of the picture grid, load the pictures into the corresponding picture grids of each template in the same predetermined order, and accumulate the various pictures of the template Relative to the total cropping amount of the loaded picture, each template corresponds to a total cropping amount, and the template with the smallest cropping amount is selected as the target template.
  • the template with the smallest cropping amount is selected as the target template.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种图片处理方法、装置、电子设备及存储介质,基于图片的预定数量,对应的选取用于容纳图片的图片格的数量与预定数量相同的模板,按照描述图片尺寸的尺寸比值的预定次序对图片进行排序,以相同的预定次序对各个模板中的图片格按照描述图片格大小的尺寸比值进行排序,按照相同的预定次序将图片装入到各个模板对应的图片格中,并累计模板的各个图片格相对于所装入的图片的总裁剪量,从中选取裁剪量最小的模板作为目标模板。如此,在对各个图片进行拼图时,选择裁剪量最小的模板作为拼图模板,且各个图片所装入的图片格是按照图片尺寸的尺寸比值相对应,避免了图片被过度裁剪而过多丢失图片信息。

Description

一种图片处理方法、装置、电子设备及存储介质
本申请要求于2019年12月17提交中国专利局、申请号为201911304930.5一种图片处理方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机领域,尤其涉及一种图片处理方法、装置、电子设备及存储介质。
背景技术
随着手机的普遍应用,用户对手机的照片的美化需求越来越高,如今各式各样的应用软件不断的推出满足用户需求的各式各样的功能,如拼图功能,用户可以将多张照片拼接到一起作为一张图片展示,在拼图的过程中,需要用户根据图片的张数手动选择合适的拼图模板,并按照用户选择图片的顺序依次填充到拼图模板的各个宫格完成拼图,在此过程中,用户手动选择号拼图模板后,拼图模板中的各个宫格装入用户选择的图片时,是按照用户选择图片的顺序依次对应装入,如果拼图模板中的宫格的尺寸与对应装入的图片的尺寸相差较大,则会导致图片被过度裁剪。
发明内容
本申请实施例提供了一种图片处理方法、装置、电子设备及存储介质,无需用户手动选取拼图模板,且避免了图片被过度裁剪的问题。
第一方面,本申请实施例提供了一种图片处理方法,所述图片处理方法包括:选取预定数量的图片;基于所述预定数量确定第一模板集合,所述第一模板集合包括多个用于所述预定数量的图片的模板,每个模板包括所述预定数量个用于容纳图片的图片格;基于描述所述图片尺寸的尺寸比值的预定次序对所述预定数量的图片进行排序;对于所述第一模板集合中的每个所述模板,基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序;对于所述第一模板集合中的每个所述模板,计算每个所述模板的裁剪量,所述模板的裁剪量是依照所述预定次序将每张图片对应地装入预定次序相同的图片格中所需的裁剪量的总和;从所述第一模板集合中,选定所述裁剪量最小的模板作为用于所述预定数量的图片的目标模板。
本申请实施例公开的一种图片处理方法,在用户选取预定数量的图片之后,基于图片的预定数量,对应的选取用于容纳图片的图片格的数量与预定数量相同的模板,各个模板构成第一模板集合。在选定第一模板集合后,具体选用哪个模板作为目标模板可以基于模板的图片格对应装入图片后的总的裁剪量进行确定,具体是,按照描述图片尺寸的尺寸比值的预定次序对图片进行排序,以相同的预定次序对各个模板中的图片格按照描述图片格大小的尺寸比值进行排序,按照相同的预定次序将图片装入到 各个模板对应的图片格中,并累计模板的各个图片格相对于所装入的图片的总裁剪量,每一个模板均对应有一个总裁剪量,从中选取裁剪量最小的模板作为目标模板。如此,在对各个图片进行拼图时,选择裁剪量最小的模板作为拼图模板,且各个图片所装入的图片格是按照图片尺寸的尺寸比值相对应,避免了图片被过度裁剪而过多丢失图片信息。
在上述第一方面的可能实现中,对所述预定数量的图片进行排序包括:按照各所述图片的横纵比的预定次序对各所述图片进行排序。具体的,基于描述图片尺寸的尺寸比值可以包括图片的纵横比或图片的横纵比,图片的纵横比指的是图片的高度与宽度的比值,图片的横纵比指的是图片的宽度与高度的比值。进一步的,图片的尺寸比值也可以为图片的宽度与图片的对角线的长度的比值或者图片的高度与图片的对角线的长度的比值。
在上述第一方面的可能实现中,图片格的形状可以为矩形,也可以为非矩形,当图片格为矩形时,对预定数量的图片格进行排序包括:按照各所述图片格的横纵比的预定次序对各所述图片格进行排序。具体的,基于描述图片格大小的尺寸比值可以包括图片格的纵横比或图片格的横纵比,图片格的纵横比指的是图片格的高度与宽度的比值,图片格的横纵比指的是图片格的宽度与高度的比值。进一步的,图片格的尺寸比值也可以为图片格的宽度与图片格的对角线的长度的比值或者图片格的高度与图片格的对角线的长度的比值。值得注意的是,在进行排序时,图片的尺寸比值和图片格的尺寸比值应该保持一致,如图片的尺寸比值为横纵比时,在进行排序时,图片格的尺寸比值也应该为横纵比,以保证图片与对应的图片格的匹配的精确度。
在上述第一方面的可能实现中,当图片格为非矩形时,如椭圆形、圆形、五边形等,对于非矩形的图片格,可以以图片格的外接矩形的横纵比的预定次序对各图片格排序。对于椭圆形的图片格而言,其外接矩形的横纵比为椭圆的短轴与长轴的比值,对于圆形的图片格而言,其外接矩形的横纵比为圆形的直径的比值。对于图片格为非矩形时的外接矩形,指的是以二维形状的非矩形的图片格在二维坐标下,以非矩形的图片格的最大横坐标、最小横坐标、最大纵坐标和最小纵坐标所定的边界,即为外接矩形。
在上述第一方面的可能实现中,对于预定数量的图片和每个模板中的图片格的横纵比的预定次序进行排序,其可以为根据预定数量的图片的横纵比的值的大小降序排列,也可以为根据预定数量的图片的横纵比的值的大小升序排列。
在上述第一方面的可能实现中,所述图片的横纵比包括所述图片的宽度与高度的比值,
所述图片格的横纵比包括所述图片格的宽度与高度的比值,所述宽度与所述高度以厘米为单位。
在上述第一方面的可能实现中,选取的所有的图片中可能存在描述图片尺寸的尺寸比值相同的目标图片,对于这些目标图片而言,与其预定次序对应的图片格只有一个,为了提升用户的体验感,可以按照用户选择预定数量的图片的步骤中目标图片的被选中的先后选择顺序为优先级优先为排序在前的目标图片分配图片格,选择顺序指的是用户按照先后顺序依次选取图片的顺序,其余的目标图片可以依次按照图片格的 预定次序往后顺延,保证预定数量的图片在装入各个图片格中,裁剪量最小。
在上述第一方面的可能实现中,对应的最小裁剪量的目标模板可能为多个,以各目标模板构成第二模板集合,按照预设优先级从第二模板集合中选取一个优先级最高的目标模板作为最终的预定数量的图片的目标模板。其中,预设优先级可以由用户自定义设置的,即用户按照自己的使用需求自定义选定目标模板作为优先级较高的目标模板,提升了用户体验,也可以是将处于离线状态就可以使用的基础的目标模板设置为优先级较高模板,将只有在线下载才能使用的模板设置为比基础的目标模板的优先级低的模板。
在上述第一方面的可能实现中,为了避免以同一模板中各图片格与各自对应的图片的面积差值计算裁剪量的方式中以面积差值的数据过大降低裁剪量的计算速度,可以采用归一化处理的方式计算模板的裁剪量,即将图片格与对应装入的图片的裁剪量以百分比的形式体现,将图片格与对应装入的图片的裁剪量的数值都归一化到(0,1)范围内,其中,所述计算模板的裁剪量采用下式计算:
Figure PCTCN2020135761-appb-000001
其中,C k为第k个模板的总的裁剪量,C ki为第k个模板的第i个图片格中装入的第i个图片的裁剪量,r i为描述第i个图片的大小的尺寸比值,r ki为描述所述第k个模板的装入第i个图片的第i个图片格的尺寸比值。
在上述第一方面的可能实现中,在确定目标模板之后,依照预定次序将各图片对应的装入预定次序相同的图片格中,完成各图片的拼图处理。其中,以3张图片为例,第1张图片的横纵比为3/4,第2张图片的横纵比为1/2,第3张图片的横纵比为1/3,将3张图片按照降序排列,依次为:第1张图片→第2张图片→第3张图片;选取的目标模板的图片格的个数对应为3个,第1个图片格的横纵比为5/12,第2个图片格的横纵比为5/6,第3个图片格的横纵比为7/12,将目标模板的3个图片格按照降序排列,依次为第2个图片格→第3个图片格→第1个图片格,按照排列预定次序,将排序第1的第1张图片装入到排序第1的第2个图片格中,将排序第2的第2张图片装入到排序第2的第3个图片格中,将排序第3的第3张图片装入到排序第3的第3个图片格中。如此,最大程度上保证了3张图片的总的裁剪量最小。
在上述第一方面的可能实现中,应用裁剪量计算公式,上述以3张图片为例的总的裁剪量为
Figure PCTCN2020135761-appb-000002
即3张图片的总的裁剪量为44.3%。值得注意的是,如果图片和图片格的尺寸比值相同,则说明图片与图片格重合或者可以等比例放大或缩小图片使得图片和图片格重合,使得尺寸比值与图片格相同的图片装入该图片格中可以不被裁剪,即裁剪量为零。
第二方面,本申请实施例公开了一种图片处理装置,包括:
选取模块,用于选取预定数量的图片;
确定模块,用于基于所述预定数量确定第一模板集合,所述第一模板集合包括多个用于所述预定数量的图片的模板,每个模板包括所述预定数量个用于容纳图片的图片格;
第一排序模块,用于基于描述所述图片尺寸的尺寸比值的预定次序对所述预定数量的图片进行排序;
第二排序模块,用于对于所述第一模板集合中的每个所述模板,基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序;
计算模块,用于对于所述第一模板集合中的每个所述模板,计算每个所述模板的裁剪量,所述模板的裁剪量是依照所述预定次序将每张图片对应地装入预定次序相同的图片格中所需的裁剪量的总和;
选定模块,用于从所述第一模板集合中,选定所述裁剪量最小的模板作为用于所述预定数量的图片的目标模板。
在上述第二方面的可能实现中,第一排序模块包括:
第一排序单元,用于按照各所述图片的横纵比的预定次序对各所述图片进行排序。
在上述第二方面的可能实现中,第二排序模块包括:
第二排序单元,用于按照各所述图片格的横纵比的预定次序对各所述图片格进行排序。
在上述第二方面的可能实现中,第二排序模块包括:
第三排序单元,用于按照所述图片格的外接矩形的横纵比的预定次序对各所述图片格进行排序。
第三方面,本申请实施例公开了一种电子设备,电子设备包括:
存储器,用于存储处理程序;
处理器,所述处理器执行所述处理程序时实现如以上任意一种所述的图像处理方法的步骤。
第四方面,本申请实施例公开了一种计算机可读存储介质,所述计算机可读存储介质上存储有处理程序,处理器执行所述处理程序时实现如以上任意一种所述的图像处理方法的步骤。
本申请其他特征和相应的有益效果在说明书的后面部分进行阐述说明,且应当理解,至少部分有益效果从本申请说明书中的记载变的显而易见。
附图说明
图1(a)至图1(c)为本申请实施例公开的一种现有技术的图片拼图的示意图;
图2为本申请实施例公开的一种图片处理方法的流程示意图;
图3(a)为本申请实施例公开的一组拼图模板的布局示意图;
图3(b)为本申请实施例公开的美学螺旋式的布局示意图;
图4(a)为本申请实施例公开的一种为目标图片分配图片格的方法流程示意图;
图4(b)为本申请实施例公开的一种对图片格进行排序的方法流程示意图;
图4(c)为本申请实施例公开的一种图片格的外接矩形的图形示意图;
图4(d)为本申请实施例公开的一种模板的裁剪量的计算方法的流程示意图;
图4(e)为本申请实施例公开的一种选取最优的目标模板的方法流程示意图
图5(a)为本申请实施例公开的目标模板中的一图片格装入与一图片格预定次序相同的图片的示意图;
图5(b)为本申请实施例公开的图片装入图片格中时的位置调整示意图;
图5(c)至图5(e)为采用本申请实施例公开的一种图片处理方法对图片进行拼图的示意图;
图6为本申请实施例公开的一种图片处理装置的结构示意图;
图7为本申请实施例公开的一种电子设备的结构示意图;
图8为本申请实施例公开的一种SOC的结构示意图。
具体实施方式
以下由特定的具体实施例说明本申请的实施方式,本领域技术人员可由本说明书所揭示的内容轻易地了解本申请的其他优点及功效。虽然本申请的描述将结合较佳实施例一起介绍,但这并不代表此发明的特征仅限于该实施方式。恰恰相反,结合实施方式作发明介绍的目的是为了覆盖基于本申请的权利要求而有可能延伸出的其它选择或改造。为了提供对本申请的深度了解,以下描述中将包含许多具体的细节。本申请也可以不使用这些细节实施。此外,为了避免混乱或模糊本申请的重点,有些具体细节将在描述中被省略。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。
应注意的是,在本说明书中,相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。
下面将结合附图对本申请的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围,此外,对于本领域技术人员所公知的技术也可以作为本申请实施例的一部分,本申请对此不再赘述。
可以理解,如本文所使用的,术语“模块”可以指代或者包括专用集成电路(ASIC)、电子电路、执行一个或多个软件或固件程序的处理器(共享、专用、或群组)和/或存储器、组合逻辑电路、和/或提供所描述的功能的其他适当硬件组件,或者可以作为这些硬件组件的一部分。
可以理解,在本申请各实施例中,处理器可以是微处理器、数字信号处理器、微控制器等,和/或其任何组合。根据另一个方面,所述处理器可以是单核处理器,多核处理器等,和/或其任何组合。随着手机的普遍应用,用户对手机的照片的后期处理的需求越来越高,如今各式各样的应用软件不断的推出满足用户需求的各式各样的功能,如拼图功能,用户可以将手机拍摄的存储于手机图库中的多张照片拼接到一起作为一张图片展示,在拼图的过程中,需要用户根据图片的张数手动选择合适的拼图模板(即对应于图片的张数选择图片格的个数与图片的张数相同拼图模板),并按照用户选择图片的顺序依次填充到拼图模板的各个宫格(图片格)完成拼图,在此过程中,用户 手动选择好拼图模板后,拼图模板中的各个宫格装入用户选择的图片时,是按照用户选择图片的顺序依次对应装入,如果拼图模板中的宫格的尺寸与对应装入的图片的尺寸相差较大,则会导致图片被过度裁剪。
以某应用推出的拼图功能为例,其对应有多个拼图模板,根据拼图模板中图片格的个数可以将拼图模板分为多组,每一组中拼图模板的图片格在整个模板面中的布局位置以及各个图片格的尺寸大小都各不相同,请参见图1(a)和图1(b),图1(a)为本申请实施例公开的一种拼图示意图,共有8张图片。在用户选定图片之后,按照现有技术的方案,依据用户选择图片的选择顺序,8张示例图片被装入到用户选择的具有8个图片格的示例模板中的一示例图片格中,在进行裁剪时,示例图片位于示例图片格的部分被保留,处于示例图片格之外的部分全部被裁剪,如图1(b)所示的,8张图片完成拼图之后,标号为1的图片和标号为4的图片被过度裁剪,裁剪量均超出了40%,很容易丢失示例图片的重要信息。如果示例图片为包含人脸的人脸自拍图像,而人脸区域恰好处于示例图片格中,按照该种裁剪方式很容易导致大脸问题,影响用户体验。
继续参见图1(c),图1(c)中包含4张图片,用户选择的示例模板为具有4个图片格的模板,4张图片被装入该模板时,标号为1和标号为4的图片也被过分裁剪,丢失了标号为1和标号为4的图片的重要信息。可以理解的是,图1(c)和图1(b)和图1(a)中的标号为1和标号为4的图片为相同的图片。
基于此,本申请实施例提供了一种图片处理方法、装置、电子设备及存储介质,无需用户手动选取拼图模板,且避免了图片被过度裁剪的问题。
下面结合附图对本申请实施例公开的一种图片处理方法进行说明。
请参见图2,图2为本申请实施例公开的一种图片处理方法的流程示意图,图2所示的图片处理方法包括:
S20:选取N张图片,以构成九宫格或者基于九宫格变形的拼图样式。
在本申请的一些实施例中,N可以为整数,本申请实施例中,以N为8为例进行说明,这8张图片是由用户从手机中的图库中的多张图片中选取的,即由用户选取的需要拼图的照片。其中,将8张图片作为图片的预定数量,对于预定数量其也可以为其他值,本申请实施例在此并不作限定。
S21:基于选取的N张图片确定第一模板集合,第一模板集合包括多个,每个模板集合中的模板的图片格的个数也为N,即图片的数量和图片格的数量相同,例如8个用于8张图片的模板,每个模板包括8个用于容纳8张图片的图片格。
在本申请的一些实施例中,对于用于各图片的拼图模板而言,为了增加拼图模板的灵动性、美观性以及避免图片被过度裁剪,可以基于美学布局中的螺旋布局原则对拼图模板中的图片格的位置以及尺寸进行布局。如图3(a)所示的,图3(a)为本申请实施例公开的一组拼图模板的布局示意图,其中,从中心的图片格开始,沿着逆时针的方向,各个图片格呈现螺旋式的不均分的方式布局,如图3(b)所示的,图3(b)为本申请实施例公开的一种螺旋式的布局方式示意图,图3(a)基于图3(b)所示的螺旋布局方式对图片格进行布局,其并非采用均分的方式进行布局,因被选取的待拼图的图片的尺寸互不相同,若图片格采用均分的方式进行布局,很容易导致待拼图的 图片被过度裁剪的情况。
S22:基于描述图片尺寸的尺寸比值的大小对N张图片进行降序排列。
在本申请的一些实施例中,描述图片尺寸的尺寸比值可以为图片的纵横比(高度与宽度的比值)、图片的横纵比(宽度与高度的比值)、图片的宽度与图片的对角线的比值、图片的高度与图片的对角线的比值等。各个尺寸比值之间存在大小关系,对于各个图片可以按照尺寸比值的大小降序排列或者按照尺寸比值的大小升序排列,即以降序排列或升序排列为预定次序对8张图片进行排序。对于图片的宽度和高度而言,其可以以厘米为单位,也可以以像素为单位。
S23:对于第一模板集合中的每个模板,基于描述图片格大小的横纵比对N个图片格进行降序排列。
在本申请的一些实施例中,对8张图片格进行排序包括:按照各所述图片格的横纵比对各图片格进行降序排序。具体的,基于描述图片格大小的尺寸比值可以包括图片格的纵横比或图片格的横纵比,图片格的纵横比指的是图片格的高度与宽度的比值,图片格的横纵比指的是图片格的宽度与高度的比值。进一步的,图片格的尺寸比值也可以为图片格的宽度与图片格的对角线的长度的比值或者图片格的高度与图片格的对角线的长度的比值。值得注意的是,在进行排序时,图片的尺寸比值和图片格的尺寸比值应该保持一致,如图片的尺寸比值为横纵比时,在进行排序时,图片格的尺寸比值也应该为横纵比,以保证图片与对应的图片格的匹配的精确度。
进一步的,在本申请的一些实施例中,图片格的形状可以为矩形,也可以为非矩形,当图片格为非矩形时,如椭圆形、圆形、五边形等。
进一步的,在本申请的一些实施例中,在用户选取的8张图片中,可能存在描述图片尺寸的尺寸比值相同的目标图片,如对8张图片进行降序排列,对模板中的8个图片格进行降序排列,8张图片中存在尺寸比值相同且排序号为5的两张目标图片,这两张排序号为5的目标图片对应的8张图片格中排序号为5的图片格只为1个,为了对两张目标图片分配该图片格的同时保证用户的体验不被降低,本申请实施例提供了一种为目标图片分配图片格的方法。
参见图4(a),图4(a)为本申请实施例公开的一种为目标图片分配图片格的方法流程示意图,该方法包括:
S40:选取N张图片,以构成九宫格或者基于九宫格变形的拼图样式。
其中,N可以为整数,本申请实施例中,以N为8为例进行说明。
S41:基于选取的N张图片确定第一模板集合,第一模板集合包括多个,每个模板集合中的模板的图片格的个数也为N,即图片的数量和图片格的数量相同,例如8个用于8张图片的模板,每个模板包括8个用于容纳8张图片的图片格。
S42:基于描述图片尺寸的横纵比的大小对N张图片进行降序排列。
S43:对于第一模板集合中的每个模板,基于图片格的形状和描述图片格大小的横纵比对N个图片格进行降序排列。
其中,对于S43而言,在本申请的一些实施例中,图片格的形状可以为矩形,也可以为非矩形,当图片格为非矩形时,如椭圆形、圆形、五边形等,对于矩形和非矩形的图片格,描述其图片格大小的尺寸比值可以以图4(b)中所示的方法进行排序, 请参见图4(b),图4(b)为本申请实施例公开的一种对图片格进行排序的方法流程示意图,该方法包括:
S430:判断图片格的形状是否为矩形,若是,则进入S431,若否,则进入S432。
S431:按照图片格的横纵比的大小对图片格进行排序。
在本申请的一些实施例中,基于描述图片格大小的尺寸比值可以包括图片格的纵横比或图片格的横纵比,图片格的纵横比指的是图片格的高度与宽度的比值,图片格的横纵比指的是图片格的宽度与高度的比值。进一步的,图片格的尺寸比值也可以为图片格的宽度与图片格的对角线的长度的比值或者图片格的高度与图片格的对角线的长度的比值。值得注意的是,在进行排序时,图片的尺寸比值和图片格的尺寸比值应该保持一致,如图片的尺寸比值为横纵比时,在进行排序时,图片格的尺寸比值也应该为横纵比,以保证图片与对应的图片格的匹配的精确度。
S432:按照图片格的外接矩形的横纵比的大小对图片格进行排序。
在本申请的一些实施例中,对于椭圆形的图片格而言,其外接矩形的横纵比为椭圆的短轴与长轴的比值,对于圆形的图片格而言,其外接矩形的横纵比为圆形的直径的比值。对于图片格为非矩形时的外接矩形,指的是以二维形状的非矩形的图片格在二维坐标下,以非矩形的图片格的最大横坐标、最小横坐标、最大纵坐标和最小纵坐标所定的边界,即为外接矩形,以图片格为如图4(c)所示的非矩形为例,图4(c)为本申请实施例公开的一种图片格的外接矩形的图形示意图,其中,图4(c)示出的加黑的边框即为图4(c)所示的非矩形的外接矩形,其外接矩形为在二维坐标下连接其最大横坐标、最大纵坐标、最小横坐标以及最小纵坐标而形成的边界组成的矩形。
值得注意的是,在进行排序时,图片的尺寸比值和图片格的尺寸比值应该保持一致,如图片的尺寸比值为横纵比时,在进行排序时,图片格的尺寸比值也应该为横纵比,以保证图片与对应的图片格的匹配的精确度,在图片按照其尺寸比值的大小降序排列时,图片格也应该按照其尺寸比值的大小降序排列。
S44:判断N张图片中是否存在横纵比相同的目标图片,若是,则进入S45,若否,则进入S46。
S45:排序号为5的图片为两张,将排序号为5的两张图片作为目标图片,并确定在选取N张图片的步骤中2张目标图片的被选中的先后顺序。
S47:以先后顺序为优先级优先为排序号为5的2张目标图片中选择顺序在前的目标图片分配与选择顺序在前的目标图片的排序号为5的图片格。
可以理解的是,剩余的一张目标图片分配到排序号为6的图片格中,其余的图片分配图片格的顺序按照降序排列后的图片的排列号和图片格的排列号依次往后顺延。
S46:依照N张图片的按照横纵比进行降序排列的排列号将每张图片对应地装入按降序排列的N个图片格的排列号相同的图片格中。
在本申请的一些实施例中,图片格的横纵比可以为1:2,4:7,2:3,8:9,1:1,4:3等等。
S48:对于第一模板集合中的每个模板,以预定公式计算每个模板中的图片格对应装入N张图片后的裁剪量。
在本申请的一些实施例中,计算每个模板的裁剪量时,为了避免以同一模板中各 图片格与各自对应的图片的面积差值计算裁剪量的方式中以面积差值的数据过大降低裁剪量的计算速度,可以采用归一化处理的方式计算模板的裁剪量,即将图片格与对应装入的图片的裁剪量以百分比的形式体现,将图片格与对应装入的图片的裁剪量的数值都归一化到(0,1)范围内,计算模板的裁剪量可以采用一下计算公式进行计算:
Figure PCTCN2020135761-appb-000003
在本申请的一些实施例中,以尺寸比值为横纵比、排序预定次序为降序排列为例,若选取了n张图片,图片格的数量满足n张图片的拼图模板的第一模板集合为{T 1,T 2,......,T k},针对选取的n张图片,按照图片的横纵比的值的大小由大到小降序排列形成图片集合{r 1,r 2,......,r n},对应的,针对第一模板集合中的模板T k,模板T k中每个图片格按照横纵比的值的大小由大到小降序排列形成图片格集合{r k1,r k2,......,r ki},即r 1为n张图片中横纵比最大的图片,r k1为模板T k中横纵比最大的图片格,依次参照。在步骤S48中,以预定公式计算裁剪量请参见图4(d),图4(d)为本申请实施例公开的一种模板的裁剪量的计算方法的流程示意图,该方法包括:
S480:判断第i个图片的大小的横纵比是否大于第k个模板的装入第i个图片的第i个图片格的横纵比。若大于,则进入S481,若第i个图片的大小的横纵比小于第k个模板的装入第i个图片的第i个图片格的横纵比,则进入S482。
S481:利用公式
Figure PCTCN2020135761-appb-000004
计算第i个图片格的裁剪量。
S482:利用公式
Figure PCTCN2020135761-appb-000005
计算第i个图片格的裁剪量。
S483:依次循环,在不满足i<n的条件时,便为计算完成第k个模板的第n个图片的裁剪量并进入S584。
S484:利用公式
Figure PCTCN2020135761-appb-000006
计算第k个模板的总的裁剪量。
循环以上过程,直至计算完成第一模板集合为{T 1,T 2,......,T k}中k个模板的总的裁剪量,k个模板的总的裁剪量构成集合{C 1,C 2,......,C k},并从{C 1,C 2,......,C k}中选取总的裁剪量最小的目标模板min{C 1,C 2,......,C k}。
S49:从第一模板集合中,选定裁剪量最小的模板作为用于N张图片的目标模板。
更进一步的,在本申请的一些实施例中,对应的最小裁剪量的目标模板可能为多个,对此,如何选择一个目标模板作为最终的目标模板完成拼图处理,可以基于预设优先级从多个目标模板中选取一个最优的。对应于步骤S49,请参见图4(e),图4(e)为本申请实施例公开的一种选取最优的目标模板的方法流程示意图,该方法包括:
S490:判断与最小裁剪量对应的目标模板是否为多个,若是,则进入S491,若否,则进入S492。
S491:以各目标模板构成第二模板集合,以离线状态下使用的基础模板为最高优 先级的模板从第二模板集合中选取一个优先级最高的目标模板作为最优的用于8张图片的目标模板,然后再进入S492。
在本申请的一些实施例中,可以以离线状态下使用的基础模板和在线下载使用的模板设置预设优先级,此外预设优先级可以由用户自定义设置的,即用户按照自己的使用需求自定义选定目标模板作为优先级较高的目标模板,提升了用户体验,也可以是将处于离线状态就可以使用的基础的目标模板设置为优先级较高模板,将只有在线下载才能使用的模板设置为比基础的目标模板的优先级低的模板。
S492:依照N张图片的按照横纵比进行降序排列的排列号将每张图片对应地装入按降序排列的N个图片格的排列号相同的图片格中。
在执行S23之后,执行S24。
S24:对于第一模板集合中的每个模板,计算每个模板的裁剪量,模板的裁剪量是依照N张图片的按照横纵比进行降序排列的排列号将每张图片对应地装入按降序排列的N个图片格的排列号相同的图片格中所需的裁剪量的总和。
在本申请的一些实施例中,对于每个模板的裁剪量指的是每个模板中,将8张图片按照降序排列的排列顺序号对应的装入将8个图片格按照降序排列的排列顺序号相同的图片格中,每个图片处于与之对应的图片格之外的图片区域的面积之和。在图片装入图片格中,为了避免图片的包含生物特征的信息被过度裁剪,可以基于生物特征识别技术调整各图片在各自对应的图片格中的位置然后再进行裁剪。可以理解的是,计算每个模板的裁剪量可以参见以上图4(d)示出的计算方法进行计算。
S25:从第一模板集合中,选定裁剪量最小的模板作为用于N张图片的目标模板。
在本申请的一些实施例中,在确定目标模板之后,依照预定次序将各图片对应的装入预定次序相同的图片格中,完成各图片的拼图处理。其中,结合以上公式,以3张图片为例,根据3张图片选择出的第一模板集合中的各模板的图片格的个数也为3,第1张图片的横纵比为3/4,第2张图片的横纵比为1/2,第3张图片的横纵比为1/3,将3张图片按照降序排列,依次为:第1张图片→第2张图片→第3张图片;选取的目标模板的图片格的个数对应为3个,第1个图片格的横纵比为5/12,第2个图片格的横纵比为5/6,第3个图片格的横纵比为7/12,将目标模板的3个图片格按照降序排列,依次为第2个图片格→第3个图片格→第1个图片格,按照排列预定次序,将排序第1的第1张图片装入到排序第1的第2个图片格中,将排序第2的第2张图片装入到排序第2的第3个图片格中,将排序第3的第3张图片装入到排序第3的第3个图片格中。如此,最大程度上保证了3张图片的总的裁剪量最小。
在本申请的一些实施例中,应用裁剪量计算公式,上述以3张图片为例的总的裁剪量为
Figure PCTCN2020135761-appb-000007
即3张图片的总的裁剪量为44.3%。值得注意的是,如果图片和图片格的尺寸比值相同,则说明图片与图片格重合或者可以等比例放大或缩小图片使得图片和图片格重合,使得尺寸比值与图片格相同的图片装入该图片格中可以不被裁剪,即裁剪量为零。
在本申请的一些实施例中,请参见图5(a),图5(a)为本申请实施例公开的目标模板中的一图片格装入与一图片格预定次序相同的图片的示意图,其中,虚线框表示的是示例图片格,实线框表示的是示例图片,处于虚线框之外的图片的区域便被裁 剪。按照本申请的技术方案匹配图片格和图片,会保证原图片的矩形的形状不变,避免了图片被过度裁剪。
在本申请的一些实施例中,当图片的尺寸小于图片格的尺寸时(图片完全被图片格包覆),如图5(b)所示的,图5(b)为本申请实施例公开的图片装入图片格中时的位置调整示意图,如图5(b)左侧所示的图例,示例图片图片的尺寸小于示例图片图片格的尺寸,在示例图片图片装入示例图片图片格后,调整示例图片图片在示例图片图片格中的大小和位置,使得示例图片图片的三条边缘线与示例图片图片格的三条边缘线相重合,调整示例图片图片在示例图片图片格中的大小和位置后,处于示例图片格区域外的图片区域便可以被裁剪。值得注意的是,图5(a)和图5(b)仅仅是示意,并不代表只能为图5(a)和图5(b)的类型,本申请实施例在此并不作限定。
采用本申请实施例提供的以上的图片处理方法,在进行拼图时,避免了图片被过度采集,请参见图5(c)、图5(d)和图5(e),图5(c)是采用本申请实施例公开的一种图片处理方法对图片进行拼图的示意图,图5(c)中的8张图片对应于图1(a)中的8张图片,采用本申请实施例公开的图片处理方法,如图5(d)所示的,标号1和标号4的图片未被过度裁剪,标号4对应的图片的裁剪量低于25%,标号1的图片的裁剪量为零,如图5(e)所示的,图5(e)中的四张图片的对应的是图1(c)中的4张图片,采用本申请实施例提供的以上图片处理方法的技术方案,图5(e)所示的,4张图片被装入该具有4个图片格的模板时,标号为1和标号为4的图片未被过分裁剪,从而保留了标号为1和标号为4的图片的重要信息。
请参见图6,图6为本申请实施例公开的一种图片处理装置的结构示意图,图片处理装置包括:
选取模块70,用于选取预定数量的图片;
确定模块71,用于基于预定数量确定第一模板集合,第一模板集合包括多个用于预定数量的图片的模板,每个模板包括预定数量个用于容纳图片的图片格;
第一排序模块72,用于基于描述图片尺寸的尺寸比值的预定次序对预定数量的图片进行排序;
第二排序模块73,用于对于第一模板集合中的每个模板,基于描述图片格大小的尺寸比值的预定次序对预定数量的图片格进行排序;
计算模块74,用于对于第一模板集合中的每个模板,计算每个模板的裁剪量,模板的裁剪量是依照预定次序将每张图片对应地装入预定次序相同的图片格中所需的裁剪量的总和;
选定模块75,用于从第一模板集合中,选定裁剪量最小的模板作为用于预定数量的图片的目标模板。
在本申请的一些实施例中,第一排序模块72包括:
第一排序单元,用于按照各图片的横纵比的预定次序对各图片进行排序。
在本申请的一些实施例中,第二排序模块73包括:
第二排序单元,用于按照各图片格的横纵比的预定次序对各图片格进行排序。
在本申请的一些实施例中,第二排序模块73包括:
第三排序单元,用于按照图片格的外接矩形的横纵比的预定次序对各图片格进行 排序。
在本申请一些实施例中,还提供了一种电子设备,下面结合图7对本申请实施例中的电子设备进行介绍。图7为本申请实施例公开的一种电子设备的结构示意图。
对于至少一个实施例,控制器中枢804经由诸如前端总线(FSB)之类的多分支总线、诸如快速通道互连(QPI)之类的点对点接口、或者类似的连接与处理器801进行通信。处理器801执行控制一般类型的数据处理操作的指令。在一实施例中,控制器中枢804包括,但不局限于,图形存储器控制器中枢(GMCH)(图中未示出)和输入/输出中枢(IOH)(其可以在分开的芯片上)(图中未示出),其中GMCH包括存储器和图形控制器并与IOH耦合。
电子设备800还可包括耦合到控制器中枢804的协处理器806和存储器802。或者,存储器802和GMCH中的一个或两者可以被集成在处理器801内(如本申请中所描述的),存储器802和协处理器806直接耦合到处理器801以及控制器中枢804,控制器中枢804与IOH处于单个芯片中。
在一个实施例中,存储器802可以是例如动态随机存取存储器(DRAM)、相变存储器(PCM)或这两者的组合。存储器802中可以包括用于存储数据和/或指令的一个或多个有形的、非暂时性计算机可读介质。计算机可读存储介质中存储有指令,具体而言,存储有该指令的暂时和永久副本。
在一个实施例中,协处理器806是专用处理器,诸如例如高吞吐量MIC处理器、网络或通信处理器、压缩引擎、图形处理器、GPGPU、或嵌入式处理器等等。协处理器806的任选性质用虚线表示在图7中。
在一个实施例中,电子设备800可以进一步包括网络接口(NIC)803。网络接口803可以包括收发器,用于为设备800提供无线电接口,进而与任何其他合适的设备(如前端模块,天线等)进行通信。在各种实施例中,网络接口803可以与电子设备800的其他组件集成。网络接口803可以实现上述实施例中的通信单元的功能。
在一个实施例中,如图7所示的,电子设备800可以进一步包括输入/输出(I/O)设备805。输入/输出(I/O)设备805可以包括:用户界面,该设计使得用户能够与电子设备800进行交互;***组件接口的设计使得***组件也能够与电子设备800交互;和/或传感器设计用于确定与电子设备800相关的环境条件和/或位置信息。
值得注意的是,图7仅是示例性的。即虽然图7中示出了电子设备800包括处理器801、控制器中枢804、存储器802等多个器件,但是,在实际的应用中,使用本申请各方法的设备,可以仅包括电子设备800各器件中的一部分器件,例如,可以仅包含处理器801和NIC803。图7中可选器件的性质用虚线示出。
在本申请一些实施例中,该电子设备800的计算机可读存储介质中存储有指令可以包括:由处理器中的至少一个单元执行时导致设备实施如图2至图6提到的图片处理方法的指令。当指令在计算机上运行时,使得计算机执行上述如图2至图6所提到的图片处理方法。
现在参考图8,图8为本申请实施例公开的一种SOC的结构示意图,所示为根据本申请的一实施例的SoC(System on Chip,片上***)1000的框图。在图8中,相似的部件具有同样的附图标记。另外,虚线框是更先进的SoC的可选特征。该SoC 可以被用于根据本申请的一实施例的电子设备,根据其内所存储的指令,可以实现相应的功能。
在图8中,SoC 1000包括:互连单元1002,其被耦合至处理器1001;***代理单元1006;总线控制器单元1005;集成存储器控制器单元1003;一组或一个或多个协处理器1007,其可包括集成图形逻辑、图像处理器、音频处理器和视频处理器;静态随机存取存储器(SRAM)单元1008;直接存储器存取(DMA)单元1004。在一个实施例中,协处理器1007包括专用处理器,诸如例如网络或通信处理器、压缩引擎、GPU、高吞吐量MIC处理器、或嵌入式处理器等等。
静态随机存取存储器(SRAM)单元1008中可以包括用于存储数据和/或指令的一个或多个计算机可读介质。计算机可读存储介质中可以存储有指令,具体而言,存储有该指令的暂时和永久副本。
在SoC 1000被应用于根据本申请的电子设备上时,计算机可读存储介质中存储有指令可以包括:由处理器中的至少一个单元执行时导致电子设备实施如图2-图6所提到的图片处理方法的指令。当指令在计算机上运行时,使得计算机执行上述如图2-图6所提到的图片处理方法。
此外,本申请实施例还公开了一种计算机可读存储介质,计算机可读存储介质上存储有处理程序,处理程序被处理器执行时实现如图2至图6提到的图像处理方法。
计算机可读存储介质可以为只读存储器、随机存取存储器、硬盘或者光盘等。
本申请实施例公开的一种图片处理方法、装置、电子设备及存储介质,具有如下有益效果:
在用户选取预定数量的图片之后,基于图片的预定数量,对应的选取用于容纳图片的图片格的数量与预定数量相同的模板,各个模板构成第一模板集合。在选定第一模板集合后,具体选用哪个模板作为目标模板可以基于模板的图片格对应装入图片后的总的裁剪量进行确定,具体是,按照描述图片尺寸的尺寸比值的预定次序对图片进行排序,以相同的预定次序对各个模板中的图片格按照描述图片格大小的尺寸比值进行排序,按照相同的预定次序将图片装入到各个模板对应的图片格中,并累计模板的各个图片格相对于所装入的图片的总裁剪量,每一个模板均对应有一个总裁剪量,从中选取裁剪量最小的模板作为目标模板。如此,在对各个图片进行拼图时,选择裁剪量最小的模板作为拼图模板,且各个图片所装入的图片格是按照图片尺寸的尺寸比值相对应,避免了图片被过度裁剪而过多丢失图片信息。
最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。

Claims (13)

  1. 一种图片处理方法,其特征在于,所述图片处理方法包括:
    选取预定数量的图片;
    基于所述预定数量确定第一模板集合,所述第一模板集合包括多个用于所述预定数量的图片的模板,每个模板包括所述预定数量个用于容纳图片的图片格;
    基于描述所述图片尺寸的尺寸比值的预定次序对所述预定数量的图片进行排序;
    对于所述第一模板集合中的每个所述模板,基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序;
    对于所述第一模板集合中的每个所述模板,计算每个所述模板的裁剪量,所述模板的裁剪量是依照所述预定次序将每张图片对应地装入预定次序相同的图片格中所需的裁剪量的总和;
    从所述第一模板集合中,选定所述裁剪量最小的模板作为用于所述预定数量的图片的目标模板。
  2. 如权利要求1所述的图片处理方法,其特征在于,所述基于描述所述图片尺寸的尺寸比值的预定次序对所述预定数量的图片进行排序包括:
    按照各所述图片的横纵比的预定次序对各所述图片进行排序。
  3. 如权利要求2所述的图片处理方法,其特征在于,若所述图片格为矩形,所述基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序包括:
    按照各所述图片格的横纵比的预定次序对各所述图片格进行排序。
  4. 如权利要求2所述的图片处理方法,其特征在于,若所述图片格非矩形,所述基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序包括:
    按照所述图片格的外接矩形的横纵比的预定次序对各所述图片格进行排序。
  5. 如权利要求1所述的图片处理方法,其特征在于,所述预定次序为降序排列。
  6. 如权利要求1-5任意一项所述的图片处理方法,其特征在于,
    所述图片的横纵比包括所述图片的宽度与高度的比值,
    所述图片格的横纵比包括所述图片格的宽度与高度的比值,所述宽度与所述高度以厘米为单位。
  7. 如权利要求1-5任意一项所述的图片处理方法,其特征在于,若各所述图片中存在描述所述图片尺寸的尺寸比值相同的目标图片,则以在选取预定数量的图片的步骤中所述目标图片的被选中的先后顺序为优先级优先为各所述目标图片中排序在前的目标图片分配与所述目标图片的预定次序相一致的图片格。
  8. 如权利要求1-5任意一项所述的图片处理方法,其特征在于,若与所述最小裁剪量对应的目标模板为多个,则以各所述目标模板构成第二模板集合,根据预设优先级从所述第二模板集合中选取一个优先级最高的目标模板作为最优的用于所述预定数量的图片的目标模板。
  9. 如权利要求1-5任意一项所述的图片处理方法,其特征在于,所述计算模板的裁剪量采用下式计算:
    Figure PCTCN2020135761-appb-100001
    Figure PCTCN2020135761-appb-100002
    其中,C k为第k个模板的总的裁剪量,C ki为第k个模板的第i个图片格中装入的第i个图片的裁剪量,r i为描述第i个图片的大小的尺寸比值,r ki为描述所述第k个模板的装入第i个图片的第i个图片格的尺寸比值。
  10. 如权利要求1-5任意一项所述的图片处理方法,其特征在于,在确定所述目标模板后,依照所述预定次序将各所述图片对应的装入预定次序相同的图片格中,完成各所述图片的拼图处理。
  11. 一种图片处理装置,其特征在于,包括:
    选取模块,用于选取预定数量的图片;
    确定模块,用于基于所述预定数量确定第一模板集合,所述第一模板集合包括多个用于所述预定数量的图片的模板,每个模板包括所述预定数量个用于容纳图片的图片格;
    第一排序模块,用于基于描述所述图片尺寸的尺寸比值的预定次序对所述预定数量的图片进行排序;
    第二排序模块,用于对于所述第一模板集合中的每个所述模板,基于描述所述图片格大小的尺寸比值的所述预定次序对所述预定数量的图片格进行排序;
    计算模块,用于对于所述第一模板集合中的每个所述模板,计算每个所述模板的裁剪量,所述模板的裁剪量是依照所述预定次序将每张图片对应地装入预定次序相同的图片格中所需的裁剪量的总和;
    选定模块,用于从所述第一模板集合中,选定所述裁剪量最小的模板作为用于所述预定数量的图片的目标模板。
  12. 一种电子设备,其特征在于,包括:
    存储器,所述存储器用于存储处理程序;
    处理器,所述处理器执行所述处理程序时实现如权利要求1-10任意一项所述的图 像处理方法的步骤。
  13. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有处理程序,所述处理程序被处理器执行时实现如权利要求1-10任意一项所述的图像处理方法的步骤。
PCT/CN2020/135761 2019-12-17 2020-12-11 一种图片处理方法、装置、电子设备及存储介质 WO2021121162A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP20902823.2A EP4040376B1 (en) 2019-12-17 2020-12-11 Picture processing method and apparatus, and electronic device and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911304930.5A CN111008933B (zh) 2019-12-17 2019-12-17 一种图片处理方法、装置、电子设备及存储介质
CN201911304930.5 2019-12-17

Publications (1)

Publication Number Publication Date
WO2021121162A1 true WO2021121162A1 (zh) 2021-06-24

Family

ID=70116409

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/135761 WO2021121162A1 (zh) 2019-12-17 2020-12-11 一种图片处理方法、装置、电子设备及存储介质

Country Status (3)

Country Link
EP (1) EP4040376B1 (zh)
CN (1) CN111008933B (zh)
WO (1) WO2021121162A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111008933B (zh) * 2019-12-17 2022-07-12 荣耀终端有限公司 一种图片处理方法、装置、电子设备及存储介质
CN112667835A (zh) * 2020-12-23 2021-04-16 北京达佳互联信息技术有限公司 作品处理方法、装置、电子设备及存储介质
CN114564131B (zh) * 2022-03-01 2024-03-12 抖音视界有限公司 一种内容发布方法、装置、计算机设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160267634A1 (en) * 2015-03-12 2016-09-15 Line Corporation Methods, systems and computer-readable mediums for efficient creation of image collages
CN107330858A (zh) * 2017-06-30 2017-11-07 北京金山安全软件有限公司 一种图片处理方法、装置、电子设备及存储介质
CN107705251A (zh) * 2017-09-21 2018-02-16 努比亚技术有限公司 图片拼接方法、移动终端及计算机可读存储介质
CN107798655A (zh) * 2017-10-19 2018-03-13 佛山市章扬科技有限公司 一种图片处理方法
CN109064526A (zh) * 2018-06-07 2018-12-21 珠海格力电器股份有限公司 一种生成拼图的方法及装置
CN111008933A (zh) * 2019-12-17 2020-04-14 华为技术有限公司 一种图片处理方法、装置、电子设备及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9152292B2 (en) * 2009-02-05 2015-10-06 Hewlett-Packard Development Company, L.P. Image collage authoring
US8180178B2 (en) * 2009-06-24 2012-05-15 Hewlett-Packard Development Company, L.P. Autocropping and autolayout method for digital images
EP2555165B1 (en) * 2011-08-04 2020-04-15 Samsung Electronics Co., Ltd. Method and device for packing multiple images
CN102930523B (zh) * 2012-11-12 2015-09-23 北京奇虎科技有限公司 图片处理***和图片拼接实现方法
CN105046678B (zh) * 2012-11-12 2018-05-18 北京奇虎科技有限公司 一种实现图片拼接的装置、方法和图片处理***

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160267634A1 (en) * 2015-03-12 2016-09-15 Line Corporation Methods, systems and computer-readable mediums for efficient creation of image collages
CN107330858A (zh) * 2017-06-30 2017-11-07 北京金山安全软件有限公司 一种图片处理方法、装置、电子设备及存储介质
CN107705251A (zh) * 2017-09-21 2018-02-16 努比亚技术有限公司 图片拼接方法、移动终端及计算机可读存储介质
CN107798655A (zh) * 2017-10-19 2018-03-13 佛山市章扬科技有限公司 一种图片处理方法
CN109064526A (zh) * 2018-06-07 2018-12-21 珠海格力电器股份有限公司 一种生成拼图的方法及装置
CN111008933A (zh) * 2019-12-17 2020-04-14 华为技术有限公司 一种图片处理方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
EP4040376A1 (en) 2022-08-10
EP4040376A4 (en) 2022-12-21
CN111008933A (zh) 2020-04-14
EP4040376B1 (en) 2023-11-08
CN111008933B (zh) 2022-07-12

Similar Documents

Publication Publication Date Title
WO2021121162A1 (zh) 一种图片处理方法、装置、电子设备及存储介质
CN107395958B (zh) 一种图像处理方法、装置、电子设备及存储介质
CN106464755A (zh) 自动调整摄像头的方法和电子设备
WO2019222889A1 (zh) 一种图像特征提取方法及装置
CN108921856B (zh) 图像裁剪方法、装置、电子设备及计算机可读存储介质
US10621428B1 (en) Layout analysis on image
CN107610046A (zh) 背景虚化方法、装置及***
CN110221722B (zh) 图片处理方法、电子设备及存储介质
CN111357034A (zh) 点云生成方法、***和计算机存储介质
CN103079016B (zh) 一种拍照脸型变换方法及智能终端
CN111523642B (zh) 用于卷积运算的数据重用方法、运算方法及装置、芯片
CN109791703B (zh) 基于二维媒体内容生成三维用户体验
US20150131891A1 (en) Method for detecting defect in pattern
CN110673944A (zh) 执行任务的方法和装置
CN108769419A (zh) 拍照方法、移动终端及计算机可读存储介质
WO2022048414A1 (zh) 一种图像生成方法、装置、设备及存储介质
CN110264546B (zh) 图像合成的方法、装置、计算机可读存储介质及终端
US20180176532A1 (en) Systems and methods for computational zoom
CN106354381B (zh) 图像文件的处理方法及装置
WO2023151386A1 (zh) 数据处理方法、装置、终端和可读存储介质
CN109871939B (zh) 一种图像处理方法及图像处理装置
WO2023109086A1 (zh) 文字识别方法、装置、设备及存储介质
TW202125402A (zh) 圖像處理方法、圖像處理設備及儲存介質
US20180144521A1 (en) Geometric Work Scheduling of Irregularly Shaped Work Items
CN112348069B (zh) 数据增强方法、装置、计算机可读存储介质及终端设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20902823

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020902823

Country of ref document: EP

Effective date: 20220502

NENP Non-entry into the national phase

Ref country code: DE