Image processing method and apparatus therefor

CN122597443APending Publication Date: 2026-08-18VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610958666.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0004]本申请实施例的目的是提供一种图像处理方法及其装置,能够解决裁剪框跳变的问题

Benefits of technology

[0011] In this embodiment, a drag input is received for a first vertex of a first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any one of the vertices of the first cropping frame; in response to the drag input, the number of vertices of the first cropping frame located outside the first image is determined; the first cropping frame is adjusted according to a cropping frame adjustment strategy corresponding to the number of vertices, resulting in a second cropping frame; wherein all four vertices of the second cropping frame are located inside the first image; the first image is cropped using the second cropping frame. Thus, by adjusting the cropping frame according to a cropping frame adjustment strategy corresponding to the number of vertices located outside the image to be cropped, cropping frame jumps can be prevented, ensuring that the cropped image meets the user's requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122597443A_ABST
    Figure CN122597443A_ABST
Patent Text Reader

Abstract

The application discloses an image processing method and device, and belongs to the technical field of image processing. The image processing method comprises the following steps: receiving a dragging input of a first vertex of a first cropping frame; wherein the first cropping frame comprises a plurality of vertices, and the first vertex is any vertex of the first cropping frame; in response to the dragging input, determining the number of vertices of the first cropping frame located outside a first image; adjusting the first cropping frame according to a cropping frame adjustment strategy corresponding to the number, to obtain a second cropping frame; wherein the four vertices of the second cropping frame are all located inside the first image; and cropping the first image through the second cropping frame.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing technology, and specifically relates to an image processing method and apparatus. Background Technology

[0002] Image cropping is the process of cropping an image according to user needs, mainly by cropping out the area that meets the user's requirements from the image.

[0003] In related technologies, when using a cropping box to crop an image, the cropping box may jump around when dragged along the edge of the image, resulting in the cropped area not meeting the user's requirements. Summary of the Invention

[0004] The purpose of this application is to provide an image processing method and apparatus that can solve the problem of cropping box jumps.

[0005] In a first aspect, embodiments of this application provide an image processing method, including: Receive drag input for the first vertex of the first cropping box; wherein the first cropping box includes multiple vertices, and the first vertex is any one of the vertices of the first cropping box; In response to drag input, determine the number of vertices of the first cropping box located outside the first image; Based on the cropping box adjustment strategy corresponding to the quantity, the first cropping box is adjusted to obtain the second cropping box; wherein all four vertices of the second cropping box are located inside the first image; The first image is cropped using the second cropping frame.

[0006] Secondly, embodiments of this application provide an image processing apparatus, including: A receiving module is used to receive drag input to the first vertex of the first cropping box; wherein the first cropping box includes multiple vertices, and the first vertex is any one of the vertices of the first cropping box; A determination module is used to determine the number of vertices of the first cropping box located outside the first image in response to drag input; The adjustment module is used to adjust the first cropping box according to the cropping box adjustment strategy corresponding to the quantity, and obtain the second cropping box; wherein all four vertices of the second cropping box are located inside the first image; The cropping module is used to crop the first image using a second cropping frame.

[0007] Thirdly, embodiments of this application provide an electronic device, which includes a processor and a memory. The memory stores programs or instructions that can run on the processor, and when the programs or instructions are executed by the processor, they implement the steps of the image processing method provided in embodiments of this application.

[0008] Fourthly, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the image processing method provided in embodiments of this application.

[0009] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the steps of the image processing method provided in embodiments of this application.

[0010] Sixthly, embodiments of this application provide a computer program product, which is stored in a storage medium and executed by at least one processor to implement the steps of the image processing method provided in embodiments of this application.

[0011] In this embodiment, a drag input is received for a first vertex of a first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any one of the vertices of the first cropping frame; in response to the drag input, the number of vertices of the first cropping frame located outside the first image is determined; the first cropping frame is adjusted according to a cropping frame adjustment strategy corresponding to the number of vertices, resulting in a second cropping frame; wherein all four vertices of the second cropping frame are located inside the first image; the first image is cropped using the second cropping frame. Thus, by adjusting the cropping frame according to a cropping frame adjustment strategy corresponding to the number of vertices located outside the image to be cropped, cropping frame jumps can be prevented, ensuring that the cropped image meets the user's requirements. Attached Figure Description

[0012] Figure 1 This is a schematic flowchart of an image processing method provided in some embodiments of this application; Figure 2 This is a schematic diagram showing that the number of vertices of the cropping frame located outside the image is 1, according to some embodiments of this application; Figure 3 This is a schematic diagram of a cropping frame with two vertices located outside the image, provided in some embodiments of this application. Figure 4 This is a schematic diagram showing that the number of vertices of the cropping frame located outside the image is 3, according to some embodiments of this application; Figure 5 This is a first schematic diagram of adjusting the first clipping frame provided in some embodiments of this application; Figure 6 This is a second schematic diagram of adjusting the first clipping frame provided by some embodiments of this application; Figure 7 This is a third schematic diagram of adjusting the first clipping frame provided by some embodiments of this application; Figure 8 This is a fourth schematic diagram of adjusting the first clipping frame provided in some embodiments of this application; Figure 9 This is a fifth schematic diagram of adjusting the first clipping frame provided in some embodiments of this application; Figure 10 These are schematic diagrams of the structure of an image processing apparatus provided in some embodiments of this application; Figure 11 These are schematic diagrams of the structure of electronic devices provided in some embodiments of this application; Figure 12 These are schematic diagrams of the hardware structure of electronic devices according to some embodiments of this application. Detailed Implementation

[0013] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0014] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0015] The terminology used in the implementation section of this application is only for explaining specific embodiments of this application and is not intended to limit this application. The terminology involved in the embodiments of this application is explained below.

[0016] The cropping box is a rectangle used to select the cropping area when cropping an image.

[0017] The image to be cropped is the image that needs to be cropped.

[0018] The image processing method and apparatus provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0019] It should be noted that the image processing method provided in this application can be executed by electronic devices such as mobile phones, tablets, laptops, PDAs, and in-vehicle electronic devices. Some embodiments of this application use electronic devices as the executing entity to illustrate the image processing method provided in this application.

[0020] The image processing method provided in this application can be applied to scenarios where images are cropped.

[0021] Figure 1 This is a schematic flowchart of an image processing method provided in some embodiments of this application. The image processing method includes the following steps: Step 101: Receive drag input for the first vertex of the first cropping box; wherein, the first cropping box includes multiple vertices, and the first vertex is any vertex of the first cropping box; In some embodiments of this application, the first cropping frame can be a rectangle. The first cropping frame has four vertices, and the first vertex can be any one of the four vertices.

[0022] Step 102: In response to drag input, determine the number of vertices of the first cropping box located outside the first image; In some embodiments of this application, the first image in the embodiments of this application can be a convex quadrilateral that has been processed from a certain image, such as horizontal scaling, vertical scaling, rotation, etc.

[0023] In some embodiments of this application, in step 102, when dragging the first vertex of the first cropping frame causes the first cropping frame to have vertices located outside the first image, the number of vertices of the first cropping frame located outside the first image is determined. When the first cropping frame has vertices located outside the first image, the number of vertices of the first cropping frame located outside the first image may be 1, 2, or 3.

[0024] In some embodiments of this application, when cropping an image using a cropping box, if a user drags a vertex of the cropping box, the drag point needs to move with the user's finger or a touch device such as a stylus, causing the cropping box to extend beyond the image area. To confine the cropping box within the image area, all cropping box vertices extending beyond the image area need to be translated into the image area. Due to factors such as the number of cropping box vertices outside the image area, the position of the drag point, the orientation of the cropping box vertices outside the image area relative to the image area, and the shape of the image area, there are many scenarios where the cropping box extends beyond the image area.

[0025] This application categorizes scenarios where the cropping box extends beyond the image area into two types: Type 1: only one cropping box vertex is located outside the image area; Type 2: two or three cropping box vertices are located outside the image area. Different cropping box adjustment strategies are configured for Type 1 and Type 2 scenarios respectively.

[0026] Figure 2 This is a schematic diagram showing that the number of vertices of the cropping frame located outside the image is 1, according to some embodiments of this application; Figure 3 This is a schematic diagram of a cropping frame with two vertices located outside the image, provided in some embodiments of this application. Figure 4 This is a schematic diagram of a cropping frame located outside the image with 3 vertices, provided in some embodiments of this application.

[0027] exist Figures 2 to 4 In the diagram, point P is the drag point. Figure 2 In the image 201, the number of vertices of the cropping box 202 located outside the image 201 is 1; Figure 3 In the image 201, the number of vertices of the cropping box 202 located outside the image 201 is 2; Figure 4 In the image 201, the number of vertices of the cropping box 202 located outside the image 201 is 3.

[0028] Step 103: Adjust the first cropping box according to the cropping box adjustment strategy corresponding to the quantity to obtain the second cropping box; wherein, all four vertices of the second cropping box are located inside the first image; In some embodiments of this application, step 103 may include: when the number of vertices of the first cropping frame located outside the first image is 1, adjusting the first cropping frame according to the positional relationship between the second vertex, the intersection point, and the vertices of the first image to obtain a second cropping frame; wherein, the second vertex is the vertex of the first cropping frame located outside the first image, and the intersection point is the intersection of the diagonals of the first image.

[0029] In some embodiments of this application, the positional relationship between the vertex of the first cropping frame located outside the first image, the intersection of the diagonal of the first image, and the vertex of the first image can be such that the intersection of the vertex of the first cropping frame located outside the first image and the diagonal of the first image is located in the diagonal quadrant of a certain vertex of the first image, or that the intersection of the vertex of the first cropping frame located outside the first image and the diagonal of the first image is not located in the diagonal quadrant of any vertex of the first image, that is, the intersection of the vertex of the first cropping frame located outside the first image and the diagonal of the first image is not located in the diagonal quadrant of any vertex of the first image.

[0030] In some embodiments of this application, adjusting the first cropping frame to obtain the second cropping frame based on the positional relationship between the second vertex, the center point, and the vertices of the first image may include: when the second vertex and the center point are respectively located in the diagonal quadrants of the third vertex, adjusting the second vertex to the position of the third vertex to obtain the second cropping frame; wherein the third vertex is any vertex of the first image.

[0031] For example, such as Figure 5 As shown, Figure 5 This is a first schematic diagram illustrating the adjustment of the first clipping frame according to some embodiments of this application. Figure 5 In the image, the four vertices of the cropping box 202 are vertices A, B, C, and D, and the four vertices of the image 201 are vertices X, Y, Z, and M. Point O is the intersection of the two diagonals XZ and YM of the image 201. Since vertex A of the cropping box 202 and point O are located in the diagonal quadrant opposite vertex X of the image 201, vertex A of the cropping box 202 is adjusted to the position of vertex X of the image 201.

[0032] In some embodiments of this application, adjusting the first cropping frame to obtain the second cropping frame based on the positional relationship between the second vertex, the center point, and the vertices of the first image may include: when the second vertex and the center point are not respectively located in the diagonal quadrants of the vertices of the first image, obtaining a first distance from the second vertex in the horizontal direction to the first image and a second distance from the second vertex in the vertical direction to the first image; translating the second vertex to the first image according to the translation method corresponding to the target distance; wherein, the target distance is the minimum distance between the first distance and the second distance.

[0033] For example, such as Figure 6 As shown, Figure 6 This is a second schematic diagram illustrating the adjustment of the first clipping frame according to some embodiments of this application. Figure 6In the image, the four vertices of the cropping box 202 are vertices A, B, C, and D, and the four vertices of the image 201 are vertices X, Y, Z, and M. Point O is the intersection of the two diagonals XZ and YM of the image 201. Vertices A and O of the cropping box 202 are not located in the diagonal quadrants of vertex X, Y, Z, or M of the image 201; that is, vertices A and O of the cropping box 202 are not located in the diagonal quadrants of any vertex of the image 201. At this point, obtain the horizontal distance from vertex A of cropping frame 202 to image 201 and the vertical distance from vertex A of cropping frame 202 to image 201. Compare the two distances to obtain the minimum distance between the horizontal and vertical distances of vertex A of cropping frame 202 to image 201. The minimum distance between the horizontal and vertical distances of vertex A of cropping frame 202 to image 201 is the vertical distance of vertex A of cropping frame 202 to image 201. Then, translate vertex A of cropping frame 202 vertically to image 201.

[0034] In some embodiments of this application, step 103 may include: when the number is 2 or 3, controlling the first side to be horizontally translated to the first image to obtain the third side, and controlling the second side to be vertically translated to the first image to obtain the fourth side; wherein, the first side is a vertical side adjacent to the first vertex, and the second side is a horizontal side adjacent to the first vertex; updating the first vertex to the intersection of the third side and the fourth side to obtain the third cropping frame; and determining the second cropping frame according to the number of vertices of the third cropping frame located outside the first image.

[0035] In some embodiments of this application, determining the second cropping frame based on the number of vertices outside the first image of the third cropping frame may include: when the number of vertices outside the first image of the third cropping frame is 0, using the third cropping frame as the second cropping frame; when the number of vertices outside the first image of the third cropping frame is 1, adjusting the third cropping frame according to the positional relationship between the fourth vertex, the intersection point, and the vertices of the first image to obtain the second cropping frame; wherein the fourth vertex is the vertex of the third cropping frame outside the first image, and the intersection point is the intersection of the diagonals of the first image.

[0036] For example, such as Figure 7 As shown, Figure 7 This is a third schematic diagram illustrating the adjustment of the first clipping frame according to some embodiments of this application. Figure 7In the image, the four vertices of the cropping box 202 are vertices A, B, C, and D, and the four vertices of the image 201 are vertices X, Y, Z, and M. Vertex A of the cropping box 202 is the drag point. When dragging vertex A, vertices B and D of the cropping box 202 are located outside of the image 201, meaning that the number of vertices of the cropping box 202 located outside the image 201 is 2. Horizontally translate edge AB to the first image to obtain edge A1B1, and vertically translate edge AD to the first image to obtain edge A2D1; the intersection of edge A1B1 and edge A2D1 is A3. Then, update vertex A of the cropping box 202 to A3. At this time, vertex B of the cropping box 202 is updated to B1, and vertex D of the cropping box 202 is updated to D1. All vertices of the cropping frame A3B1CD1 are located inside the image 201, and the number of vertices of the cropping frame A3B1CD1 located outside the image 201 is 0. Therefore, the cropping frame A3B1CD1 is the second cropping frame in this embodiment of the application.

[0037] For example, such as Figure 8 As shown, Figure 8 This is a fourth schematic diagram illustrating the adjustment of the first clipping frame according to some embodiments of this application. Figure 8 In the image, the four vertices of the cropping box 202 are vertices A, B, C, and D, and the four vertices of the image 201 are vertices X, Y, Z, and M. Vertex A of the cropping box 202 is the drag point. When dragging vertex A, vertices A and D of the cropping box 202 are located outside of image 201, meaning the number of vertices of the cropping box 202 located outside of image 201 is 2. Vertically translating edge AB to the first image yields edge A2B1, and horizontally translating edge AD to the first image yields edge A1D1. The intersection of edge A2B1 and edge A1D1 is A3. Therefore, vertex A of the cropping box 202 is updated to A3. At this time, vertex B of the cropping box 202 is updated to B1, and vertex D of the cropping box 202 is updated to D1. The vertex of the cropping box A3B1CD1 located outside of image 201 is A3, meaning the number of vertices of the cropping box A3B1CD1 located outside of image 201 is 1.

[0038] Vertex A3 and point O of cropping box 202 are not located in the diagonal quadrant of vertex X of image 201, nor in the diagonal quadrant of vertex Y of image 201, nor in the diagonal quadrant of vertex Z of image 201, nor in the diagonal quadrant of vertex M of image 201. That is, vertex A3 and point O of cropping box 202 are not located in the diagonal quadrant of any vertex of image 201. At this point, obtain the horizontal distance from vertex A3 of cropping frame 202 to image 201 and the vertical distance from vertex A3 of cropping frame 202 to image 201. Compare the two distances to obtain the minimum distance between the horizontal and vertical distances of vertex A3 of cropping frame 202 to image 201. The minimum distance between the horizontal and vertical distances of vertex A3 of cropping frame 202 to image 201 is the horizontal distance of vertex A3 of cropping frame 202 to image 201. Then, translate vertex A3 of cropping frame 202 horizontally to image 201.

[0039] For example, such as Figure 9 As shown, Figure 9 This is a fifth schematic diagram illustrating the adjustment of the first clipping frame according to some embodiments of this application. Figure 9 In the image, the four vertices of cropping box 202 are vertices A, B, C, and D, and the four vertices of image 201 are vertices X, Y, Z, and M. Vertex A of cropping box 202 is the drag point. When dragging vertex A, vertices A, B, and D of cropping box 202 are located outside image 201, meaning the number of vertices of cropping box 202 located outside image 201 is 3. Vertically translating edge AD to the first image yields edge A1D1, and horizontally translating edge AB to the first image yields edge A2B1. The intersection of edge A1D1 and edge A2B1 is A3. Therefore, vertex A of cropping box 202 is updated to A3. At this time, vertex B of cropping box 202 is updated to B1, and vertex D of cropping box 202 is updated to D1. The vertex of cropping box A3B1CD1 located outside image 201 is A3, meaning the number of vertices of cropping box A3B1CD1 located outside image 201 is 1.

[0040] Vertex A3 and point O of cropping box 202 are not located in the diagonal quadrant of vertex X of image 201, nor in the diagonal quadrant of vertex Y of image 201, nor in the diagonal quadrant of vertex Z of image 201, nor in the diagonal quadrant of vertex M of image 201. That is, vertex A3 and point O of cropping box 202 are not located in the diagonal quadrant of any vertex of image 201. At this point, obtain the horizontal distance from vertex A3 of cropping frame 202 to image 201 and the vertical distance from vertex A3 of cropping frame 202 to image 201. Compare the two distances to obtain the minimum distance between the horizontal and vertical distances of vertex A3 of cropping frame 202 to image 201. The minimum distance between the horizontal and vertical distances of vertex A3 of cropping frame 202 to image 201 is the horizontal distance of vertex A3 of cropping frame 202 to image 201. Then, translate vertex A3 of cropping frame 202 horizontally to image 201.

[0041] Step 104: Crop the first image using the second cropping frame.

[0042] In some embodiments of this application, in step 104, the portion of the first image selected by the second cropping frame can be cropped.

[0043] In this embodiment, a drag input is received for a first vertex of a first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any one of the vertices of the first cropping frame; in response to the drag input, the number of vertices of the first cropping frame located outside the first image is determined; the first cropping frame is adjusted according to a cropping frame adjustment strategy corresponding to the number of vertices, resulting in a second cropping frame; wherein all four vertices of the second cropping frame are located inside the first image; the first image is cropped using the second cropping frame. Thus, by adjusting the cropping frame according to a cropping frame adjustment strategy corresponding to the number of vertices located outside the image to be cropped, cropping frame jumps can be prevented, ensuring that the cropped image meets the user's requirements.

[0044] The image processing method provided in this application can be executed by an image processing device. This application uses an image processing device executing the image processing method as an example to illustrate the image processing device provided in this application.

[0045] Figure 10 This is a schematic diagram of the structure of an image processing apparatus provided in some embodiments of this application. The image processing apparatus 1000 may include: The receiving module 1001 is used to receive drag input to the first vertex of the first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any vertex of the first cropping frame; The determination module 1002 is used to determine the number of vertices of the first cropping box located outside the first image in response to drag input; The adjustment module 1003 is used to adjust the first cropping frame according to the cropping frame adjustment strategy corresponding to the quantity, and obtain the second cropping frame; wherein all four vertices of the second cropping frame are located inside the first image; The cropping module 1004 is used to crop the first image using a second cropping frame.

[0046] In some embodiments of this application, the adjustment module 1003 is specifically used for: When the number is 1, the first cropping box is adjusted according to the positional relationship between the second vertex, the center point, and the vertices of the first image to obtain the second cropping box; wherein, the second vertex is the vertex of the first cropping box located outside the first image, and the center point is the intersection of the diagonals of the first image.

[0047] In some embodiments of this application, the adjustment module 1003 is specifically used for: With the second vertex and the intersection point located in the diagonal quadrants opposite the third vertex, the second vertex is adjusted to the position of the third vertex to obtain the second cropping frame; wherein the third vertex is any vertex of the first image.

[0048] In some embodiments of this application, the adjustment module 1003 is specifically used for: If the second vertex and the center point are not located in the diagonal quadrants of the vertices of the first image respectively, obtain the first distance from the second vertex to the first image in the horizontal direction and the second distance from the second vertex to the first image in the vertical direction. The second vertex is translated to the first image according to the translation method corresponding to the target distance; where the target distance is the minimum distance between the first distance and the second distance.

[0049] In some embodiments of this application, the adjustment module 1003 is specifically used for: The translation submodule is used to control the first side to be horizontally translated to the first image to obtain the third side when the number of sides is 2 or 3, and to control the second side to be vertically translated to the first image to obtain the fourth side; wherein, the first side is the vertical side adjacent to the first vertex, and the second side is the horizontal side adjacent to the first vertex. The update submodule is used to update the first vertex to the intersection of the third and fourth sides to obtain the third clipping box; The determination submodule is used to determine the second cropping box based on the number of vertices of the third cropping box located outside the first image.

[0050] In some embodiments of this application, the determination submodule is specifically used for: If the number of vertices of the third cropping box located outside the first image is 0, the third cropping box is used as the second cropping box. When the number of vertices in the third cropping box that are outside the first image is 1, the third cropping box is adjusted according to the positional relationship between the fourth vertex, the intersection point, and the vertices of the first image to obtain the second cropping box; wherein, the fourth vertex is the vertex of the third cropping box that is outside the first image, and the intersection point is the intersection of the diagonals of the first image.

[0051] The image processing device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0052] The image processing device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0053] The image processing apparatus provided in this application embodiment can achieve... Figures 1 to 9 The various processes implemented in the image processing method embodiment will not be described again here to avoid repetition.

[0054] Optionally, such as Figure 11As shown, this application embodiment also provides an electronic device 1100, including a processor 1101 and a memory 1102. The memory 1102 stores a program or instructions that can run on the processor 1101. When the program or instructions are executed by the processor 1101, they implement the various steps of the image processing method embodiment provided in this application embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0055] Figure 12 These are schematic diagrams of the hardware structure of electronic devices according to some embodiments of this application.

[0056] The electronic device 1200 includes, but is not limited to, components such as: radio frequency unit 1201, network module 1202, audio output unit 1203, input unit 1204, sensor 1205, display unit 1206, user input unit 1207, interface unit 1208, memory 1209, and processor 1210.

[0057] Those skilled in the art will understand that the electronic device 1200 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 1210 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 12 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0058] The user input unit 1207 is used to: receive drag input for a first vertex of a first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any one of the vertices of the first cropping frame; The processor 1210 is configured to: in response to drag input, determine the number of vertices of the first cropping box located outside the first image; adjust the first cropping box according to the cropping box adjustment strategy corresponding to the number to obtain a second cropping box; wherein all four vertices of the second cropping box are located inside the first image; and crop the first image using the second cropping box.

[0059] In some embodiments of this application, the processor 1210 is specifically used for: When the number is 1, the first cropping box is adjusted according to the positional relationship between the second vertex, the center point, and the vertices of the first image to obtain the second cropping box; wherein, the second vertex is the vertex of the first cropping box located outside the first image, and the center point is the intersection of the diagonals of the first image.

[0060] In some embodiments of this application, the processor 1210 is specifically used for: With the second vertex and the intersection point located in the diagonal quadrants opposite the third vertex, the second vertex is adjusted to the position of the third vertex to obtain the second cropping frame; wherein the third vertex is any vertex of the first image.

[0061] In some embodiments of this application, the processor 1210 is specifically used for: If the second vertex and the center point are not located in the diagonal quadrants of the vertices of the first image respectively, obtain the first distance from the second vertex to the first image in the horizontal direction and the second distance from the second vertex to the first image in the vertical direction. The second vertex is translated to the first image according to the translation method corresponding to the target distance; where the target distance is the minimum distance between the first distance and the second distance.

[0062] In some embodiments of this application, the processor 1210 is specifically used for: When the number is 2 or 3, control the first side to be horizontally translated to the first image to obtain the third side, and control the second side to be vertically translated to the first image to obtain the fourth side; wherein, the first side is the vertical side adjacent to the first vertex, and the second side is the horizontal side adjacent to the first vertex; Update the first vertex to the intersection of the third and fourth sides to obtain the third clipping box; The second cropping frame is determined based on the number of vertices of the third cropping frame located outside the first image.

[0063] In some embodiments of this application, the processor 1210 is specifically used for: If the number of vertices of the third cropping box located outside the first image is 0, the third cropping box is used as the second cropping box. When the number of vertices in the third cropping box that are outside the first image is 1, the third cropping box is adjusted according to the positional relationship between the fourth vertex, the intersection point, and the vertices of the first image to obtain the second cropping box; wherein, the fourth vertex is the vertex of the third cropping box that is outside the first image, and the intersection point is the intersection of the diagonals of the first image.

[0064] It should be understood that, in this embodiment, the input unit 1204 may include a graphics processing unit (GPU) 12041 and a microphone 12042. The GPU 12041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 1206 may include a display panel 12061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 1207 includes a touch panel 12071 and at least one of other input devices 12072. The touch panel 12071 is also called a touch screen. The touch panel 12071 may include a touch detection device and a touch controller. Other input devices 12072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0065] The memory 1209 can be used to store software programs and various data. The memory 1209 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 1209 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 1209 in this embodiment includes, but is not limited to, these and any other suitable types of memory.

[0066] Processor 1210 may include one or more processing units; optionally, processor 1210 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 1210.

[0067] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the image processing method provided in this application and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0068] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0069] This application also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the image processing method provided in this application and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0070] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0071] This application also provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the image processing method embodiment provided in this application, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0072] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0073] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the image processing methods provided in the various embodiments of this application.

[0074] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. An image processing method, characterized in that, The method includes: Receive drag input for the first vertex of the first cropping frame; The first cropping frame includes multiple vertices, and the first vertex is any one of the multiple vertices; In response to the drag input, determine the number of vertices of the first cropping box located outside the first image; According to the cropping frame adjustment strategy corresponding to the quantity, adjust the first cropping frame to obtain the second cropping frame; In this case, all four vertices of the second cropping frame are located inside the first image; The first image is cropped using the second cropping frame.

2. The method according to claim 1, characterized in that, The step of adjusting the first cropping frame according to the cropping frame adjustment strategy corresponding to the quantity to obtain the second cropping frame includes: When the number is 1, the first cropping frame is adjusted according to the positional relationship between the second vertex, the center point, and the vertices of the first image to obtain the second cropping frame; wherein, the second vertex is the vertex of the first cropping frame located outside the first image, and the center point is the intersection of the diagonals of the first image.

3. The method according to claim 2, characterized in that, The step of adjusting the first cropping frame to obtain the second cropping frame based on the positional relationship between the second vertex, the center point, and the vertices of the first image includes: When the second vertex and the intersection point are respectively located in the diagonal quadrant of the third vertex, the second vertex is adjusted to the position of the third vertex to obtain the second cropping frame; wherein, the third vertex is any vertex of the first image.

4. The method according to claim 2, characterized in that, The step of adjusting the first cropping frame to obtain the second cropping frame based on the positional relationship between the second vertex, the center point, and the vertices of the first image includes: If the second vertex and the intersection point are not located in the diagonal quadrants of the respective vertices of the first image, obtain the first distance from the second vertex in the horizontal direction to the first image and the second distance from the second vertex in the vertical direction to the first image. The second vertex is translated to the first image according to the translation method corresponding to the target distance; wherein, the target distance is the minimum distance between the first distance and the second distance.

5. The method according to claim 1, characterized in that, The step of adjusting the first cropping frame according to the cropping frame adjustment strategy corresponding to the quantity to obtain the second cropping frame includes: When the number is 2 or 3, the first side is horizontally translated to the first image to obtain the third side, and the second side is vertically translated to the first image to obtain the fourth side; wherein, the first side is a vertical side adjacent to the first vertex, and the second side is a horizontal side adjacent to the first vertex; The first vertex is updated to the intersection of the third and fourth sides to obtain the third clipping frame; The second cropping frame is determined based on the number of vertices of the third cropping frame located outside the first image.

6. An image processing apparatus, characterized in that, The device includes: A receiving module is used to receive drag input to a first vertex of a first cropping frame; wherein the first cropping frame includes multiple vertices, and the first vertex is any one of the vertices of the first cropping frame; A determination module is configured to determine, in response to the drag input, the number of vertices of the first cropping box located outside the first image; An adjustment module is used to adjust the first cropping frame according to the cropping frame adjustment strategy corresponding to the quantity, so as to obtain a second cropping frame; wherein all four vertices of the second cropping frame are located inside the first image; The cropping module is used to crop the first image using the second cropping frame.

7. The apparatus according to claim 6, characterized in that, The adjustment module is specifically used for: When the number is 1, the first cropping frame is adjusted according to the positional relationship between the second vertex, the center point, and the vertices of the first image to obtain the second cropping frame; wherein, the second vertex is the vertex of the first cropping frame located outside the first image, and the center point is the intersection of the diagonals of the first image.

8. The apparatus according to claim 7, characterized in that, The adjustment module is specifically used for: When the second vertex and the intersection point are respectively located in the diagonal quadrant of the third vertex, the second vertex is adjusted to the position of the third vertex to obtain the second cropping frame; wherein, the third vertex is any vertex of the first image.

9. The apparatus according to claim 7, characterized in that, The adjustment module is specifically used for: If the second vertex and the intersection point are not located in the diagonal quadrants of the respective vertices of the first image, obtain the first distance from the second vertex in the horizontal direction to the first image and the second distance from the second vertex in the vertical direction to the first image. The second vertex is translated to the first image according to the translation method corresponding to the target distance; wherein, the target distance is the minimum distance between the first distance and the second distance.

10. The apparatus according to claim 6, characterized in that, The adjustment module includes: The translation submodule is used to control the first side to be horizontally translated to the first image to obtain the third side when the number is 2 or 3, and to control the second side to be vertically translated to the first image to obtain the fourth side; wherein, the first side is a vertical side adjacent to the first vertex, and the second side is a horizontal side adjacent to the first vertex; The update submodule is used to update the first vertex to the intersection of the third and fourth sides to obtain the third clipping frame; A determination submodule is used to determine the second cropping frame based on the number of vertices of the third cropping frame located outside the first image.