Image cropping method, device, electronic device and storage medium
By over-segmenting and aesthetically cropping the image, the problem of ignoring the beauty of image details in the existing technology is solved, and a partial cropped image with aesthetics is generated, which improves the accuracy and beauty of cropping.
Patent Information
- Application Number
- CN202110205952.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-24
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-02-24
AI Technical Summary
The existing technology ignores the beauty of the details of the original image during the image cropping process, resulting in a waste of shooting resources and the cropping result is not beautiful enough.
By over-segmenting the image to be processed into multiple sub-regions, the cropping regions are determined, and each region is cropped, scored and sorted according to the image aesthetics algorithm, and the cropping results are finally output with a preset number of rankings.
Fully explore image details and generate aesthetically pleasing partial cropping images, which improves cropping accuracy and aesthetics and reduces resource waste.
Smart Images

Figure CN112884781B
Abstract
Description
Technical Field
[0001] The present application generally relates to the field of image processing technology, and specifically relates to an image cropping method, device, electronic device and storage medium. Background Art
[0002] In the process of image editing and application, it is often necessary to crop images. For example, for images with weak composition, you can crop the surrounding borders to make the subject in the image meet the composition rules of photography and be more aesthetic.
[0003] At present, the related technology crops a small amount of the border of the original image and outputs an overall cropped image with little difference in content from the original image, while ignoring the beauty of the details of the original image, resulting in a waste of shooting resources. Summary of the invention
[0004] In view of the above-mentioned defects or deficiencies in the related art, it is desired to provide an image cropping method, device, electronic device and storage medium that can fully explore the details of the original image and generate a corresponding aesthetically pleasing cropped image.
[0005] In a first aspect, the present application provides an image cropping method, the method comprising:
[0006] Over-segmenting the image to be processed to obtain at least two over-segmented sub-regions;
[0007] Determining a cropping location according to the over-segmented sub-region;
[0008] Performing cropping on each of the cropping locations to obtain a cropping result corresponding to each of the cropping locations;
[0009] Scoring and ranking each of the cropping results;
[0010] Outputting the cropping images corresponding to the cropping results whose rankings are within a preset number range according to the scores.
[0011] Optionally, in some embodiments of the present application, determining the cropping location according to the over-segmented sub-region includes:
[0012] Calculating the centroid of each of the over-segmented sub-regions respectively;
[0013] According to the preset shape and / or scale parameters, an area extending around the center of gravity to form the preset shape and / or scale is obtained as the cutting location.
[0014] Optionally, in some embodiments of the present application, based on multiple different preset shapes and / or scale parameters preset for the same center of gravity, multiple trimming locations with different shapes and / or scales based on the same center of gravity are obtained.
[0015] Optionally, in some embodiments of the present application, it also includes:
[0016] Each of the cropping locations is cropped according to an image aesthetic cropping algorithm to obtain a cropping result corresponding to each of the cropping locations.
[0017] Optionally, in some embodiments of the present application, after obtaining the score of each of the cropping results, the process further includes:
[0018] Calculate the intersection-and-union ratio between all cropping results;
[0019] When the intersection-over-union ratio is greater than a preset threshold, the cropping result with the lowest score among the two cropping results is deleted.
[0020] In a second aspect, the present application provides an image cropping device, the device comprising:
[0021] An over-segmentation module is configured to over-segment the image to be processed to obtain at least two over-segmented sub-regions;
[0022] A determination module, configured to determine a cropping location according to the over-segmented sub-region;
[0023] A cropping module, configured to crop each of the cropping locations to obtain a cropping result corresponding to each of the cropping locations;
[0024] A scoring module configured to score and sort each of the cropping results;
[0025] The output module is configured to output the cropping images corresponding to the cropping results whose rankings are within a preset number range according to the scores.
[0026] Optionally, in some embodiments of the present application, the determining module includes:
[0027] A first calculation unit, configured to calculate the centroid of each of the over-segmented sub-regions respectively;
[0028] The acquisition unit is configured to acquire, according to preset shape and / or scale parameters, an area extending around the center of gravity to form a preset shape and / or scale as the cropping location.
[0029] Optionally, in some embodiments of the present application, the acquisition unit is further configured to acquire multiple trimming locations with different shapes and / or scales based on the same center of gravity based on multiple different preset shapes and / or scale parameters preset for the same center of gravity.
[0030] Optionally, in some embodiments of the present application, the cropping module is further configured to crop each of the cropping locations according to an image aesthetic cropping algorithm to obtain a cropping result corresponding to each of the cropping locations.
[0031] Optionally, in some embodiments of the present application, the scoring module further includes:
[0032] A second calculation unit is configured to calculate the intersection-and-union ratio between all cropping results;
[0033] The deleting unit is configured to delete the lowest-scoring cropping result of the two cropping results when the intersection-over-union ratio is greater than a preset threshold.
[0034] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the instruction, the program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the image cropping method as described in any one of the first aspects.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the image cropping method as described in any one of the first aspects.
[0036] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0037] The embodiment of the present application provides an image cropping method, device, electronic device and storage medium, which over-segments the image to be processed into at least two over-segmented sub-regions, and performs cropping according to the cropping positions determined by each over-segmented sub-region, and scores and ranks each cropping result, and then outputs a cropping image corresponding to the cropping result whose ranking is within a preset number range. The embodiment of the present application can fully explore the details of the image to be processed by decomposing the image to be processed, thereby generating an aesthetically pleasing local cropping image. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0039] Figure 1 A schematic diagram of a basic process of an image cropping method provided in an embodiment of the present application;
[0040] Figure 2 A schematic diagram of determining a cropping location provided in an embodiment of the present application;
[0041] Figure 3 A schematic diagram of another method for determining a cropping location provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of another method for determining a cropping location provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of another method for determining a cropping location provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of determining a cropping location provided in another embodiment of the present application;
[0045] Figure 7 A schematic diagram of another method for determining a cropping location provided in another embodiment of the present application;
[0046] Figure 8 A schematic diagram of another method for determining a cropping location provided in another embodiment of the present application;
[0047] Fig. 9 A schematic diagram showing a cutting diagram provided in an embodiment of the present application;
[0048] Fig.10 A schematic diagram of the structure of an image cropping device provided in an embodiment of the present application;
[0049] Fig.11 A schematic diagram of the structure of another image cropping device provided in an embodiment of the present application;
[0050] Fig.12 A schematic diagram of the structure of another image cropping device provided in an embodiment of the present application;
[0051] Fig.13 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0053] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the application described can be implemented in an order other than those illustrated or described herein.
[0054] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0055] For ease of understanding and explanation, the following Figures 1 to 13 The image cropping method, device, electronic device and storage medium provided by the embodiments of the present application are described in detail.
[0056] Please refer to Figure 1 , which is a basic flow chart of an image cropping method provided in an embodiment of the present application. The method comprises the following steps:
[0057] S101, over-segmenting the image to be processed to obtain at least two over-segmented sub-regions.
[0058] Exemplarily, the embodiment of the present application divides the image to be processed into at least two over-segmented sub-regions through an image over-segmentation algorithm, wherein the image features (such as color, spatial texture, and geometric shape, etc.) in the same over-segmented sub-region have appearance consistency or similarity, while showing obvious differences between different over-segmented sub-regions. The advantage of such a setting is that it can avoid forcibly splitting the components of the image to be processed, such as dividing the same building as a component into two sub-regions, thereby affecting the accuracy of cropping. Optionally, the image over-segmentation algorithm in the embodiment of the present application may include but is not limited to any one of a graph-based image segmentation algorithm, a simple linear iterative clustering (SLIC) algorithm, or a watershed algorithm.
[0059] S102: Determine a cropping location according to the over-segmented sub-region.
[0060] For example, the embodiment of the present application first calculates the centroid O of each over-segmented sub-region respectively; then, according to the preset shape and / or scale parameters, obtains the region extending around the centroid O to form a preset shape and / or scale as the cropping location. Figure 2 As shown, the dotted line represents the boundary of the over-segmented sub-region, and the black dot represents the center of gravity O. Since the sum of the pixel values on the left and right sides of the center of gravity O is equal, and the sum of the pixel values on the upper and lower sides is also equal, the over-segmented sub-region can be evenly divided according to the center of gravity O, further improving the cropping accuracy, while also narrowing the search range, and improving the automatic cropping speed and processing efficiency. For example, the embodiment of the present application calculates the center of gravity O of the over-segmented sub-region through equations (1) and (2), that is:
[0061]
[0062]
[0063] Among them, the coordinates of pixel i in the over-segmented sub-region are (x i ,y i ), the pixel value of pixel i is p i , the coordinates of the center of gravity O are (x, y).
[0064] The following is a detailed description of the process of determining the cutting location based on the center of gravity O.
[0065] The first method is to obtain, according to a preset shape, an area extending from the center of gravity O to the surrounding area to form a preset shape as a cutting position.
[0066] It should be noted that the preset shape may include but is not limited to any one of a polygon or a circle, wherein the polygon may include but is not limited to a triangle, a quadrilateral or a pentagon, etc., and the circle may include but is not limited to a perfect circle or an ellipse, etc.
[0067] For example, Figure 3 As shown, the center of gravity O is used as the inner center point, and the area A1 of a preset shape is extended to the periphery, and the shape of the area A1 is a triangle. Figure 4 As shown, the center of gravity O is used as the inner center point, and the area A2 and the area A3 of the preset shape are extended to the surroundings. Figure 4 It can be seen that area A2 and area A3 are distributed in a ring shape. Optionally, the preset shapes of each area may be different, for example Figure 4The shape of the middle area A2 is an ellipse, and the shape of the area A3 is a quadrilateral. In this case, the embodiment of the present application can obtain multiple clipping locations with the same center of gravity O as the inner center and different shapes from each other according to multiple different preset shapes preset for the same center of gravity O. Alternatively, the preset shapes of each area can also be the same. In this case, the embodiment of the present application can obtain multiple clipping locations with the same center of gravity O as the inner center and the same shapes from multiple identical preset shapes preset for the same center of gravity O.
[0068] Another example Figure 5 As shown, the center of gravity O is used as the outer center point, and the area A4 and the area A5 of the preset shape are extended to the periphery. Figure 5 It can be seen that area A4 and area A5 are distributed around the center of gravity O, and at this time, the distance OP1 from the center of gravity O to the center point P1 of area A4 is equal to the distance OP2 from the center of gravity O to the center point P2 of area A5. Similarly, the preset shapes of each area may be different. In this case, the embodiment of the present application can obtain multiple trimming locations with the same center of gravity O as the outer center and different shapes from each other based on multiple different preset shapes preset for the same center of gravity O. Alternatively, the preset shapes of each area may also be the same. In this case, the embodiment of the present application can obtain multiple trimming locations with the same center of gravity O as the outer center and the same shape from each other based on multiple identical preset shapes preset for the same center of gravity O.
[0069] The second method is to obtain, according to a preset scale parameter, an area of preset scale extending from the center of gravity O as a reference and surrounding area as a cropping location.
[0070] For example, it is assumed that the scale parameter includes the extension direction and the proportional relationship between the extension lengths corresponding to the extension directions, such as Figure 6 As shown, with the vertical line l as a reference and the center of gravity O as the starting point, the lines are extended to 30 degrees, 150 degrees, 210 degrees and 330 degrees respectively to obtain line segments OM1, OM2, OM3 and OM4, and then the area formed by connecting points M1, M2, M3 and M4 in sequence is used as the cutting location. Further, taking line segment M1M3 as an example, the line segment M2M4 is similar. If OM1 / OM3=0.618, the center of gravity O is the golden ratio segmentation point of line segment M1M3, and if OM1 / OM3=1, the center of gravity O is the midpoint of line segment M1M3.
[0071] For example Figure 7 As shown, it is assumed that the scale parameter also includes the distance and direction between the extension point N and the center of gravity O of multiple regions, where the distance is a number greater than or equal to 0. The distances corresponding to each region can be equal or unequal. It should be noted that the formation process of each region is different from Figure 6The formation process shown in the figure is the same in principle and will not be described again here. Optionally, the preset scale parameters of each area are different. In this case, the embodiment of the present application can obtain multiple clipping locations with different scales based on the same center of gravity O according to multiple different preset scale parameters preset for the same center of gravity O.
[0072] In a third method, according to preset shape and scale parameters, an area with a preset shape and scale extending around the center of gravity O is obtained as a cropping location.
[0073] For example, assuming that the preset shape is a rectangle, the center of gravity O is the inner center point, such as Figure 8 As shown, the length and width of the scale parameters corresponding to the rectangular area ① are both 45 mm, the length and width of the scale parameters corresponding to the rectangular area ② are both 90 mm, and the length and width of the scale parameters corresponding to the rectangular area ③ are both 135 mm. Optionally, in some embodiments of the present application, the preset shapes and scale parameters of each area may be different. In this case, according to the multiple different preset shapes and scale parameters preset for the same center of gravity O, multiple cutting locations with different shapes and scales based on the same center of gravity O are obtained.
[0074] Furthermore, after all cropping locations are obtained, these cropping locations are added to the candidate cropping location list, thereby narrowing the search range and improving processing efficiency. In some optional embodiments of the present application, the complete image area to be processed can also be added to the candidate cropping location list to ensure that an aesthetically pleasing image can be cropped.
[0075] S103, performing cropping on each cropping location to obtain a cropping result corresponding to each cropping location.
[0076] For example, on the image to be processed, the embodiment of the present application can crop each cropping location according to the image aesthetic cropping algorithm to obtain a cropping result corresponding to each cropping location. The advantage of such a setting is that the details of the image to be processed can be fully explored, thereby generating an aesthetically pleasing local cropping image.
[0077] It should be noted that the cropping operation for each cropping position in the embodiment of the present application can be performed sequentially or simultaneously, thereby improving processing efficiency. Optionally, the image aesthetic cropping algorithm in the embodiment of the present application may include but is not limited to any one of a rule-based cropping algorithm or an end-to-end algorithm based on deep learning. For example, the rule-based cropping algorithm introduces photographic composition rules. After detecting and identifying relevant composition elements, the photographic composition rules are used as constraints to search for the optimal cropping method. Another example is an end-to-end algorithm based on deep learning. Through a large amount of pre-labeled image cropping data, a deep neural network model is trained, and the deep neural network model is used to crop images.
[0078] S104, scoring and ranking each cropping result.
[0079] Exemplarily, the embodiment of the present application may use an image aesthetic evaluation algorithm to score and sort each cropping result. It should be noted that the image aesthetic evaluation algorithm in the embodiment of the present application may include but is not limited to any one of a support vector machine (SVM) or a neural network model.
[0080] Optionally, after obtaining the score of each cropping result, some embodiments of the present application may also use a non-maximum suppression (NMS) algorithm to calculate the intersection over union (IoU) between all cropping results to filter out cropping results with too large overlapping areas. For example, when the IoU is greater than a preset threshold, the cropping result with the lowest score among the two cropping results is deleted.
[0081] S105: Outputting cropping images corresponding to cropping results whose rankings are within a preset number range according to the scores.
[0082] For example, assuming that K represents a preset number, the corresponding area in the image to be processed is cropped according to the coordinates of the first K cropping results, and then the cropped image is output. In actual use, the user only needs to input an original image to be processed through an electronic device, and can quickly and easily obtain multiple aesthetically pleasing cropped images. Fig. 9 As shown, after the automatic cropping is completed, the cropped images ranked in the top 4 are displayed simultaneously with the image to be processed.
[0083] The embodiment of the present application provides an image cropping method, which over-segments an image to be processed into at least two over-segmented sub-regions, performs cropping according to the cropping locations determined by each over-segmented sub-region, and scores and ranks each cropping result, thereby outputting a cropping image corresponding to the cropping result whose ranking is within a preset number range. The embodiment of the present application can fully explore the details of the image to be processed by decomposing the image to be processed, thereby generating an aesthetically pleasing local cropping image.
[0084] Based on the above examples, please refer to Fig.10 , which is a structural schematic diagram of an image cropping device provided in an embodiment of the present application, the device can be applied to Figures 1 to 9 In the image cropping method provided in the corresponding embodiment. Fig.10 As shown, the image cropping device 100 includes:
[0085] An over-segmentation module 101 is configured to over-segment the image to be processed to obtain at least two over-segmented sub-regions;
[0086] A determination module 102, configured to determine a cropping location according to the over-segmented sub-region;
[0087] A cropping module 103 is configured to crop each cropping location to obtain a cropping result corresponding to each cropping location;
[0088] A scoring module 104, configured to score and sort each cropping result;
[0089] The output module 105 is configured to output the cropping images corresponding to the cropping results whose rankings are within a preset number range according to the scores.
[0090] Optionally, in some embodiments of the present application, Fig.11 As shown, the determination module 102 includes:
[0091] A first calculation unit 1021 is configured to calculate the centroid of each over-segmented sub-region respectively;
[0092] The acquisition unit 1022 is configured to acquire, according to the preset shape and / or scale parameters, an area extending from the center of gravity to the surrounding area to form a preset shape and / or scale as a cropping location.
[0093] Optionally, in some embodiments of the present application, the acquisition unit 1022 is further configured to acquire multiple clipping locations with the same center of gravity as a reference and different shapes and / or scales from each other based on multiple different preset shapes and / or scale parameters preset for the same center of gravity.
[0094] Optionally, in some embodiments of the present application, the cropping module 103 is further configured to crop each cropping location according to an image aesthetic cropping algorithm to obtain a cropping result corresponding to each cropping location.
[0095] Optionally, in some embodiments of the present application, Fig.12 As shown, the scoring module 104 also includes:
[0096] The second calculation unit 1041 is configured to calculate the intersection-and-union ratios between all the cropping results;
[0097] The deleting unit 1042 is configured to delete the cropping result with the lowest score among the two cropping results when the intersection-over-union ratio is greater than a preset threshold.
[0098] It should be noted that, for the description of the same steps and the same contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.
[0099] The embodiment of the present application provides an image cropping device, in which an over-segmentation module is used to over-segment an image to be processed to obtain at least two over-segmented sub-regions; a determination module is used to determine a cropping location according to the over-segmented sub-regions; a cropping module is used to crop each cropping location to obtain a cropping result corresponding to each cropping location; a scoring module is used to score and sort each cropping result; and an output module is used to output a cropping image corresponding to the cropping result whose ranking is within a preset number range according to the score. The embodiment of the present application can fully explore the details of the image to be processed by decomposing the image to be processed, thereby generating an aesthetically pleasing local cropping image.
[0100] Based on the above examples, please refer to Fig.13 , which is a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 200 includes a processor 2001 and a memory 2002, wherein the processor 2001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 2001 may be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA).
[0101] The processor 2001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state.
[0102] In addition, the processor 2001 may be integrated with a graphics processing unit (GPU), which is used to render and draw the content to be displayed on the display screen. In some embodiments, the processor 2001 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0103] The memory 2002 may include one or more computer-readable storage media, which may be non-transitory. The memory 2002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 2002 is used to store at least one program, which is used to be executed by the processor 2001 to implement the steps of the image cropping method provided in the method embodiment of the present application.
[0104] In some embodiments, the electronic device 200 may further include a peripheral device interface 2003 and at least one peripheral device. The processor 2001, the memory 2002 and the peripheral device interface 2003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 2003 via a bus, a signal line or a circuit board.
[0105] Specifically, the peripheral devices include but are not limited to the radio frequency circuit 2004, the touch display screen 2005 and the power supply 2006. The peripheral device interface 2003 can be used to connect at least one peripheral device related to input / output (I / O) to the processor 2001 and the memory 2002. In some embodiments, the processor 2001, the memory 2002 and the peripheral device interface 2003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 2001, the memory 2002 and the peripheral device interface 2003 can be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.
[0106] The radio frequency circuit 2004 is used to receive and transmit radio frequency (RF) signals, also known as electromagnetic signals. The radio frequency circuit 2004 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 2004 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 2004 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 2004 can communicate with other devices through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a wireless fidelity (Wireless Fidelity, WiFi) network. In some embodiments, the radio frequency circuit 2004 may also include circuits related to near field communication (NFC).
[0107] The display screen 2005 is used to display a user interface (UI). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 2005 is a touch display screen, the display screen 2005 also has the ability to collect touch signals on the surface or above the surface of the display screen 2005. The touch signal can be input to the processor 2001 as a control signal for processing. At this time, the display screen 2005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 2005 can be one, set on the front panel of the electronic device 200; in other embodiments, the display screen 2005 can be at least two, respectively set on different surfaces of the electronic device 200 or in a folding design; in some other embodiments, the display screen 2005 can be a flexible display screen, set on the curved surface or folding surface of the electronic device 200. Even, the display screen 2005 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 2005 can be made of materials such as a liquid crystal display (LCD) and an organic light-emitting diode (OLED).
[0108] Those skilled in the art will understand that Fig.13 The structure shown in the figure does not constitute a limitation on the electronic device 200, and may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0109] It should be noted that the electronic device 200 involved in the embodiments of the present application may include but is not limited to a personal digital assistant (PDA), a tablet computer, a wireless handheld device, a mobile phone, etc.
[0110] As another aspect, an embodiment of the present application provides a computer-readable storage medium for storing program code, where the program code is used to execute any one of the image cropping methods of the aforementioned embodiments.
[0111] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0112] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms. The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0113] In addition, each functional module in each embodiment of the present application may be integrated into a processing unit, or each module may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.
[0114] Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the whole or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the image cropping method of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0115] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image cropping method, characterized in that: The method comprises: Over-segmenting the image to be processed to obtain at least two over-segmented sub-regions; Determining a cropping location according to the over-segmented sub-region; Performing cropping on each of the cropping locations to obtain a cropping result corresponding to each of the cropping locations; Scoring and ranking each of the cropping results; Outputting, according to the score, cropping images corresponding to cropping results whose rankings are within a preset number range; The determining the cropping location according to the over-segmented sub-region comprises: Calculating the centroid of each of the over-segmented sub-regions respectively; According to the preset shape and / or scale parameters, an area extending from the center of gravity to the surrounding area to form the preset shape and / or scale is obtained as the cropping location, and the over-segmented sub-areas can be evenly divided according to the center of gravity, and the sum of the pixel values on the left and right sides of the center of gravity is equal, and the sum of the pixel values on the upper and lower sides of the center of gravity is equal; The image features in the same over-segmented sub-region have appearance consistency or similarity, and the image features are different between different over-segmented sub-regions. The image features include any one of the following: color, spatial texture, and geometric shape.
2. The image cropping method according to claim 1, wherein: According to a plurality of different preset shapes and / or scale parameters preset for the same center of gravity, a plurality of cutting locations with the same center of gravity as a reference and having different shapes and / or scales are obtained.
3. The image cropping method according to claim 1 or 2, further comprising: Each of the cropping locations is cropped according to an image aesthetic cropping algorithm to obtain a cropping result corresponding to each of the cropping locations.
4. The image cropping method according to claim 1, after obtaining the score of each cropping result, further comprising: Calculate the intersection-and-union ratio between all cropping results; When the intersection-over-union ratio is greater than a preset threshold, the cropping result with the lowest score among the two cropping results is deleted.
5. An image cropping device, characterized in that: The device comprises: An over-segmentation module is configured to over-segment the image to be processed to obtain at least two over-segmented sub-regions; A determination module, configured to determine a cropping location according to the over-segmented sub-region; A cropping module, configured to crop each of the cropping locations to obtain a cropping result corresponding to each of the cropping locations; A scoring module configured to score and sort each of the cropping results; An output module configured to output, according to the score, cropping images corresponding to cropping results whose rankings are within a preset number range; The determination module comprises: A first calculation unit, configured to calculate the centroid of each of the over-segmented sub-regions respectively; an acquisition unit configured to acquire, according to a preset shape and / or scale parameter, an area extending from the center of gravity to the surrounding area to form a preset shape and / or scale as the cropping location, wherein the over-segmented sub-areas can be evenly divided according to the center of gravity, and the sum of the pixel values on the left and right sides of the center of gravity is equal, and the sum of the pixel values on the upper and lower sides of the center of gravity is equal; The image features in the same over-segmented sub-region have appearance consistency or similarity, and the image features are different between different over-segmented sub-regions. The image features include any one of the following: color, spatial texture, and geometric shape.
6. The image cropping device according to claim 5, wherein: The acquisition unit is further configured to acquire, based on a plurality of different preset shapes and / or scale parameters preset for the same center of gravity, a plurality of clipping locations with different shapes and / or scales based on the same center of gravity.
7. The image cropping device according to claim 5 or 6, wherein: The cropping module is also configured to crop each of the cropping locations according to an image aesthetic cropping algorithm to obtain a cropping result corresponding to each of the cropping locations.
8. The image cropping device according to claim 5, wherein: The scoring module also includes: A second calculation unit is configured to calculate the intersection-and-union ratio between all cropping results; The deleting unit is configured to delete the lowest-scoring cropping result of the two cropping results when the intersection-over-union ratio is greater than a preset threshold.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the instruction, the program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the image cropping method as described in any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the image cropping method according to any one of claims 1 to 4.
