Image cutting method, device and storage medium
By determining the center point coordinates of the image to be cropped and the cropped box in the image cropping technique, enlarging the image to include the cropping box, and processing the cropping box to obtain a new cropping box, the problems of inflexible cropping and display errors in the prior art are solved, and the user experience is improved.
Patent Information
- Application Number
- CN202210234088.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-10
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-03-10
AI Technical Summary
The prior art lacks flexibility in the image cropping process, and it is impossible to effectively select the area that the user wants for cropping, and the rebound operation may lead to display errors and reduce user experience.
By determining the coordinates of the center point of the image to be cropped and the cropping box, obtaining the shortest distance from the center point of the cropping box to the edge of the image, determining the target edge, enlarge the image to include the cropping box, obtaining the image editing configuration, processing the cropping box to obtain a new cropping box, and cropping the image based on the cropping box.
It realizes flexible transformation of the cropping box, avoids the problem of display errors, enables users to effectively observe the relationship between the area to be cropped and the overall image, and improves the user experience.
Smart Images

Figure CN114612485B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image cropping method, device and storage medium. Background Art
[0002] With the popularity of mobile phones, people use mobile phone cameras to take pictures more and more frequently and edit the images they take. In order to obtain a specific area in an image, it is necessary to use image cropping technology to crop the image, but the existing technology has many restrictions on image cropping and cannot flexibly select the area the user wants and crop it. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides an image cropping method, device and storage medium. The technical solution of the present disclosure is as follows:
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image cropping method, characterized by comprising:
[0005] Determine the coordinates of the first image to be cropped and the center point of the first cropping frame;
[0006] Obtaining the shortest first distance from the center point of the first cropping frame to the edge of the first image to be cropped, and determining that an edge corresponding to the first distance is a first target edge;
[0007] Enlarging the first image to be cropped, acquiring a second image to be cropped and a second target edge, wherein an edge on the second image to be cropped corresponding to the first target edge is the second target edge, and a range of the second image to be cropped is larger than the first cropping frame;
[0008] Acquire an image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge;
[0009] Processing the first cropping frame according to the image editing configuration to obtain a second cropping frame;
[0010] The first image to be cropped is cropped according to the second cropping frame.
[0011] Optionally, the image editing configuration includes at least one of the following:
[0012] Translation direction;
[0013] Translation distance;
[0014] Scaling ratio.
[0015] Optionally, acquiring the image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge includes:
[0016] Obtain a second distance from the center point of the first cropping frame to the second target edge;
[0017] Acquire the scaling ratio according to the first distance and the second distance;
[0018] The translation distance and the translation direction are determined according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame.
[0019] Optionally, the processing the first cropping frame according to the image editing configuration to obtain a second cropping frame specifically includes:
[0020] Moving the first cropping frame according to the translation distance and the translation direction, and scaling the first cropping frame according to the scaling ratio to obtain a second cropping frame;
[0021] The second cropping frame and the first image to be cropped are moved so that a center point of the first image to be cropped coincides with a center point of the screen, wherein a relative position of the second cropping frame and the first image to be cropped remains unchanged.
[0022] Optionally, the center point of the image to be cropped is the center point of the canvas of the image to be cropped.
[0023] Optionally, the center point of the image to be cropped is the center point of a key content area in the image to be cropped, wherein the step of obtaining the key content area includes: obtaining a content weight of the image to be cropped, and obtaining the key content area according to the content weight.
[0024] According to a second aspect of an embodiment of the present disclosure, there is provided an image cropping device, characterized in that it includes:
[0025] A coordinate determination module, used to determine the coordinates of the first image to be cropped and the center point of the first cropping frame;
[0026] a target edge determination module, configured to obtain a first shortest distance from a center point of the first cropping frame to an edge of a first image to be cropped, and determine an edge corresponding to the first distance as a first target edge;
[0027] an enlarging module, configured to enlarge the first image to be cropped, and obtain a second image to be cropped and a second target edge, wherein an edge on the second image to be cropped corresponding to the first target edge is the second target edge, and a range of the second image to be cropped is larger than the first cropping frame;
[0028] An editing configuration acquisition module, used to acquire an image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge and the second target edge;
[0029] A processing module, configured to process the first cropping frame according to the translation distance, the translation direction and the scaling ratio to obtain a second cropping frame;
[0030] A cropping module is used to crop the first image to be cropped according to the second cropping frame.
[0031] Optionally, the image editing configuration includes at least one of the following:
[0032] Translation direction;
[0033] Translation distance;
[0034] Scaling ratio.
[0035] Optionally, the editing configuration acquisition module includes:
[0036] A distance acquisition submodule, used to acquire a second distance from the center point of the first cropping frame to the second target edge;
[0037] A zoom ratio acquisition submodule, configured to acquire a zoom ratio according to the first distance and the second distance;
[0038] The translation parameter determination submodule is used to determine the translation distance and translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the second cropping frame.
[0039] Optionally, the processing module specifically includes:
[0040] A first processing submodule, configured to move the first cropping frame according to the translation distance and the translation direction, and scale the first cropping frame according to the scaling ratio to obtain a second cropping frame;
[0041] The second processing submodule is used to move the second cropping frame and the first image to be cropped so that the center point of the first image to be cropped coincides with the center point of the screen, wherein the relative positions of the second cropping frame and the first image to be cropped remain unchanged.
[0042] Optionally, the center point of the image to be cropped is the center point of the canvas of the image to be cropped.
[0043] Optionally, the center point of the image to be cropped is the center point of a key content area in the image to be cropped, wherein the step of obtaining the key content area includes: obtaining a content weight of the image to be cropped, and obtaining the key content area according to the content weight.
[0044] According to a third aspect of an embodiment of the present disclosure, there is provided an image cropping electronic device, characterized in that it includes:
[0045] processor;
[0046] a memory for storing instructions executable by the processor;
[0047] The processor is configured to execute the instructions to implement the image cropping method as described in any one of the first aspects above.
[0048] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an image cropping electronic device, the image cropping electronic device is enabled to perform an image cropping method as described in any one of the first aspects above.
[0049] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of the above-mentioned first aspects.
[0050] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0051] Through the embodiments of the present application, the first cropping frame is moved to the first image to be cropped by performing translation and rotation transformations, thereby avoiding the problem of display errors, allowing the user to effectively observe the relationship between the intercepted area to be cropped and the overall image to be cropped, thereby improving the user experience.
[0052] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0054] Figure 1 The figure is a flow chart of an image cropping method according to an exemplary embodiment.
[0055] Figure 2 The figure is a flow chart of an image cropping method according to an exemplary embodiment.
[0056] Figure 3 The figure is a flow chart of an image cropping method according to an exemplary embodiment.
[0057] Figure 4 The figure is a block diagram of an image cropping device according to an exemplary embodiment.
[0058] Figure 5 It is a block diagram of a device according to an exemplary embodiment.
[0059] Figure 6 It is a block diagram of a device according to an exemplary embodiment. DETAILED DESCRIPTION
[0060] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0061] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure 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 data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0062] In the related art, image cropping requires the use of a rectangular cropping frame to select the area to be cropped in the image to be cropped. The four sides of the cropping frame are parallel to the four sides of the mobile phone screen, and the cropping frame cannot be rotated. The user can only perform operations such as translation, zooming in, zooming out, and rotating the image to be cropped. And the cropping frame is zoomed in and out to select the area to be cropped. When the magnification of the image to be cropped is too large, resulting in a part of the image to be cropped being outside the screen display range, in order to allow the user to observe the entire image to be cropped, the prior art will simultaneously perform a rebound operation on the image to be cropped and the cropping frame, and the rebound is to simultaneously shrink the image to be cropped and the cropping frame. However, the rebound operation will cause a black area to appear on the mobile phone screen, which may cause display errors. And the user cannot effectively observe the relationship between the intercepted area to be cropped and the entire image to be cropped, which reduces the user's experience.
[0063] Figure 1 is a flow chart of an image cropping method according to an exemplary embodiment. Figure 1 As shown, the method is used in image cropping and includes the following steps.
[0064] In step 101, the coordinates of a first image to be cropped and a center point of a first cropping frame are determined.
[0065] In the embodiment of the present application, in order to enable the user to better observe the relationship between the area to be cropped and the first image to be cropped when taking a screenshot, it is necessary to scale the first image to be cropped and the first cropping frame. Since the user may not be accurate enough when translating and rotating the first image to be cropped by hand when taking a screenshot, in order to correct the user's operation error, the present application needs to scale the first image to be cropped to ensure that the first cropping frame is included in the range of the first image to be cropped. In order to obtain the scaling ratio, it is necessary to obtain the straight line equation of the edge of the first image to be cropped, the center point coordinates of the first image to be cropped, and the center point coordinates of the first cropping frame.
[0066] In step 102, the shortest first distance from the center point of the first cropping frame to the edge of the first image to be cropped is obtained, and the edge corresponding to the first distance is determined as the first target edge.
[0067] In the embodiment of the present application, a two-dimensional rectangular coordinate system is established with the center point of the first image to be cropped as the origin, and the distance from the center point of the first cropping frame to each edge of the first image to be cropped is calculated. Since the first image to be cropped needs to be enlarged to include the first cropping frame, the multiple required for enlargement needs to be calculated based on the shortest distance. Therefore, the shortest distance is selected as the first distance, and the edge corresponding to the first distance is determined as the first target edge.
[0068] In step 103, the first image to be cropped is enlarged to obtain a second image to be cropped and a second target edge, wherein the edge on the second image to be cropped corresponding to the first target edge is the second target edge, and the range of the second image to be cropped is larger than the first cropping frame.
[0069] In step 104, an image editing configuration is obtained according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge;
[0070] In the embodiment of the present application, firstly, the distance from the center point of the first cropping frame to the four sides of the first image to be cropped is obtained, and the shortest first distance and the first target side corresponding to the first distance are selected, and the first target side belongs to the first image to be cropped. The first image to be cropped is enlarged so that the range of the second image to be cropped obtained after enlargement is larger than the range of the first cropping frame, and the zoom factor of the second image to be cropped should not be too large, and the minimum zoom factor needs to be obtained. That is, the second image to be cropped can just cover the first cropping frame. At this time, the second distance from the second target side corresponding to the first target side to the center point of the first cropping frame is obtained. The second target side belongs to the second image to be cropped. The image editing configuration can be obtained according to the coordinates of the center point of the first cropping frame, the first target side and the second target side. The image editing configuration is used to process the first cropping frame so that the range of the first cropping frame after processing is smaller than the first image to be cropped, so as to avoid the user having difficulty in observing the relationship between the content in the cropping frame and the image to be cropped as a whole.
[0071] Optionally, the image editing configuration includes at least one of the following: translation direction; translation distance; scaling ratio.
[0072] In the embodiment of the present application, the image can be translated in a fixed direction on the screen by a certain distance according to the translation direction and the translation distance; the image can be proportionally enlarged or reduced on the screen according to the scaling ratio. The image editing configuration can be used to transform the image on a two-dimensional plane.
[0073] The zoom ratio can be obtained according to the first distance and the second distance, and the translation distance and the translation direction are determined according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame.
[0074] In step 105, the first cropping frame is processed according to the translation distance, translation direction and scaling ratio to obtain a second cropping frame.
[0075] In the embodiment of the present application, since the first image to be cropped is processed before, in actual processing, it is necessary to perform translation and rotation transformation on the first cropping frame according to the translation distance, translation direction and scaling ratio. The first cropping frame is reversely translated according to the translation distance and translation direction, and reversely scaled according to the scaling ratio, so that the second cropping frame can be obtained. At this time, the second cropping frame is within the range of the first image to be cropped and does not exceed the range of the first image to be cropped. Then, while keeping the relative positions of the second cropping frame and the first image to be cropped unchanged, the second cropping frame and the first image to be cropped are moved to the screen so that the first image to be cropped and the screen coincide, that is, the center point of the first image to be cropped coincides with the center point of the screen.
[0076] In step 106, the first image to be cropped is cropped according to the second cropping frame.
[0077] After the second to-be-cropped frame is obtained, the first to-be-cropped image can be cropped according to the second cropping frame to separate the area that the user needs to crop.
[0078] Through the embodiments of the present application, the cropping frame is transformed and moved to the first image to be cropped, thereby avoiding the problem of display errors, allowing the user to effectively observe the relationship between the intercepted area to be cropped and the overall image to be cropped, thereby improving the user experience. Figure 2 is a flow chart of an image cropping method according to an exemplary embodiment. Figure 2 As shown, the method is used in image cropping. Figure 1 Step 104 also includes the following steps.
[0079] In step 201, a second distance from the center point of the first cropping frame to the second target edge is obtained.
[0080] In the embodiment of the present application, after the first image to be cropped is enlarged, the second image to be cropped is obtained. The second image to be cropped can just cover the first cropping frame. The edge of the second image to be cropped corresponding to the first target edge is the second target edge. At this time, the scaling ratio can be calculated according to the second distance from the center point of the first cropping frame to the second target edge and the first distance.
[0081] In step 202, a scaling ratio is obtained according to the first distance and the second distance;
[0082] In the embodiment of the present application, the scaling ratio may be obtained by dividing the second distance by the first distance.
[0083] In step 203, the translation distance and the translation direction are determined according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame.
[0084] In the embodiment of the present application, the translation distance and translation direction of the center point of the first image to be cropped during the enlargement process can be obtained according to the image position algorithm.
[0085] Figure 3 is a flow chart of an image cropping method according to an exemplary embodiment. Figure 3 As shown, the method is used in image cropping. Figure 1 Step 105 includes the following steps.
[0086] In step 301, the first cropping frame is moved according to the translation distance and the translation direction, and the first cropping frame is scaled according to the scaling ratio to obtain a second cropping frame;
[0087] In the embodiment of the present application, the scaling ratio, translation distance and translation direction obtained in the previous step are the data required for processing the first image to be cropped. Since the first image to be cropped is the same size as the screen, in order to facilitate processing and reduce the amount of calculation for processing the image, in actual processing, it is necessary to perform translation and rotation transformations on the first cropping frame according to the translation distance, translation direction and scaling ratio. The first cropping frame is reversely translated according to the translation distance and translation direction, and reversely scaled according to the scaling ratio, so that the second cropping frame can be obtained.
[0088] In step 302, the second cropping frame and the first image to be cropped are moved so that the center point of the first image to be cropped coincides with the center point of the screen, wherein the relative positions of the second cropping frame and the first image to be cropped remain unchanged.
[0089] In the embodiment of the present application, after the first cropping frame is translated and scaled, the second cropping frame is within the range of the first image to be cropped and does not exceed the range of the first image to be cropped. Then, while keeping the relative positions of the second cropping frame and the first image to be cropped unchanged, the second cropping frame and the first image to be cropped are moved to the screen so that the first image to be cropped and the screen overlap, that is, the center point of the first image to be cropped and the center point of the screen overlap.
[0090] Optionally, the center point of the image to be cropped is the center point of the canvas of the image to be cropped.
[0091] In the embodiment of the present application, the center point may be the center point of the canvas of the image to be cropped, that is, the geometric center point. After determining the translation distance and the translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame, the second cropping frame obtained after processing the first cropping frame according to the translation distance and the translation direction is closer to the center point of the second image to be cropped.
[0092] In a possible embodiment, when the image to be cropped is a rectangle, the center point of the canvas is the geometric center of the rectangle, that is, the intersection point of the diagonals of the rectangle.
[0093] Optionally, the center point of the image to be cropped is the center point of a key content area in the image to be cropped, wherein the step of obtaining the key content area includes: obtaining a content weight of the image to be cropped, and obtaining the key content area according to the content weight.
[0094] In an embodiment of the present application, in order to make the second cropping frame crop more of the key content in the image to be cropped. After encoding, decoding and other analyses are performed on the image to be cropped using a trained neural network, the image to be cropped is divided into several content areas, and the weights of the pixels in each content area are close. And the content weight of each content area is obtained, and the content weight represents the importance of the content of the content area. The center of gravity of the content area with the highest content weight is used as the center point of the image to be cropped. In this way, after determining the translation distance and the translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped and the center point of the first cropping frame, the second cropping frame obtained after processing the first cropping frame according to the translation distance and the translation direction is closer to the key content of the second image to be cropped.
[0095] Figure 4 is a block diagram of an image cropping device according to an exemplary embodiment. Figure 4 The device includes a coordinate determination module 410, a target edge determination module 420, an enlargement module 430, an edit configuration acquisition module 440, a processing module 450 and a cropping module 460.
[0096] A coordinate determination module 410, used to determine the coordinates of the first image to be cropped and the center point of the first cropping frame;
[0097] A target edge determination module 420 is used to obtain the shortest first distance from the center point of the first cropping frame to the edge of the first image to be cropped, and determine the edge corresponding to the first distance as the first target edge;
[0098] The enlarging module 430 is used to enlarge the first image to be cropped, obtain the second image to be cropped and the second target edge, wherein the edge on the second image to be cropped corresponding to the first target edge is the second target edge, and the range of the second image to be cropped is larger than the first cropping frame;
[0099] An editing configuration acquisition module 440, configured to acquire an image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge;
[0100] A processing module 450 is used to process the first cropping frame according to the translation distance, translation direction and scaling ratio to obtain a second cropping frame;
[0101] The cropping module 460 is configured to crop the first image to be cropped according to the second cropping frame.
[0102] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0103] Figure 5 1 is a block diagram of a device 500 for image cropping according to an exemplary embodiment. For example, the device 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0104] Reference Figure 5 , the device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .
[0105] The processing component 502 generally controls the overall operation of the device 500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 502 may include one or more modules to facilitate the interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate the interaction between the multimedia component 508 and the processing component 502.
[0106] The memory 504 is configured to store various types of data to support operations on the device 500. Examples of such data include instructions for any application or method operating on the device 500, contact data, phone book data, messages, pictures, videos, etc. The memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0107] The power supply component 506 provides power to the various components of the device 500. The power supply component 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 500.
[0108] The multimedia component 508 includes a screen that provides an output interface between the device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0109] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), and when the device 500 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 504 or sent via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.
[0110] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0111] The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the device 500. For example, the sensor assembly 514 can detect the open / closed state of the device 500, the relative positioning of components, such as the display and keypad of the device 500, and the sensor assembly 514 can also detect the position change of the device 500 or a component of the device 500, the presence or absence of user contact with the device 500, the orientation or acceleration / deceleration of the device 500, and the temperature change of the device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0112] The communication component 516 is configured to facilitate wired or wireless communication between the device 500 and other devices. The device 500 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0113] In an exemplary embodiment, the apparatus 500 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0114] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including instructions, and the instructions can be executed by a processor 520 of the device 500 to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0115] Figure 66 is a block diagram of a device 600 for image cropping according to an exemplary embodiment. For example, the device 600 may be provided as a server. Figure 6 , the apparatus 600 includes a processing component 622, which further includes one or more processors, and a memory resource represented by a memory 632 for storing instructions executable by the processing component 622, such as an application. The application stored in the memory 632 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 622 is configured to execute instructions to perform the above method...
[0116] The device 600 may also include a power supply component 626 configured to perform power management of the device 600, a wired or wireless network interface 650 configured to connect the device 600 to a network, and an input / output (I / O) interface 656. The device 600 may operate based on an operating system stored in the memory 632, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.
[0117] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0118] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image cropping method, characterized in that: include: Determine the coordinates of the first image to be cropped and the center point of the first cropping frame; Obtaining a first shortest distance from a center point of the first cropping frame to an edge of a first image to be cropped, and determining an edge corresponding to the first distance as a first target edge; Enlarging the first image to be cropped, acquiring a second image to be cropped and a second target edge, wherein an edge on the second image to be cropped corresponding to the first target edge is the second target edge, and a range of the second image to be cropped is larger than the first cropping frame, wherein the first image to be cropped is enlarged so that a range of the second image to be cropped obtained after enlargement is larger than a range of the first cropping frame, and a zoom factor of the second image to be cropped is a minimum zoom factor, wherein an edge of the second image to be cropped obtained after enlargement at the minimum zoom factor contacts an edge of the first cropping frame; Acquiring an image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge, wherein the image editing configuration includes: a translation direction, a translation distance, and a scaling ratio, including: acquiring a second distance from the center point of the first cropping frame to the second target edge; acquiring the scaling ratio according to the first distance and the second distance; determining the translation distance and the translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame; Processing the first cropping frame according to the image editing configuration to obtain a second cropping frame includes: performing a translation and rotation transformation on the first cropping frame according to the translation distance, the translation direction, and the scaling ratio in the image editing configuration, performing a reverse translation on the first cropping frame according to the translation distance and the translation direction, and reversely scaling the first cropping frame according to the scaling ratio to obtain the second cropping frame; The first image to be cropped is cropped according to the second cropping frame.
2. The method according to claim 1, characterized in that The acquiring the image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge and the second target edge comprises: Obtain a second distance from the center point of the first cropping frame to the second target edge; Acquire the scaling ratio according to the first distance and the second distance; The translation distance and the translation direction are determined according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame.
3. The method according to claim 2, characterized in that The processing the first cropping frame according to the image editing configuration to obtain the second cropping frame specifically includes: Moving the first cropping frame according to the translation distance and the translation direction, and scaling the first cropping frame according to the scaling ratio to obtain a second cropping frame; The second cropping frame and the first image to be cropped are moved so that a center point of the first image to be cropped coincides with a center point of the screen, wherein a relative position of the second cropping frame and the first image to be cropped remains unchanged.
4. The method according to claim 3, characterized in that The center point of the image to be cropped is the center point of the canvas of the image to be cropped.
5. The method according to claim 3, characterized in that: The center point of the image to be cropped is the center point of the key content area in the image to be cropped, wherein the step of obtaining the key content area includes: obtaining the content weight of the image to be cropped, and obtaining the key content area according to the content weight.
6. An image cropping device, characterized in that: include: A coordinate determination module, used to determine the coordinates of the first image to be cropped and the center point of the first cropping frame; a target edge determination module, configured to obtain a first shortest distance from a center point of the first cropping frame to an edge of a first image to be cropped, and determine an edge corresponding to the first distance as a first target edge; an enlargement module, used to enlarge the first image to be cropped, obtain the second image to be cropped and the second target edge, wherein the edge on the second image to be cropped corresponding to the first target edge is the second target edge, and the range of the second image to be cropped is larger than the first cropping frame, wherein the first image to be cropped is enlarged so that the range of the second image to be cropped obtained after enlargement is larger than the range of the first cropping frame, and the zoom factor of the second image to be cropped is the minimum zoom factor, wherein the edge of the second image to be cropped obtained after enlargement at the minimum zoom factor contacts the edge of the first cropping frame; an editing configuration acquisition module, configured to acquire an image editing configuration according to the coordinates of the center point of the first cropping frame, the first target edge, and the second target edge, wherein the image editing configuration includes: a translation direction, a translation distance, and a scaling ratio, including: acquiring a second distance from the center point of the first cropping frame to the second target edge, acquiring the scaling ratio according to the first distance and the second distance, and determining the translation distance and the translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the first cropping frame; a processing module, configured to process the first cropping frame according to the translation distance, translation direction and scaling ratio in the image editing configuration to obtain a second cropping frame, including: performing a translation and rotation transformation on the first cropping frame according to the translation distance, translation direction and scaling ratio, performing a reverse translation on the first cropping frame according to the translation distance and translation direction, and performing a reverse scaling on the first cropping frame according to the scaling ratio to obtain the second cropping frame; A cropping module is used to crop the first image to be cropped according to the second cropping frame.
7. The device according to claim 6, characterized in that The editing configuration acquisition module includes: A distance acquisition submodule, used to acquire a second distance from the center point of the first cropping frame to the second target edge; A zoom ratio acquisition submodule, configured to acquire a zoom ratio according to the first distance and the second distance; The translation parameter determination submodule is used to determine the translation distance and translation direction according to the coordinates of the center point of the first image to be cropped, the center point of the second image to be cropped, and the center point of the second cropping frame.
8. The device according to claim 6, characterized in that The processing module specifically includes: A first processing submodule, configured to move the first cropping frame according to the translation distance and the translation direction, and scale the first cropping frame according to the scaling ratio to obtain a second cropping frame; The second processing submodule is used to move the second cropping frame and the first image to be cropped so that the center point of the first image to be cropped coincides with the center point of the screen, wherein the relative positions of the second cropping frame and the first image to be cropped remain unchanged.
9. The device according to claim 8, characterized in that The center point of the image to be cropped is the center point of the canvas of the image to be cropped.
10. The device according to claim 8, characterized in that The center point of the image to be cropped is the center point of the key content area in the image to be cropped, wherein the step of obtaining the key content area includes: obtaining the content weight of the image to be cropped, and obtaining the key content area according to the content weight.
11. An electronic device for image cropping, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image cropping method according to any one of claims 1 to 5. 12 . A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an image cropping electronic device, the image cropping electronic device is enabled to execute the image cropping method according to any one of claims 1 to 5.
13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Image cutting method and device and electronic equipment
CN110136142A
Image processing method and device, electronic equipment and storage medium
CN110706150A