WO2020224488A1 - 图像处理方法、装置及设备 - Google Patents

图像处理方法、装置及设备 Download PDF

Info

Publication number
WO2020224488A1
WO2020224488A1 PCT/CN2020/087529 CN2020087529W WO2020224488A1 WO 2020224488 A1 WO2020224488 A1 WO 2020224488A1 CN 2020087529 W CN2020087529 W CN 2020087529W WO 2020224488 A1 WO2020224488 A1 WO 2020224488A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
center
area
circular area
gravity
Prior art date
Application number
PCT/CN2020/087529
Other languages
English (en)
French (fr)
Inventor
苏达
张韵叠
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to US17/609,948 priority Critical patent/US12008761B2/en
Priority to EP20801648.5A priority patent/EP3951574A4/en
Publication of WO2020224488A1 publication Critical patent/WO2020224488A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/04845Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range for image manipulation, e.g. dragging, rotation, expansion or change of colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/66Analysis of geometric attributes of image moments or centre of gravity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/46Descriptors for shape, contour or point-related descriptors, e.g. scale invariant feature transform [SIFT] or bags of words [BoW]; Salient regional features
    • G06V10/462Salient features, e.g. scale invariant feature transforms [SIFT]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/24Indexing scheme for image data processing or generation, in general involving graphical user interfaces [GUIs]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20021Dividing image into blocks, subimages or windows
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Definitions

  • This application relates to the field of computer technology, and in particular to an image processing method, device and equipment.
  • image cropping is usually performed at the middle position of the original image to obtain a cropped image.
  • the image obtained by cropping at the middle position of the original image may not include the salient objects in the original image (objects that the user is more interested in), resulting in poor image cropping quality.
  • This application provides an image processing method, device and equipment, which improve the quality of image cropping.
  • an embodiment of the present application provides an image processing method.
  • the method may include: displaying a first image with a first size, and receiving a user's operation, the user's operation being any one of the following operations: , Screen setting operation, picture sharing operation, address book operation, picture sending operation; display a second image with a second size, the second size is smaller than the first size, the second image includes the salient content on the first image.
  • the user can input an operation in the terminal device to make the terminal device display the second image in the first image, and the second image is a part of the first image.
  • the second image includes the salient content in the first image, which improves the quality of image cropping.
  • the salient object and the second circular area including the salient object may also be determined in the first image, and the second diameter of the second circular area is larger than the first circle
  • the first diameter of the area, the second diameter is less than or equal to the shortest side length of the first image
  • the first circular area is the smallest circular area including the salient object; and the first image is cropped according to the second circular area to obtain The second image.
  • the salient object is first acquired in the first image to be processed, and the first image is cropped according to the position of the salient object in the first image to obtain the cropped second image.
  • the second image include the salient object, and also make the position of the salient object in the first image consistent with the position of the salient object in the second image, so that the composition of the second image after cropping can be made the composition of the first image Consistent, improving the quality of image cropping
  • the second circular area including the salient object may be determined in the first image by the following feasible implementation manner: obtain the first ratio between the first diameter and the shortest side length of the first image ; If the first ratio is between the first threshold and the second threshold, the second circular area is determined according to the preset ratio between the second diameter and the first diameter; if the first ratio is less than the first threshold or greater than the first Two thresholds, the square area is determined in the first image, and the inscribed circle area of the square area is determined as the second circular area.
  • the square area includes salient objects, and the side length of the square area is the shortest side length of the first image .
  • the first ratio when the first ratio is between the first threshold and the second threshold, it means that the proportion of the first circular area in the first image is not too large or too small.
  • the second circular area can be determined according to the preset ratio between the second diameter and the first diameter (for example, the preset ratio can be 0.618), so that the size of the salient object in the second circular area conforms to Aesthetic composition rules improve the quality of image cropping.
  • the first ratio is not between the first threshold and the second threshold, it means that the proportion of the first circular area in the first image is too large or too small. In order to prevent the second image from being clipped from being too small or too small. If large, the square area is determined in the first image, and the inscribed circle area of the square area is determined as the second circular area, which improves the quality of image cropping
  • the second circular area may be determined according to the preset ratio between the second diameter and the first diameter through the following feasible implementation manners: determine the first circular area in the first image; According to the center of the first circular area, the center of the first image, the first diameter and the preset ratio, the second circular area is determined in the first image.
  • determining the second circular area in the first image according to the center of the first circular area, the center of the first image, the first diameter, and the preset ratio includes: The center of the circular area, the center of the first image, determine the initial center in the first image, the center of the first circular area, the center of the first image, and the initial center are on a straight line; according to the first diameter and the preset ratio , Determine the second diameter; according to the initial center and the second diameter, determine the second circular area in the first image.
  • determining the second circular area in the first image according to the initial circle center and the second diameter includes: determining the third circular area with the initial circle center as the center and the second diameter as the diameter, the first circular area Inscribed with the third circular area; determine whether there is a part of the third circular area outside the first image; if so, perform translation and/or rotation operations on the third circular area until the processed third When all the circular areas are within the first image, the processed third circular area in the first image is determined as the second circular area; if not, the third circular area is determined as the second circular area area.
  • the position of the salient object in the second circular area can also be made consistent with the position of the salient object in the first image, so that the composition of the cropped image can be the same as that of the first image. Consistent composition, improving the quality of image cropping
  • a square area can be determined in the first image by the following feasible implementation manners: a rectangular area is determined in the first image, and the rectangular area is the smallest rectangular area that includes a salient object; The size and the side length of the square area determine the square area in the first image.
  • determining the square area in the first image according to the size of the rectangular area and the side length of the square area includes: judging whether the square area can be completed according to the size of the rectangular area and the side length of the square area Cover a rectangular area; if so, obtain the position of the center of gravity of the first image in the first image and the center of gravity of the salient object, and determine the square area according to the position of the center of gravity of the first image in the first image and the center of gravity of the salient object ; If not, the square area is determined according to the rectangular area, and the square area is located in the middle of the rectangular area.
  • the position of the rectangular area in the square area is determined according to the position of the center of gravity of the first image in the first image, so that the position of the salient object in the square area can be consistent with the position of the salient object in the first image ,
  • the composition of the cropped image can be made consistent with the composition of the first image, which improves the quality of image cropping
  • obtaining the position of the center of gravity of the first image in the first image includes: determining the center of gravity of the first image; obtaining the first distance between the center of gravity of the first image and the center of the first image , The second distance between the center of gravity of the first image and the first third line of the first image, and the third distance between the center of gravity of the first image and the first edge of the first image; Among the three lines of thirds, the distance between the center of gravity of the first image and the first third line is the shortest.
  • the distance between the center of gravity of the first image and the first edge is the shortest; according to the first distance , The second distance and the third distance, determine the position of the center of gravity of the first image in the first image, and the position of the center of gravity of the first image in the first image is at least one of the following positions: close to the center position, close to three The position of the dividing line or near the edge.
  • determining the position of the center of gravity of the first image in the first image according to the first distance, the second distance and the third distance includes: if the first distance is less than the second distance and the third distance , The center of gravity of the first image in the first image is determined to be close to the center position; if the second distance is less than the first distance and the third distance, it is determined that the center of gravity of the first image in the first image is close to three Line dividing position; if the third distance is less than the first distance and the second distance, it is determined that the position of the center of gravity of the first image in the first image is close to the edge position.
  • the position of the salient object in the square area can be made consistent with the position of the salient object in the first image, and the composition of the cropped image can be made consistent with the composition of the first image, thereby improving the quality of image cropping
  • determining the square area according to the position of the center of gravity of the first image in the first image and the center of gravity of the salient object includes: if the center of gravity of the first image is close to the position in the first image Center position, the square area is determined according to the center of gravity of the salient object and the center of the square area, and the center of gravity of the salient object is located at the center of the square area; if the center of gravity of the first image in the first image is close to the position of the third line, then Determine the square area based on the center of gravity of the salient object and the second three-point line of the square area. The center of gravity of the salient object is on the second three-point line.
  • the first and second three-point lines are of the same type.
  • Types include upper thirds, lower thirds, left thirds and right thirds; if the position of the center of gravity of the first image in the first image is close to the edge position, according to the center of gravity of the salient object and the square area
  • the second edge determines a square area. The distance between the center of gravity of the salient object and the second edge is less than the preset distance.
  • the second edge is of the same type as the first edge, and the types of edges include top edge, bottom edge, left edge and right edge. In this way, the position of the salient object in the square area can be made consistent with the position of the salient object in the first image, and the composition of the cropped image can be made consistent with the composition of the first image, thereby improving the quality of image cropping
  • determining the salient object in the first image includes: performing at least one of saliency detection processing, semantic segmentation processing, and line detection processing on the first image, so as to be in the first image Identify salient objects.
  • an embodiment of the present application provides an image processing device, including a memory and a processor, and the processor executes program instructions in the memory to implement the image processing method described in any one of the first aspect.
  • an embodiment of the present application provides a storage medium for storing a computer program, which is used to implement the image processing method described in any one of the first aspect when the computer program is executed by a computer or a processor .
  • inventions of the present application provide a computer program product.
  • the computer program product includes instructions that, when executed, cause a computer to execute the image processing method described in any one of the first aspects.
  • the embodiments of the present application provide a system on chip or system chip, the system on chip or system chip can be applied to a terminal device, the system on chip or system chip includes: at least one communication interface, at least one processing The communication interface, the memory, and the processor are interconnected by a bus.
  • the processor executes the instructions stored in the memory so that the terminal device can execute any one of the Image processing method.
  • the user can input an operation in the terminal device to make the terminal device display the second image in the first image, and the second image is Part of the first image, and the second image includes salient content in the first image, which improves the quality of image cropping
  • FIG. 1A is a schematic diagram of an image provided by an embodiment of this application.
  • FIG. 1B is a schematic diagram of another image provided by an embodiment of this application.
  • Figure 2 is a schematic diagram of a three-point line provided by an embodiment of the application.
  • 3A is a schematic diagram of a terminal interface in an application scenario provided by an embodiment of the application.
  • 3B is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of the application.
  • 3C is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of the application.
  • FIG. 3D is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of this application.
  • FIG. 4 is a schematic flowchart of an image processing method provided by an embodiment of the application.
  • 5A is a schematic diagram of a pre-processing image provided by an embodiment of the application.
  • 5B is a schematic diagram of a processed image provided by an embodiment of the application.
  • FIG. 5C is a schematic diagram of another image before processing provided by an embodiment of the application.
  • 5D is a schematic diagram of another processed image provided by an embodiment of the application.
  • FIG. 6 is a schematic diagram of an image processing process provided by an embodiment of the application.
  • FIG. 7A is a schematic diagram of another image before processing provided by an embodiment of the application.
  • FIG. 7B is a schematic diagram of another processed image provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 9 is a schematic diagram of still another image provided by an embodiment of this application.
  • FIG. 10 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 11 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 12 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 13 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 14 is a schematic diagram of still another image provided by an embodiment of this application.
  • 15 is a schematic diagram of another image provided by an embodiment of the application.
  • FIG. 16 is a schematic diagram of another image provided by an embodiment of this application.
  • FIG. 17 is a schematic diagram of still another image provided by an embodiment of this application.
  • FIG. 18 is a schematic diagram of image cropping provided by an embodiment of the application.
  • FIG. 19 is a schematic flowchart of another image processing method provided by an embodiment of the application.
  • 20 is a schematic structural diagram of an image processing device provided by an embodiment of the application.
  • FIG. 21 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
  • Terminal equipment It can be any equipment with image processing and computing capabilities.
  • the terminal device may also have an image display function.
  • the terminal device may be a mobile phone, a computer, a vehicle-mounted device, a wearable device, an industrial device, an artificial intelligence device/augmented reality (AR) device, a virtual reality (VR) device, etc.
  • AR augmented reality
  • VR virtual reality
  • Terminal function refers to the function possessed by the terminal device or the function that the terminal device can realize.
  • the terminal function includes at least the functions of the terminal device itself and the functions of the application program installed in the terminal device.
  • the function of the terminal device in this application may refer to the function of the terminal device when it leaves the factory.
  • terminal functions may include: avatar setting function, screen setting function, picture sharing function, address book function, picture sending function, image processing function, etc.
  • Salient objects refers to the more salient objects included in the image, that is, when the user observes an image, the user's attention (or points of interest) will focus on the salient objects.
  • the salient objects in the image can be people, animals, buildings, food, and so on.
  • FIGS. 1A-1B the salient objects will be described with reference to FIGS. 1A-1B.
  • FIG. 1A is a schematic diagram of an image provided by an embodiment of this application.
  • FIG. 1B is a schematic diagram of another image provided by an embodiment of the application.
  • the salient object in the image is a cartoon character, that is, when the user observes the image, the user's attention will be focused on the cartoon character.
  • the salient object in the image is an animal, that is, when the user observes the image, the user's attention will be focused on the animal.
  • FIG. 2 is a schematic diagram of a line of three provided by an embodiment of the application.
  • the image can be divided equally into 3 parts in the longitudinal part by the straight line L3 and the straight line L4, where L3 is the upper third of the image, and L4 is the lower third of the image.
  • the image can be divided into 3 parts equally by the straight line L1 and the straight line L2 in the horizontal part, where L1 is the left third of the image, and L2 is the right third of the image.
  • Image center of gravity used to indicate the average position of the pixel gray value distribution.
  • the center of gravity of the image is similar to the physical center of mass.
  • the center of gravity of the image can be calculated by the following formula:
  • X c is the coordinate of the center of gravity in the horizontal direction
  • Y c is the coordinate of the center of gravity in the vertical direction
  • P i is the gray value of the i-th pixel
  • x i is the coordinate of the i-th pixel in the horizontal direction
  • y i Is the vertical coordinate of the i-th pixel.
  • Composition It can also be called the structure of the image, which can include the position of the salient object in the image.
  • the position of the salient object in the image may include: close to the three-point line (including close to the upper three-point line, close to the lower three-point line, close to the left three-point line, and close to the right three-point line), close to the center Location, near the edge.
  • the terminal device as a mobile phone as an example to introduce the applicable application scenarios of this application.
  • FIG. 3A is a schematic diagram of a terminal interface in an application scenario provided by an embodiment of the application.
  • the terminal device is a mobile phone
  • the terminal interface includes interface A1, interface A2, and interface A3.
  • the mobile phone can display at least one operation option of the image, for example, as shown in Figure 3A
  • the operation options for the image displayed in the interface A1 include "copy", "use as wallpaper” and "assign to contact".
  • the user can operate the preset icon or preset button in the mobile phone, so that the mobile phone displays at least one operation option of the image. Assuming that the user needs to set the image as the contact's avatar, the user can click on the "assigned to contact" icon to make the mobile phone display interface A2.
  • the mobile phone displays the address book, the user can select a contact, so that the mobile phone can process the image through the image processing method shown in this application, and set the processed image as the avatar of the selected contact .
  • the mobile phone can process the image by the method shown in this application, and set the processed avatar as the avatar of the contact "Xiaohong”.
  • other devices such as a server, etc.
  • the mobile phone sets the processed image as the profile picture of the contact "Xiaohong”.
  • FIG. 3B is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of the application.
  • the terminal device is a mobile phone
  • the terminal interface includes interface B1, interface B2, and interface B3.
  • interface B1 There are social applications installed in the mobile phone. Users can post photos through social applications.
  • the social applications can be facebook, WeChat, QQ, etc.
  • the user can click the "post photos" icon in the social application to make the mobile phone display the interface for selecting photos (interface B2).
  • the mobile phone displays photos that can be published.
  • the photos that can be published can be images in the local database of the mobile phone, images taken in time by the mobile phone, images in the network, etc.
  • the user can select a photo in the interface B2, so that the mobile phone displays the interface B3.
  • the mobile phone can process the photos selected by the user through the image processing method shown in this application, and display the processed images in the interface B3.
  • the user publishes the photo through the social application program
  • other users can view the photo published by the user.
  • other devices such as a server, etc.
  • FIG. 3C is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of the application.
  • the terminal device is a smart watch
  • the terminal interface includes an interface C1, an interface C2, and an interface C3.
  • interface C1 The user can control the smart watch to display the setting interface.
  • the setting interface includes the "dial setting” icon.
  • the user can click on the "dial setting” icon to make the smart watch.
  • the photo selection page is displayed (interface C2).
  • the smart watch displays a picture that can be used for dial setting.
  • the picture that can be used for dial setting can be an image in the local database of the smart watch or an image in the network.
  • the user can select a photo in the interface C2, so that the smart watch displays the interface 403.
  • the smart watch can image the photo selected by the user through the image processing method shown in this application, and set the dial of the smart watch as the processed image. After the dial of the smart watch is set as the processed image, the current time can be displayed on the terminal watch.
  • other devices for example, mobile phones, servers, etc.
  • FIG. 3D is a schematic diagram of a terminal interface in another application scenario provided by an embodiment of the application.
  • terminal devices include mobile phones and smart watches
  • terminal interfaces include mobile phone interface D1, mobile phone interface D2, watch interface D3, and watch interface D4.
  • the interface of the phone is the phone interface D1
  • the interface of the watch is the watch interface D3.
  • the mobile phone interface D1 When the mobile phone displays an image (the image can be a local image of the mobile phone or an image on the network), the mobile phone can display at least one operation option of the image, for example, as shown in Figure 3D
  • the operation options for the image displayed in the interface D1 include "copy", "use as wallpaper” and "assign to device".
  • the mobile phone displays an image the user can operate the preset icon or preset button in the mobile phone, so that the mobile phone displays at least one operation option of the image. Assuming that the user needs to set the image as the dial of the smart watch, the user can click the "assigned to device" icon to make the mobile phone display the mobile phone interface D2.
  • the mobile phone displays the device that can be specified.
  • the mobile phone can process the image through the image processing method shown in this application and send a setting instruction to the smart watch.
  • the setting instruction includes the processed
  • the smart watch updates the dial to the processed image according to the setting instruction.
  • the interface after the smart watch updates the dial is as shown in the watch interface D4.
  • other devices for example, smart watches, servers, etc.
  • Figures 3A-3D are just examples to illustrate the applicable scenarios of this application.
  • the applicable scenarios of this application may also include others.
  • it may also be applicable to setting an image as the screen of a terminal device and sending an image to Other terminal equipment, etc. This application does not specifically limit the applicable scenarios.
  • FIG. 4 is a schematic flowchart of an image processing method provided by an embodiment of the application. Referring to Figure 4, the method may include:
  • S401 Determine a salient object in the first image.
  • the execution subject of the embodiments of the present application may be a terminal device or a server, or may be an image processing apparatus provided in the terminal device or the server.
  • the image processing device can be realized by software, or by a combination of software and hardware.
  • the first image is an image to be processed.
  • the embodiment shown in FIG. 4 may be started to be executed under the trigger of the user.
  • the manner in which the user triggers the execution of the embodiment shown in FIG. 4 is also different.
  • the application scenario is the application scenario shown in the embodiment shown in FIG. 2
  • the user triggers the execution of the embodiment shown in FIG. 4 as follows: the user clicks on the "assigned to contact" icon in the interface 201, and In the interface 202, the contact "Xiaohong" is selected.
  • the application scenario is the application scenario shown in the embodiment shown in FIG. 3
  • the user triggers the execution of the embodiment shown in FIG. 4 as follows: the user clicks on the "post photo” icon in the interface 301 and selects in the interface 302 Took a photo.
  • determining the salient object in the first image can also be understood as: determining the area (for example, pixel position, etc.) where the salient object is located in the first image. "Determining the salient object” and “determining the area where the salient object is located” shown below have the same meaning.
  • the salient object can be determined in the first image through the saliency detection model: the data representing the first image is input to the saliency detection model, and the saliency detection model processes the data representing the first image and outputs the representation Data of salient objects.
  • the data representing the first image may be the first image itself, or a grayscale image of the first image.
  • the data representing the salient object can be the position of the salient object in the first image (for example, the pixel position), or the binary image of the first image (the object in the area with the largest or smallest gray value in the binary image is Notable objects).
  • the binary image includes two kinds of gray-scale pixels, one is white pixels, and the other is black pixels.
  • a binary image can include pixels with a gray level of 0 and pixels with a gray level of 255. .
  • the saliency detection model is obtained by learning from multiple sets of samples.
  • Each set of samples includes sample images and sample salient objects in the sample images, and the sample salient objects can be manually labeled.
  • the sample salient object can be represented by the position (for example, the pixel position) of the sample salient object in the sample image.
  • FIG. 5A is a schematic diagram of a pre-processing image provided by an embodiment of the application.
  • FIG. 5B is a schematic diagram of a processed image provided by an embodiment of the application.
  • the data representing Fig. 5A (the grayscale image of Fig. 5A or Fig. 5A, etc.) can be input to the saliency detection model, and the saliency detection model can process the data representing Fig. 5A, Output data representing salient objects.
  • the output of the saliency detection model may be shown in FIG. 5B, and the object in the area with the largest gray value in FIG. 5B is the salient object.
  • the salient objects detected in the first image may not be determined by the saliency detection model, or the salient objects detected in the first image are of low quality (for example, the detected salient objects are too large or too large). Wait).
  • the salient object of the first image can also be obtained through the image semantic segmentation model.
  • Identify salient objects in the first image through the image semantic segmentation model input data representing the first image into the image semantic segmentation model, and the image semantic segmentation model processes the data representing the first image and outputs data representing the salient object.
  • the data representing the first image may be the first image itself, or a grayscale image of the first image.
  • the data representing the salient object can be the position of the salient object in the first image (for example, the pixel position), or the weight value of each part of the semantic segmentation image and the semantic segmentation image. The weight value is greater than the preset threshold, and the weight value The largest part of the image is a salient object.
  • the image semantic segmentation model can identify objects in the image, and segment the image according to the objects in the image to obtain multiple partial images, each of which includes an object.
  • the weight value of multiple objects can be preset in the image semantic segmentation model. For example, the weight value of characters is 10, the weight value of animals is 9, the weight value of buildings is 8, the weight value of food is 7, and the weight value of vehicles Is 6, the weight of the sky is 5, etc.
  • the image semantic segmentation model can calculate the weight value of part of the image corresponding to the object according to the weight value of the object and the image area where the object is located in the image.
  • the saliency detection model is obtained by learning multiple sets of samples.
  • Each set of samples includes a sample image and a sample segmentation image.
  • the sample segmentation image includes multiple segmented partial images.
  • the segmented multiple partial images can be manually labeled .
  • FIG. 5C is a schematic diagram of another image before processing provided by an embodiment of the application.
  • FIG. 5D is a schematic diagram of another processed image provided by an embodiment of the application.
  • the data representing Figure 5C (the grayscale image of Figure 5C or Figure 5C, etc.) can be input to the image semantic segmentation model, and the image semantic segmentation model can process the data representing Figure 5C.
  • Output data representing salient objects can be the weight value of each part of the image in Figure 5D and Figure 5D.
  • Figure 5D includes multiple partial images, for example, partial images representing the sky, partial images representing buildings, and parts representing water image.
  • the objects in the part of the image where the weight value is greater than the preset threshold and the weight value is the largest are the salient objects.
  • salient objects can also be detected through the saliency detection model and the semantic segmentation model at the same time.
  • FIG. 6 the process of detecting salient objects through the saliency detection model and the semantic segmentation model will be described.
  • FIG. 6 is a schematic diagram of an image processing process provided by an embodiment of the application. Please refer to FIG. 6, which includes image 601, image 602, image 603, image 604, image 605, and image 606.
  • the input (image 601 or grayscale image of image 601, etc.) representing the image 601 to be detected is input to the saliency detection model and the image semantic segmentation model, respectively.
  • the saliency detection model processes the data representing the image 601 to output data representing the salient object.
  • the output of the saliency detection model may be shown in the image 602, and the object in the region with the largest gray value in the image 602 is the salient object.
  • the salient object detected by the salient detection model is the object shown in the rectangular frame of the image 603.
  • the image semantic segmentation model can process the data representing the image 601 to output data representing salient objects.
  • the output of the image semantic segmentation model may be the image 604 and the weight value of each part of the image in the image 604.
  • the image 604 includes multiple partial images, for example, a partial image representing an animal's head, a partial image representing a grass, and so on.
  • the objects in the part of the image with the weight value greater than the preset threshold value and the largest weight value in the image 604 are the salient objects.
  • the object representing the head of the animal is a salient object (shown in image 605), that is, the salient object detected by the image semantic segmentation model is image 606 The object shown in the rectangular box.
  • the salient object detected by the saliency detection model is too large, the salient object detected by the image semantic segmentation model can be determined as the salient object of the image 601.
  • the salient object may not be determined in the first image through the image semantic segmentation model.
  • the salient object cannot be determined according to the image semantic segmentation model.
  • the salient object of the first image can also be acquired by means of straight line detection.
  • Straight line detection is used to detect obvious straight lines in the image.
  • edge detection may be performed on the first image to obtain a gradient image, and then edge detection may be performed on the gradient image by a straight line detection algorithm to obtain a straight line in the first image.
  • the edge detection algorithm may include Sobel algorithm, Canny algorithm, and so on.
  • the image semantic segmentation process may be performed on the first image first (for example, the image semantic segmentation process may be performed on the image through the above-mentioned image semantic segmentation model) to obtain the semantic segmentation image of the first image, and then the semantic segmentation process may be performed by a line detection algorithm Segment the image for edge detection to obtain straight lines in the first image.
  • the line detection algorithm may include the Hough Line algorithm, the Line Segment Detector (LSD) algorithm, and so on.
  • the principle of Hough line detection is to convert the points in the image from the Cartesian coordinate system to a parameter space, and use statistical methods to calculate the number of points on the line to find possible lines.
  • LSD is to calculate the gradient size and direction of the point, and determine the connected domain according to the gradient size and direction of the calculated point, and perform straight line detection according to the connected domain.
  • the salient objects can be determined based on the intersection points of the straight lines. For example, the objects in the area where the intersection points of the straight lines are located can be determined as salient objects.
  • FIG. 7A is a schematic diagram of another image before processing according to an embodiment of the application.
  • FIG. 7B is a schematic diagram of another processed image provided by an embodiment of the application.
  • a straight line detection can be performed on 7A to obtain a straight line detection image as shown in FIG. 7B, and the object in the area where the intersection of multiple straight lines in FIG. 7B is located can be determined as the salient object.
  • the image area can be determined in the first image according to the salient object, and the image area can be processed to determine the second image.
  • the image area may be a rectangular area, a circular area, or the like. In the following, description will be given by taking the image area as the first circular area as an example.
  • S402 Determine a first circular area in the first image according to the salient object.
  • the first circular area includes a salient object.
  • the first circular area may be the smallest circular area including a salient object.
  • the smallest circular area including the salient object refers to a circular area with the smallest diameter that can include all pixels in the salient object.
  • FIG. 8 is a schematic diagram of another image provided by an embodiment of the application. Please refer to Figure 8. Assuming that the salient object is determined to be a flower on the right, the area in the circular box in Figure 8 is the first circular area.
  • S404 Determine whether the first ratio is between the first threshold and the second threshold.
  • the first threshold and the second threshold are a number between 0-1, and the first threshold is less than the second threshold.
  • the first threshold may be 0.33
  • the second threshold may be 0.618.
  • S405 Determine a third circular area in the first image.
  • the ratio of the diameter of the first circular area to the diameter of the third circular area is a preset ratio, the center of the third circular area, the center of the first circular area and the center of the first image The center is located on the same straight line, and the first circular area is inscribed with the third circular area (the first circular area is an inscribed circle of the third circular area).
  • the preset ratio is a value between 0.5 and 1.
  • the preset ratio may be 0.618.
  • the initial circle center can be determined according to the circle of the first circular area and the center of the first image. According to the diameter of the first circular area and the preset ratio, the diameter of the third circular area is determined. And make a circle according to the initial circle center and the diameter of the third circular area, so that the first circular area is an inscribed circle of the third circular area.
  • S406 Determine whether a part of the third circular area exists outside the first image.
  • the third circular area may be translated and/or rotated through the following feasible implementation manners.
  • a possible situation a part of the third circular area is located outside an edge of the first image.
  • the third circular area is translated along the horizontal or vertical direction until When the translated third circular area is all located within the first image (the third circular area is tangent to the edge of the first image), the translated third circular area is determined as the second circular area. For example, when the upper half of the third circular area is outside the first image, the third circular area is translated downward in the vertical direction, and when the left half of the third circular area is outside the first image , Then move the third circular area to the right in the horizontal direction.
  • the first preset angle for example, 5 degrees, 8 degrees, etc.
  • FIG. 9 is a schematic diagram of another image provided by an embodiment of the application.
  • the center of the first image is O
  • the center of the first circular area is determined to be A1 in the first image
  • the center of the third circular area before translation is A2
  • the third circle after translation The center of the area is A3.
  • the center of the third circular area is A3, and the third circular area is all located in the first image. O, A1 and A3 are not on the same straight line, and the first circular area and the third circular area are not inscribed.
  • the third circular area after translation is determined as the second circular area.
  • the third circular area when there is an included angle between the first included angle and the second included angle that is smaller than the first preset included angle, the third circular area can be translated to realize that all of the third circular area is located in the first image , And the third circular area after translation can cover the first circular area, and the operation method is simple, so that the second circular area can be obtained quickly. Furthermore, the position of the salient object in the second circular area can be made consistent with the position of the salient object in the first image, and the composition in the cropped image can be made consistent with the composition of the first image. The quality of image cropping. For example, if the salient object is located at the upper third line of the first image, the salient object is also located at the upper third line of the second circular area.
  • the third circular area is rotated.
  • rotate the line between the circle of the third circular area and the center of the first circular area The angle is called the rotation angle of the third circular area.
  • the third circular area after rotation is still inscribed with the first circular area (the first circular area is still an inscribed circle of the third circular area).
  • the third circular area In the process of rotating the third circular area, before the third circular area is rotated by a second preset angle (for example, 30 degrees, 35 degrees, etc.), when the third circular area is all located within the first image
  • a second preset angle for example, 30 degrees, 35 degrees, etc.
  • the third circular area after the rotation is determined as the second circular area. If the third circular area is rotated to the second preset angle, and part of the rotated third circular area is still outside the first image, then the rotated third image is translated until the third The images are all within the first image.
  • FIG. 10 is a schematic diagram of another image provided by an embodiment of this application.
  • the center of the first image is O
  • the center of the first circular area is determined to be A1 in the first image
  • the center of the third circular area before rotation is A2
  • the third circle after rotation The center of the area is A3.
  • the third circular area Before rotating the third circular area, O, A1 and A2 are located on the same straight line, and the first circular area and the third circular area are inscribed. It can be seen from FIG. 10 that the lower half of the third circular area is outside the first image. The angle between the line between A1 and A2 and the vertical line (the vertical side of the first image), and the angle between the line between A1 and A2 and the horizontal line (the horizontal side of the first image) are both If the angle is greater than the first included angle, the third circular area can be rotated. Since the lower half of the third circular area is outside the first image, and the tangent point of the first circular area and the third circular area is located at the lower right of the circular area, the third circular area can be moved to the upper right Square rotation.
  • the angle between the first line (the line between A1 and A3) and the second line (the line between A1 and A2) can be the rotation angle of the third circular area.
  • FIG. 11 is a schematic diagram of another image provided by an embodiment of this application.
  • the center of the first image is O
  • the center of the first circular area is determined to be A1 in the first image
  • the center of the third circular area before rotation is A2
  • the third circle after rotation The center of the area is A3
  • the third circular area after translation is A4.
  • the third circular area Before rotating the third circular area, O, A1 and A2 are located on the same straight line, and the first circular area and the third circular area are inscribed. It can be seen from FIG. 11 that the upper half of the third circular area is outside the first image. The angle between the line between A1 and A2 and the vertical line (the vertical side of the first image), and the angle between the line between A1 and A2 and the horizontal line (the horizontal side of the first image) are both If the angle is greater than the first included angle, the third circular area can be rotated. Since the upper half of the third circular area is outside the first image, and the tangent point of the first circular area and the third circular area is located at the lower right of the circular area, the third circular area can be moved to the lower left Square rotation. For the rotation process of the third circular area, reference may be made to the rotation process shown in the embodiment of FIG. 10, which will not be repeated here.
  • the third circular area After rotating the third circular area by the second preset angle, and there are still some areas in the third circular area outside the first image, the third circular area is translated. Since the upper half of the third circular area is outside the first image, the third circular area is translated downward until the third circular area is all located in the first image. After the third circular area is translated, the center of the third circular area is A4, and the third circular area is all located in the first image. O, A1 and A4 are not located on the same straight line, and the first circular area and the third circular area are not inscribed. The third circular area after translation is determined as the second circular area.
  • the third circular area is rotated, or the third circular area is rotated and translated, to achieve the first All of the three circular areas are located in the first image, and the third circular area after translation can cover the first circular area.
  • the position of the salient object in the second circular area can also be obtained by the above method, It is consistent with the position of the salient object in the first image, so that the composition in the cropped image can be consistent with the composition of the first image, which improves the quality of image cropping.
  • the third circular area can be translated in the horizontal and vertical directions until all of the third circular area is within the first image, and the third circular area is determined as the second Circular area.
  • FIG. 12 is a schematic diagram of another image provided by an embodiment of this application. Please refer to Figure 12, the center of the first image is O, the center of the first circular area is determined to be A1 in the first image, the center of the third circular area before horizontal translation and before vertical translation is A2, horizontal translation The center of the third circular area after and before the vertical translation is A3, and the center of the third circular area after the horizontal translation and after the vertical translation is A4.
  • O, A1 and A2 are located on the same straight line, and the first circular area and the third circular area are inscribed. It can be seen from FIG. 12 that the lower half and the right half of the third circular area are outside the first image, and the third circular area can be translated horizontally and vertically.
  • the third circular area After the third circular area is translated in the horizontal direction, continue to translate the third circular area in the vertical direction. Since the lower half of the third circular area is outside the first image, you can move the third circular area upward. The circular area, until the third circular area is tangent to the lower edge of the first image, stop moving the third circular area upward. After the third circular area is vertically translated, the center of the third circular area is A4. O, A1 and A4 are not located on the same straight line, and the first circular area and the third circular area are not inscribed. The third circular area after translation is determined as the second circular area.
  • the third circular area when a part of the third circular area is located outside the two sides of the first image, the third circular area can be translated to realize that all of the third circular area is located in the first image. Operation
  • the method is simple, so that the second circular area can be quickly obtained. Further, the position of the salient object in the second circular area can be made consistent with the position of the salient object in the first image, so that the composition of the cropped image can be consistent with the composition of the first image, thereby improving the image The quality of the cut.
  • S408 Determine the third circular area as the second circular area.
  • the third circular area is determined as the second circular area.
  • S409 Determine the rectangular area and the side length of the square area in the first image.
  • the rectangular area is the smallest rectangular area including the salient object.
  • FIG. 13 is a schematic diagram of another image provided by an embodiment of the application. Please refer to Figure 13. Assuming that the salient object is determined to be a flower on the right, the area in the rectangular box in Figure 13 is the rectangular area.
  • the side length of the square area is equal to the shortest side length of the first image.
  • the side length of the square area is equal to the width of the first image shown in FIG. 13.
  • S410 Determine whether the square area can completely cover the rectangular area according to the size of the rectangular area and the side length of the square area.
  • S411 Acquire the position of the center of gravity of the first image in the first image and the center of gravity of the salient object.
  • the position of the center of gravity of the first image in the first image is at least one of the following positions: a position close to the center, a position close to the third line, or a position close to the edge.
  • Positions near the three-point line include: near the upper three-point line, near the bottom three-point line, near the left three-point line, and near the right three-point line.
  • the position near the edge includes: near the upper edge, near the lower edge, near the left edge, and near the right edge.
  • the position of the center of gravity of the first image in the first image may be obtained by the following feasible implementation manners: determining the center of gravity of the first image; obtaining the first distance between the center of gravity of the first image and the center of the first image , The second distance between the center of gravity of the first image and the first third line of the first image, and the third distance between the center of gravity of the first image and the first edge of the first image; according to the first distance and the second distance And the third distance to determine the position of the center of gravity of the first image in the first image.
  • the distance between the center of gravity of the first image and the first line of thirds is the shortest.
  • the edges of the first image the center of gravity of the first image is the same as the first edge. The distance is the closest.
  • the first distance is smaller than the second distance and the third distance, it is determined that the position of the center of gravity of the first image in the first image is close to the center position.
  • the second distance is less than the first distance and the third distance, it is determined that the position of the center of gravity of the first image in the first image is close to the position of the third line.
  • the first third line is the upper third line, the position of the center of gravity of the first image in the first image is close to the upper third line.
  • the first third line is the lower third line, the position of the center of gravity of the first image in the first image is close to the lower third line.
  • the first third line is the left third line, the position of the center of gravity of the first image in the first image is close to the left third line.
  • the first third line is the right third line, the position of the center of gravity of the first image in the first image is close to the right third line.
  • the third distance is less than the first distance and the second distance, it is determined that the position of the center of gravity of the first image in the first image is close to the edge position. If the first edge is the upper edge, the position of the center of gravity of the first image in the first image is close to the upper edge position. If the first edge is the lower edge, the position of the center of gravity of the first image in the first image is close to the lower edge. If the first edge is the left edge, the position of the center of gravity of the first image in the first image is close to the left edge position. If the first edge is the right edge, the position of the center of gravity of the first image in the first image is close to the right edge position.
  • S412 Determine a square area according to the position of the center of gravity of the first image in the first image and the center of gravity of the salient object.
  • a possible situation the position of the center of gravity of the first image in the first image is close to the center position.
  • the square area is determined according to the center of gravity of the salient object and the center of the square area, and the center of gravity of the salient object is located at the center of the square area.
  • FIG. 14 is a schematic diagram of still another image provided by an embodiment of this application.
  • the salient object determined in the first image is an animal
  • the rectangular area in FIG. 14 is the smallest rectangular area including the salient object (animal).
  • the animal is located in the center of the first image, and it can be determined that the center of gravity of the first image is located in the center of the first image. Therefore, the square area shown in Figure 14 can be determined, where the side length of the square area Equal to the width of the first image, the rectangular area is located at the center of the square area.
  • the first three-point line and the second three-point line are of the same type, and the three-point line types include the upper three-point line, the lower three-point line, the left three-point line, and the right three-point line.
  • FIG. 15 is a schematic diagram of another image provided by an embodiment of this application.
  • the rectangular area is as shown in FIG. 15, and the rectangular area in FIG. 15 is the smallest rectangular area including the salient object (ball).
  • the ball is located at the right third of the first image, and it can be determined that the center of gravity of the first image is at the right third of the first image. Therefore, the square area shown in Figure 15 can be determined, where , The side length of the square area is equal to the width of the first image, and the rectangular area is located at the right third of the square area.
  • the second edge is of the same type as the first edge, and the types of edges include upper edge, lower edge, left edge and right edge.
  • FIG. 16 is a schematic diagram of another image provided by an embodiment of this application.
  • the salient object determined in the first image is a cartoon character
  • the rectangular area in FIG. 16 is the smallest rectangular area including the salient object (cartoon character).
  • the cartoon character is located on the left edge of the first image, and it can be determined that the center of gravity of the first image is located on the left edge of the first image. Therefore, it can be determined that the square area shown in Figure 16 can be obtained.
  • the side length is equal to the width of the first image, and the rectangular area is located at the left edge of the square area.
  • the position of the rectangular area in the square area is determined according to the position of the center of gravity of the first image in the first image, so that the position of the salient object in the square area can be consistent with the position of the salient object in the first image Therefore, the composition of the cropped image can be made consistent with the composition of the first image, and the quality of image cropping can be improved.
  • S413 Determine a square area according to the rectangular area, where the square area is located in the middle of the rectangular area.
  • FIG. 17 is a schematic diagram of still another image provided by an embodiment of the application.
  • the rectangular area is shown in FIG. 17, and the rectangular area in FIG. 17 is the smallest rectangular area including the salient object (cartoon character).
  • the side length of the rectangular area determined in Figure 17 is equal to the width of the first image.
  • the square area located anywhere in the first image cannot make the square area completely cover the rectangular area. Therefore, the square area can be set in the rectangular area. middle place.
  • S414 Determine the inscribed circle of the square area as the second circular area.
  • S415 Crop the first image according to the second circular area to obtain a second image.
  • FIG. 18 is a schematic diagram of image cropping provided by an embodiment of the application. Refer to FIG. 18, which shows multiple images and a second image obtained by cropping the multiple images.
  • the processing steps (S401-S415) shown in the embodiment in FIG. 4 do not constitute a specific limitation on the image processing process.
  • the image processing process may include more or fewer steps than the embodiment in FIG. 4, for example, the image processing process may include part of the steps in the embodiment in FIG. 4, or, in the embodiment in FIG. Some steps in may be replaced by steps with the same function, or some steps in the embodiment of FIG. 4 may be split into multiple steps, etc.
  • the image processing method provided by the embodiment of the application first obtains a salient object in the first image to be processed, and performs cropping processing on the first image according to the position of the salient object in the first image to obtain the cropped second image
  • the position of the salient object in the first image can be consistent with the position of the salient object in the second image
  • the composition of the second image after cropping can be The composition of the first image is consistent, which improves the quality of image cropping.
  • FIG. 19 is a schematic flowchart of another image processing method provided by an embodiment of the application. Referring to Figure 19, the method may include:
  • the terminal device displays a first image.
  • the first image has a first size.
  • the first image may be a local image of the terminal device (for example, an image in a gallery of the terminal device), or a network image.
  • the shape of the first image may be square, rectangle, polygon, and so on.
  • the terminal device may display a maximized image of the first image according to the size of the first image.
  • the terminal device displays the maximized image of the first image according to the size of the first image.
  • the terminal device may also display a thumbnail of the first image.
  • the terminal device displays a thumbnail of the first image.
  • the terminal device may receive a user's operation to display the first image.
  • the user can open the local gallery of the terminal device, and open the first image in the local gallery, so that the terminal device displays the first image.
  • the user can operate the terminal function in the terminal device to make the terminal device display the first image.
  • the user clicks on the "post photo" icon in the social application to make the terminal device The first image is displayed.
  • the terminal device receives the user's operation.
  • the user's operation is any one of the following operations: avatar setting operation, screen setting operation, picture sharing operation, address book operation, and picture sending operation.
  • the avatar setting operation may include: the user clicks the "assign to contact” icon in the interface A1, and the user clicks the "little red” icon in the interface A2.
  • the image sharing operation may include: the user clicks on the "post photo" icon in the interface B1, and the user clicks on the photo input.
  • the screen setting operation may include: clicking the "dial image” icon in the user interface C1, and the user clicking the photo input.
  • the terminal device obtains a second image from the first image.
  • the second image has a second size, the second size is smaller than the first size, and the second image includes salient content on the first image.
  • the salient content refers to the image content including salient objects.
  • Fig. 1A The salient object in Fig. 1A is a cartoon character, and the salient content is the circular image area where the cartoon object is located.
  • Fig. 1B The salient object in Fig. 1B is an animal, and the salient content is the circular image area where the animal is located.
  • the terminal device may process the first image by using the method shown in the embodiment in FIG. 4 to obtain the second image.
  • the terminal device may request other devices (for example, a server, etc.) to process the first image through the method shown in the embodiment of FIG. 4 to obtain the second image, and the terminal device may then obtain the second image from the other device.
  • other devices for example, a server, etc.
  • the terminal device or the server processes the first image through the method shown in the embodiment of FIG. 4, part of the steps in the embodiment of FIG. 4 may be used to process the first image, or the image 4 examples
  • the terminal device displays the second image.
  • the second image may be displayed on the display page corresponding to the terminal function of the terminal device.
  • the terminal function is the avatar setting function
  • the interface A3 is the display page corresponding to the terminal function.
  • the terminal function is a picture sharing function
  • interface B3 is a display page corresponding to the terminal function.
  • the terminal function is a screen setting function
  • the interface C3 is a display page corresponding to the terminal function.
  • the user can input an operation in the terminal device to make the terminal device display the second image in the first image, and the second image is the first image.
  • the second image includes salient content in the first image.
  • the salient object is first obtained in the first image to be processed, and the first image is cropped according to the position of the salient object in the first image to obtain the cropped second image.
  • Image in this way, not only can the second image include the salient object, but also the position of the salient object in the first image can be consistent with the position of the salient object in the second image, so that the composition of the second image after cropping can be made Consistent with the composition of the first image, the quality of image cropping is improved.
  • FIG. 20 is a schematic structural diagram of an image processing apparatus provided by an embodiment of the application.
  • the image processing apparatus 10 may include a memory 11 and a processor 12, where the memory 11 and the processor 12 communicate; for example, the memory 11 and the processor 12 may communicate through a communication bus 13, and the memory 11 uses
  • the processor 12 executes the computer program to implement the above-mentioned image processing method.
  • FIG. 21 is a schematic structural diagram of a terminal device provided by an embodiment of the application.
  • the terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, and a battery 142, Antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, A display 194, and a subscriber identification module (SIM) card interface 195, etc.
  • SIM subscriber identification module
  • the sensor module 180 may include pressure sensor 180A, gyroscope sensor 180B, air pressure sensor 180C, magnetic sensor 180D, acceleration sensor 180E, distance sensor 180F, proximity light sensor 180G, fingerprint sensor 180H, temperature sensor 180J, touch sensor 180K, ambient light Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the terminal device 100.
  • the terminal device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc.
  • AP application processor
  • modem processor modem processor
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • the different processing units may be independent devices or integrated in one or more processors.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / Or Universal Serial Bus (USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB Universal Serial Bus
  • the I2C interface is a two-way synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may include multiple sets of I2C buses.
  • the processor 110 may be coupled to the touch sensor 180K, charger, flash, camera 193, etc. through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface to realize the touch function of the terminal device 100.
  • the I2S interface can be used for audio communication.
  • the processor 110 may include multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to realize communication between the processor 110 and the audio module 170.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through an I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communication to sample, quantize and encode analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 may also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a two-way communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through a UART interface, so as to realize the function of playing music through a Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with the display 194, the camera 193 and other peripheral devices.
  • the MIPI interface includes a camera serial interface (camera serial interface, CSI), a display serial interface (display serial interface, DSI), and so on.
  • the processor 110 and the camera 193 communicate through a CSI interface to implement the shooting function of the terminal device 100.
  • the processor 110 and the display 194 communicate through a DSI interface to realize the display function of the terminal device 100.
  • the interface connection relationship between the modules illustrated in the embodiment of the present application is merely a schematic description, and does not constitute a structural limitation of the terminal device 100.
  • the terminal device 100 may also adopt different interface connection modes in the foregoing embodiments, or a combination of multiple interface connection modes.
  • the mobile communication module 150 may provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the terminal device 100.
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering, amplifying and transmitting the received electromagnetic waves to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic waves for radiation via the antenna 1.
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110.
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low-frequency baseband signal is processed by the baseband processor and then passed to the application processor.
  • the application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display 194.
  • the modem processor may be an independent device.
  • the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the terminal device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites.
  • WLAN wireless local area networks
  • BT wireless fidelity
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication technology
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110.
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic wave radiation via the antenna 2.
  • the antenna 1 of the terminal device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the terminal device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite-based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite-based augmentation systems
  • the terminal device 100 implements a display function through a GPU, a display 194, and an application processor.
  • the GPU is a microprocessor for image processing, connected to the display 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
  • the display 194 is used to display images, videos, etc.
  • the display 194 includes a display panel.
  • the display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light emitting diode). diode, AMOLED), flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
  • the terminal device 100 may include 1 or N displays 194, and N is a positive integer greater than 1.
  • the terminal device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display 194, and an application processor.
  • the ISP is used to process the data fed back from the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transfers the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
  • ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the terminal device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the terminal device 100 may support one or more video codecs. In this way, the terminal device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
  • MPEG moving picture experts group
  • MPEG2 MPEG2, MPEG3, MPEG4, etc.
  • NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • the NPU can realize applications such as intelligent cognition of the terminal device 100, such as image recognition, face recognition, voice recognition, text understanding, and so on.
  • the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
  • the internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, at least one application program (such as a sound playback function, an image playback function, etc.) required by at least one function.
  • the data storage area can store data (such as audio data, phone book, etc.) created during the use of the terminal device 100.
  • the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.
  • the processor 110 executes various functional applications and data processing of the terminal device 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the terminal device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. For example, music playback, recording, etc.
  • the audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal.
  • the audio module 170 can also be used to encode and decode audio signals.
  • the audio module 170 may be provided in the processor 110, or part of the functional modules of the audio module 170 may be provided in the processor 110.
  • An embodiment of the present application provides a storage medium, where the storage medium is used to store a computer program, and the computer program is used to implement the foregoing image processing method when the computer program is executed by a computer or a processor.
  • the embodiments of the present application provide a computer program product.
  • the computer program product includes instructions that, when executed, cause a computer to execute the above-mentioned image processing method.
  • the embodiment of the application provides a system on a chip or a system chip, the system on a chip or a system chip may be applied to a terminal device, the system on a chip or the system chip includes: at least one communication interface, at least one processor, and at least one The memory, the communication interface, the memory, and the processor are interconnected by a bus, and the processor executes the instructions stored in the memory so that the terminal device can execute the above-mentioned image processing method.
  • All or part of the steps in the foregoing method embodiments can be implemented by a program instructing relevant hardware.
  • the aforementioned program can be stored in a readable memory.
  • the program executes the steps of the above-mentioned method embodiments; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state hard disk, magnetic tape (magnetic tape), floppy disk (floppy disk), optical disc (optical disc) and any combination thereof.
  • These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing equipment are generated for use It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
  • the term “including” and its variations may refer to non-limiting inclusion; the term “or” and its variations may refer to “and/or”.
  • the terms “first”, “second”, etc. in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
  • “plurality” means two or more.
  • “And/or” describes the association relationship of the associated objects, indicating that there can be three types of relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone.
  • the character “/” generally indicates that the associated objects are in an "or” relationship.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Multimedia (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本申请实施例提供一种图像处理方法、装置及设备,该方法包括:显示第一图像,第一图像具有第一尺寸;接收用户的操作,所述用户的操作为如下操作中的任意一种:头像设置操作、屏幕设置操作、图片分享操作、通讯录操作、图片发送操作;显示第二图像,所述第二图像具有第二尺寸,所述第二尺寸小于所述第一尺寸,所述第二图像包括第一图像上的显著内容。提高了图像裁剪的质量。

Description

图像处理方法、装置及设备
本申请要求在2019年5月9日提交中国国家知识产权局、申请号为201910386382.9的中国专利申请的优先权,发明名称为“图像处理方法、装置及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种图像处理方法、装置及设备。
背景技术
目前,在很多应用场景中(例如联系人头像设置、智能手表桌面设置等),需要对原始图像进行裁剪以得到裁剪图像,并使用裁剪图像。
在现有技术中,通常在原始图像的中间位置进行图像裁剪,以得到裁剪图像。然而,在原始图像的中间位置进行裁剪得到的图像中可能不包括原始图像中的显著对象(用户较为感兴趣的对象),导致图像裁剪的质量较差。
发明内容
本申请提供一种图像处理方法、装置及设备,提高了图像裁剪的质量。
第一方面,本申请实施例提供一种图像处理方法,该方法可以包括:显示具有第一尺寸的第一图像,接收用户的操作,用户的操作为如下操作中的任意一种:头像设置操作、屏幕设置操作、图片分享操作、通讯录操作、图片发送操作;显示具有第二尺寸的第二图像,第二尺寸小于第一尺寸,第二图像包括第一图像上的显著内容。
在上述过程中,在终端设备显示第一图像后,用户可以在终端设备中输入操作,以使终端设备显示第一图像中的第二图像,第二图像为第一图像中的一部分,且第二图像包括第一图像中的显著内容,提高了图像裁剪的质量。
在一种可能的实施方式中,显示第二图像之前,还可以在第一图像中确定显著对象和包括显著对象的第二圆形区域,第二圆形区域的第二直径大于第一圆形区域的第一直径,第二直径小于或等于第一图像的最短边长,第一圆形区域为包括显著对象的最小圆形区域;以及按照第二圆形区域对第一图像进行裁剪,得到第二图像。
在上述过程中,先在待处理的第一图像中获取显著对象,并根据显著对象在第一图像中的位置,对第一图像进行裁剪处理,得到裁剪后的第二图像,这样,不但可以使得第二图像中包括显著对象,还可以使得显著对象在第一图像中的位置与显著对象在第二图像中的位置一致,进而可以使得裁剪后的第二图像的构图与第一图像的构图一致,提高了图像裁剪的质量
在一种可能的实施方式中,可以通过如下可行的实现方式在第一图像中确定包括显著对象的第二圆形区域:获取第一直径与第一图像的最短边长之间的第一比值;若第一比值在第一阈值与第二阈值之间,则根据第二直径和第一直径之间的预设比值,确定第二圆形区域;若第一比值小于第一阈值或者大于第二阈值,则在第一图像中确定正方形区域,并将正方形区域的内接圆区域确定为第二圆形区域,正方形区域中包括显著对象,正方形区域的边长为 第一图像的最短边长。
在上述过程中,在第一比值在第一阈值与第二阈值之间时,说明第一圆形区域在第一图像中所占的比例不是太大,也不是太小,在该种情况下,可以按照第二直径和第一直径之间的预设比值(例如,该预设比值可以为0.618),确定第二圆形区域,使得显著对象在第二圆形区域中所占的大小符合美学构图规则,提高了图像裁剪的质量。在第一比值不在第一阈值与第二阈值之间时,说明第一圆形区域在第一图像中所占的比例太大或则太小,为了避免剪裁得到的第二图像过小或者过大,则在第一图像中确定正方形区域,并将正方形区域的内接圆区域确定为第二圆形区域,提高了图像裁剪的质量
在一种可能的实施方式中,可以通过如下可行的实现方式根据第二直径和第一直径之间的预设比值,确定第二圆形区域:在第一图像中确定第一圆形区域;根据第一圆形区域的圆心、第一图像的中心、第一直径和预设比值,在第一图像中确定第二圆形区域。
在一种可能的实施方式中,根据第一圆形区域的圆心、第一图像的中心、第一直径和预设比值,在第一图像中确定第二圆形区域,包括:可以根据第一圆形区域的圆心、第一图像的中心,在第一图像中确定初始圆心,第一圆形区域的圆心、第一图像的中心和初始圆心在一条直线上;根据第一直径和预设比值,确定第二直径;根据初始圆心和第二直径,在第一图像中确定第二圆形区域。
可选的,根据初始圆心和第二直径,在第一图像中确定第二圆形区域,包括:以初始圆心为圆心、以第二直径为直径确定第三圆形区域,第一圆形区域与第三圆形区域内切;判断第三圆形区域是否存在部分区域位于第一图像之外;若是,则对第三圆形区域进行平移操作和/或旋转操作,直至处理后的第三圆形区域全部位于第一图像之内时,将第一图像中的、处理后第三圆形区域确定为第二圆形区域;若否,则将第三圆形区域确定为第二圆形区域。
在上述过程中,通过上述方法,还可以使得显著对象在第二圆形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量
在一种可能的实施方式中,可以通过如下可行的实现方式在第一图像中确定正方形区域:在第一图像中确定矩形区域,矩形区域为包括显著对象的最小的矩形区域;根据矩形区域的尺寸和正方形区域的边长,在第一图像中确定正方形区域。
在一种可能的实施方式中,根据矩形区域的尺寸和正方形区域的边长,在第一图像中确定正方形区域,包括:根据矩形区域的尺寸和正方形区域的边长,判断正方形区域是否能够完全覆盖矩形区域;若是,则获取第一图像的重心在第一图像中的位置、以及显著对象的重心,根据第一图像的重心在第一图像中的位置、以及显著对象的重心,确定正方形区域;若否,根据矩形区域确定正方形区域,正方形区域位于矩形区域的中间位置。
在上述过程中,根据第一图像的重心在第一图像中的位置确定矩形区域在正方形区域中的位置,可以使得显著对象在正方形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量
在一种可能的实施方式中,获取第一图像的重心在第一图像中的位置,包括:确定第一图像的重心;获取第一图像的重心与第一图像的中心之间的第一距离、第一图像的重心与第一图像的第一三分线之间的第二距离、以及第一图像的重心与第一图像的第一边缘的第三距离;其中,在第一图像的多条三分线中,第一图像的重心与第一三分线之间的距离最近,在第一图像的多个边缘中,第一图像的重心与第一边缘的距离最近;根据第一距离、第二距离和第三距离,确定第一图像的重心在第一图像中的位置,第一图像的重心在第一图像中的位 置为如下位置中的至少一种:靠近中心位置、靠近三分线位置或靠近边缘位置。
在一种可能的实施方式中,根据第一距离、第二距离和第三距离,确定第一图像的重心在第一图像中的位置,包括:若第一距离小于第二距离和第三距离,则确定第一图像的重心在第一图像中的位置为靠近中心位置;若第二距离小于第一距离和第三距离,则确定第一图像的重心在第一图像中的位置为靠近三分线位置;若第三距离小于第一距离和第二距离,则确定第一图像的重心在第一图像中的位置为靠近边缘位置。这样,可以使得显著对象在正方形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量
在一种可能的实施方式中,根据第一图像的重心在第一图像中的位置、以及显著对象的重心,确定正方形区域,包括:若第一图像的重心在第一图像中的位置为靠近中心位置,则根据显著对象的重心和正方形区域的中心确定正方形区域,显著对象的重心位于正方形区域的中心位置;若第一图像的重心在第一图像中的位置为靠近三分线位置,则根据显著对象的重心和正方形区域的第二三分线,确定正方形区域,显著对象的重心位于第二三分线上,第一三分线和第二三分线的类型相同,三分线的类型包括上三分线、下三分线、左三分线和右三分线;若第一图像的重心在第一图像中的位置为靠近边缘位置,则根据显著对象的重心和正方形区域的第二边缘,确定正方形区域,显著对象的重心与第二边缘的距离小于预设距离,第二边缘与第一边缘的类型相同,边缘的类型包括上边缘、下边缘、左边缘和右边缘。这样,可以使得显著对象在正方形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量
在一种可能的实施方式中,在第一图像中确定显著对象,包括:对第一图像进行显著性检测处理、语义分割处理、直线检测处理中的至少一种处理,以在第一图像中确定显著对象。
第二方面,本申请实施例提供一种图像处理装置,包括存储器和处理器,所述处理器执行所述存储器中的程序指令,用于实现第一方面任一项所述的图像处理方法。
第三方面,本申请实施例提供一种存储介质,所述存储介质用于存储计算机程序,所述计算机程序被计算机或处理器执行时用于实现第一方面任一项所述的图像处理方法。
第四方面,本申请实施例提供一种计算机程序产品,所述计算机程序产品包括指令,当所述指令被执行时,使得计算机执行上述第一方面任一项所述的图像处理方法。
第五方面,本申请实施例提供一种芯片上系统或系统芯片,所述芯片上系统或系统芯片可应用于终端设备,所述芯片上系统或系统芯片包括:至少一个通信接口,至少一个处理器,至少一个存储器,所述通信接口、存储器和处理器通过总线互联,所述处理器通过执行所述存储器中存储的指令,使得所述终端设备可执行如本申请第一方面任一所述图像处理方法。
本申请实施例提供的图像处理方法、装置及设备,在终端设备显示第一图像后,用户可以在终端设备中输入操作,以使终端设备显示第一图像中的第二图像,第二图像为第一图像中的一部分,且第二图像包括第一图像中的显著内容,提高了图像裁剪的质量
附图说明
图1A为本申请实施例提供的一种图像的示意图;
图1B为本申请实施例提供的另一种图像的示意图;
图2为本申请实施例提供的一种三分线示意图;
图3A为本申请实施例提供的一种应用场景下的终端界面示意图;
图3B为本申请实施例提供的另一种应用场景下的终端界面示意图;
图3C为本申请实施例提供的再一种应用场景下的终端界面示意图;
图3D为本申请实施例提供的又一种应用场景下的终端界面示意图;
图4为本申请实施例提供的图像处理方法的流程示意图;
图5A为本申请实施例提供的一种处理前图像示意图;
图5B为本申请实施例提供的一种处理后的图像示意图;
图5C为本申请实施例提供的另一种处理前图像示意图;
图5D为本申请实施例提供的另一种处理后的图像示意图;
图6为本申请实施例提供的图像处理过程示意图;
图7A为本申请实施例提供的又一种处理前图像示意图;
图7B为本申请实施例提供的又一种处理后的图像示意图;
图8为本申请实施例提供的另一种图像示意图;
图9为本申请实施例提供的再一种图像示意图;
图10为本申请实施例提供的另一种图像示意图;
图11为本申请实施例提供的又一种图像示意图;
图12为本申请实施例提供的另一种图像示意图;
图13为本申请实施例提供的另一种图像示意图;
图14为本申请实施例提供的再一种图像示意图;
图15为本申请实施例提供的另一种图像示意图;
图16为本申请实施例提供的又一种图像示意图;
图17为本申请实施例提供的再一种图像示意图;
图18为本申请实施例提供的图像裁剪示意图;
图19为本申请实施例提供的另一种图像处理方法的流程示意图;
图20为本申请实施例提供的图像处理装置的结构示意图;
图21为本申请实施例提供的终端设备的结构示意图。
具体实施方式
为了便于对本申请的理解,首先对本申请涉及的概念进行解释说明。
终端设备:可以为任意具有图像处理运算能力的设备。终端设备还可以具有图像显示功能。例如,终端设备可以为手机、电脑、车载设备、可穿戴设备、工业设备、人工智能设备/增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备等。
终端功能:是指终端设备所具备的功能或者终端设备可以实现的功能。终端功能至少包括终端设备本身所具备的功能、以及终端设备中安装的应用程序所具备的功能。终端设备本申请所具备的功能可以是指终端设备在出厂时终端设备所具备的功能。例如,终端功能可以包括:头像设置功能、屏幕设置功能、图片分享功能、通讯录功能、图片发送功能、图像处理功能等。
显著对象:是指图像中包括的较为显著的对象,即,在用户观察一张图像时,用户的注意力(或者兴趣点)会聚焦于显著对象。例如,图像中的显著对象可以为人物、动物、建筑、食物等。下面,结合图1A-图1B,对显著对象进行说明。图1A为本申请实施例提供的一种图像的示意图。图1B为本申请实施例提供的另一种图像的示意图。请参见图1A,该图像中的 显著对象为卡通人物,即,用户观察该图像时,用户的注意力会聚焦在该卡通人物上。请参见图1B,该图像中的显著对象为一只动物,即,用户观察该图像时,用户的注意力会聚焦在该动物上。
图像的三分线:包括上三分线、下三分线、左三分线和右三分线。下面,结合图2,对图像的三分线进行说明。图2为本申请实施例提供的一种三分线示意图。请参见图2,图像在纵向部分可以被直线L3和直线L4平均分为3份,其中,L3为图像的上三分线,L4为图像的下三分线。请参见图1C,图像在横向部分可以被直线L1和直线L2平均分为3份,其中,L1为图像的左三分线,L2为图像的右三分线。
图像的重心:用于指示像素灰度值分布的平均位置。图像的重心与物理质心类似,可以通过如下公式计算图像的重心:
Figure PCTCN2020087529-appb-000001
Figure PCTCN2020087529-appb-000002
其中,X c是重心在水平方向的坐标,Y c是重心在竖直方向的坐标,P i为第i个像素的灰度值,x i为第i个像素在水平方向的坐标,y i为第i个像素在竖直方向的坐标。
构图:还可以称为图像的结构,可以包括图像中的显著对象在图像中的位置。例如,显著对象在图像中的位置可以包括:靠近三分线位置(包括靠近上三分线位置、靠近下三分线位置、靠近左三分线位置和靠近右三分线位置)、靠近中心位置、靠近边缘位置。
为了便于理解,下面,以终端设备为手机为例,介绍本申请可适用的应用场景。
图3A为本申请实施例提供的一种应用场景下的终端界面示意图。请参见图3A,终端设备为手机,终端界面包括界面A1、界面A2和界面A3。
请参见界面A1,在手机显示一张图像(该图像可以为手机本地的图像,也可以为网络中的图像)时,手机可以显示该图像的至少一种操作选项,例如,在图3A所示的示例中,界面A1中显示的图像的操作选项包括“拷贝”、“用作墙纸”和“指定给联系人”。或者,手机显示一张图像时,用户可以对手机中的预设图标或者预设按钮进行操作,以使手机显示出图像的至少一种操作选项。假设用户需要将该图像设置为联系人的头像,则用户可以对“指定给联系人”图标进行点击操作,以使手机显示界面A2。
请参见界面A2,手机显示通讯录,用户可以选择一个联系人,以使得手机可以通过本申请所示的图像处理方法对该图像进行处理,并将处理后的图像设置为选中的联系人的头像。例如,假设用户选择联系人“小红”,则手机可以通过本申请所示的方法对图像进行处理,并将处理后的头像设置为联系人“小红”的头像。当然,还可以由其它设备(例如服务器等)通过本申请所示的图像处理方法对该图像进行处理,并将处理后的图像发送给手机。
请参见界面A3,手机将处理后的图像设置为了联系人“小红”的头像。
图3B为本申请实施例提供的另一种应用场景下的终端界面示意图。请参见图3B,终端设备为手机,终端界面包括界面B1、界面B2和界面B3。
请参见界面B1,手机中安装有社交应用程序,用户可以通过社交APP发表照片,社交应用程序可以为facebook、微信、QQ等。例如,用户可以对社交应用程序中的“发表照片”图标进行点击操作,以使手机显示选择照片的界面(界面B2)。
请参见界面B2,手机显示可发表的照片,例如,可发表的照片可以为手机本地数据库中的图像、手机及时拍摄的图像、网络中的图像等。用户可以在界面B2中选择一张照片,以使手机显示界面B3。
请参见界面B3,手机可以通过本申请所示的图像处理方法对用户选择的照片进行图像处理,并在界面B3中显示处理后的图像。可选的,在用户通过社交应用程序发表该照片之后,其它用户可以查看到该用户发表的照片。当然,还可以由其它设备(例如服务器等)通过本申请所示的图像处理方法对该图像进行处理,并将处理后的图像发送给手机。
图3C为本申请实施例提供的再一种应用场景下的终端界面示意图。请参见图3C,终端设备为智能手表,终端界面包括界面C1、界面C2和界面C3。
请参见界面C1,用户可以对智能手表进行控制操作,以使智能手表显示设置界面,在设置界面中包括“表盘设置”图标,用户可以对该“表盘设置”图标进行点击操作,以使智能手表显示照片选择页面(界面C2)。
请参见界面C2,智能手表显示可进行表盘设置的图片,例如,可进行表盘设置的图片可以为智能手表本地数据库中的图像、网络中的图像等。用户可以在界面C2中选择一张照片,以使智能手表显示界面403。
请参见界面C3,智能手表可以通过本申请所示的图像处理方法对用户选择的照片进行图像处理,并将智能手表的表盘设置为处理后的图像。在将智能手表的表盘设置为处理后的图像之后,可以在终端手表上显示当前时间。当然,还可以由其它设备(例如,手机、服务器等)通过本申请所示的图像处理方法对该图像进行处理,并将处理后的图像发送给智能手表。
图3D为本申请实施例提供的又一种应用场景下的终端界面示意图。请参见图3D,终端设备包括手机和智能手表,终端界面包括手机界面D1、手机界面D2、手表界面D3和手表界面D4。
在t1时刻,手机的界面为手机界面D1,手表的界面为手表界面D3。请参见手机界面D1,在手机显示一张图像(该图像可以为手机本地的图像,也可以为网络中的图像)时,手机可以显示该图像的至少一种操作选项,例如,在图3D所示的示例中,界面D1中显示的图像的操作选项包括“拷贝”、“用作墙纸”和“指定给设备”。或者,手机显示一张图像时,用户可以对手机中的预设图标或者预设按钮进行操作,以使手机显示出图像的至少一种操作选项。假设用户需要将该图像设置为智能手表的表盘,则用户可以对“指定给设备”图标进行点击操作,以使手机显示手机界面D2。
请参见界面D2,手机显示可指定的设备,用户可以选择智能手表后,手机可以通过本申请所示的图像处理方法对该图像进行处理,并向智能手表发送设置指令,设置指令包括处理后的图像,智能手表根据设置指令将表盘更新为该处理后的图像,智能手表更新表盘之后的界面如手表界面D4所示。当然,还可以由其它设备(例如,智能手表、服务器等)通过本申请所示的图像处理方法对该图像进行处理,并将处理后的图像发送给手机。
图3A-图3D只是以示例的形式示意本申请可适用的场景,当然,本申请可适用的场景还可以包括其它,例如,还可以适用于将图像设置为终端设备的屏幕、将图像发送给其它终端设备等。本申请对适用场景不作具体限定。
下面,通过具体实施例对本申请所示的技术方案进行详细说明。需要说明的是,如下实施例可以单独存在,也可以相互结合,对于相同或相似的内容,在不同的实施例中不再重复说明。
图4为本申请实施例提供的图像处理方法的流程示意图。请参见图4,该方法可以包括:
S401、在第一图像中确定显著对象。
本申请实施例的执行主体可以为终端设备、服务器,也可以为设置在终端设备或者服务器中的图像处理装置。可选的,图像处理装置可以通过软件实现,也可以通过软件和硬件的 结合实现。
其中,第一图像为待处理的图像。
可选的,可以在用户的触发下开始执行图4所示的实施例。当图像处理的应用场景不同时,用户触发执行图4所示的实施例的方式也不同。例如,当应用场景为图2实施例所示的应用场景时,用户触发执行图4所示的实施例的方式为:用户对界面201中的“指定给联系人”图标进行点击操作、以及在界面202中选择联系人“小红”。当应用场景为图3实施例所示的应用场景时,用户触发执行图4所示的实施例的方式为:用户对界面301中的“发表照片”图标进行点击操作、以及在界面302中选择了一张照片。
需要说明的是,在第一图像中确定显著对象还可以理解为:在第一图像中确定显著对象所在的区域(例如像素位置等)。下文所示的“确定显著对象”和“确定显著对象所在的区域”具有相同的含义。
可选的,可以通过显著性检测模型在第一图像中确定显著对象:将表示第一图像的数据输入至显著性检测模型,显著性检测模型对表示第一图像的数据进行处理,并输出表示显著对象的数据。表示第一图像的数据可以为第一图像本身,也可以为第一图像的灰度图像等。表示显著对象的数据可以为显著对象在第一图像中的位置(例如像素位置),也可以为第一图像的二值图像(二值图像中灰度值最大或者最小的区域中的对象即为显著对象)。二值图像中包括两种灰度的像素,一种为表示白色的像素,另一种为表示黑色的像素,例如,二值图像中可以包括灰度为0的像素和灰度为255的像素。
显著性检测模型为对多组样本进行学习得到的,每组样本中包括样本图像和样本图像中的样本显著对象,该样本显著对象可以为人工标记的。可以通过样本显著对象在样本图像中的位置(例如,像素位置)表示样本显著对象。
下面,结合图5A-图5B,对通过显著性检测模型检测显著对象的过程进行说明。
图5A为本申请实施例提供的一种处理前图像示意图。图5B为本申请实施例提供的一种处理后的图像示意图。在获取图5A中的显著对象时,可以将表示图5A的数据(图5A或者图5A的灰度图像等)输入至显著性检测模型,显著性检测模型可以对表示图5A的数据进行处理,以输出表示显著对象的数据。例如,显著性检测模型的输出可以为图5B,图5B中灰度值最大的区域中的对象即为显著对象。
需要说明的是,通过显著性检测模型可能无法在第一图像中确定得到的显著对象、或者在第一图像中检测到的显著对象的质量较低(例如,检测到的显著对象过大、过小等)。在该种情况下,还可以通过图像语义分割模型获取第一图像的显著对象。
通过图像语义分割模型在第一图像中确定显著对象:将表示第一图像的数据输入至图像语义分割模型,图像语义分割模型对表示第一图像的数据进行处理,并输出表示显著对象的数据。表示第一图像的数据可以为第一图像本身,也可以为第一图像的灰度图像等。表示显著对象的数据可以为显著对象在第一图像中的位置(例如像素位置),也可以为语义分割图像和语义分割图像中每部分图像的权重值,权重值大于预设阈值,且权重值最大的部分图像为显著对象。
图像语义分割模型可以识别图像中的对象,并根据图像中的对象,对图像进行分割处理,得到多个部分图像,每个部分图像中包括一个对象。可以在图像语义分割模型中预先设置多个对象的权重值,例如,人物的权重值为10,动物的权重值为9,建筑的权重值为8,食物的权重值为7,车辆的权重值为6,天空的权重值为5等。图像语义分割模型可以根据对象的权重值和图像中对象所在的图像面积,计算该对象对应的部分图像的权重值。
显著性检测模型为对多组样本进行学习得到的,每组样本中包括样本图像和样本分割图像,样本分割图像中包括分割的多个部分图像,该分割的多个部分图像可以为人工标记的。
下面,结合图5C-图5D,对通过图像语义分割模型检测显著对象的过程进行说明。
图5C为本申请实施例提供的另一种处理前图像示意图。图5D为本申请实施例提供的另一种处理后的图像示意图。在获取图5C中的显著对象时,可以将表示图5C的数据(图5C或者图5C的灰度图像等)输入至图像语义分割模型,图像语义分割模型可以对表示图5C的数据进行处理,以输出表示显著对象的数据。例如,图像语义分割模型的输出可以为图5D以及图5D中每部分图像的权重值,图5D中包括多个部分图像,例如,表示天空的部分图像、表示建筑的部分图像和表示水的部分图像。图5D中权重值大于预设阈值、且权重值最大的部分图像中的对象即为显著对象。
在实际应用过程中,为了提高显著对象检测的效率和稳定性,还可以同时通过显著性检测模型和语义分割模型检测显著对象。下面,结合图6,对通过显著性检测模型和语义分割模型检测显著对象的过程进行说明。
图6为本申请实施例提供的图像处理过程示意图。请参见图6,包括图像601、图像602、图像603、图像604、图像605和图像606。
请参见图6,在进行显著对象检测时,将表示待检测的图像601的输入(图像601或者图像601的灰度图像等)分别输入至显著性检测模型和图像语义分割模型。
显著性检测模型对表示图像601的数据进行处理,以输出表示显著对象的数据。例如,显著性检测模型的输出可以为图像602所示,图像602中灰度值最大的区域中的对象即为显著对象。相应的,通过显著性检测模型检测得到的显著对象为图像603的矩形框中所示的对象。
图像语义分割模型可以对表示图像601的数据进行处理,以输出表示显著对象的数据。例如,图像语义分割模型的输出可以为图像604以及图像604中每部分图像的权重值,图像604中包括多个部分图像,例如,表示动物头部的部分图像、表示草地的部分图像等。图像604中权重值大于预设阈值、且权重值最大的部分图像中的对象即为显著对象。假设图像604中表示动物头部的部分图像的权重值最大,则可以确定表示动物头部的对象为显著对象(图像605所示),即,通过图像语义分割模型检测得到的显著对象为图像606的矩形框中所示的对象。
由于显著性检测模型检测得到的显著对象过大,因此,可以将图像语义分割模型检测得到的显著对象确定为图像601的显著对象。
需要说明的是,通过图像语义分割模型可能无法在第一图像中确定得到的显著对象,例如,部分图像中最大的权重值小于预设阈值时,则根据图像语义分割模型无法确定得到显著对象。在该种情况下,还可以通过直线检测方式获取第一图像的显著对象。
直线检测用于检测出图像中的明显直线。可选的,可以先对第一图像进行边缘检测(edge detection),得到一个梯度图像,再通过直线检测算法对梯度图像进行边缘检测,以得到第一图像中的直线。边缘检测算法可以包括Sobel算法、Canny算法等。
可选的,还可以先对第一图像进行图像语义分割处理(例如,可以通过上述图像语义分割模型对图像进行语义分割处理),得到第一图像的语义分割图像,再通过直线检测算法对语义分割图像进行边缘检测,以得到第一图像中的直线。
直线检测算法可以包括霍夫直线检测(Hough Line)算法、直线提取检测(Line Segment Detector,LSD)算法等。霍夫直线检测的原理是将图像中的点从笛卡尔坐标系转换到一个参 数空间,并通过统计方法计算直线上点的数量来寻找可能存在的直线。LSD则是通过计算点的梯度大小和方向,并根据计算点的梯度大小和方向确定连通域,并根据连通域进行直线检测。
在第一图像中检测到直线之后,可以根据直线的交汇点确定显著对象,例如,可以将直线的交汇点所在的区域中的对象确定为显著对象。
下面,结合图7A-图7B,对通过图像语义分割模型检测显著对象的过程进行说明。
图7A为本申请实施例提供的又一种处理前图像示意图。图7B为本申请实施例提供的又一种处理后的图像示意图。在获取图7A中的显著对象时,可以对7A进行直线检测,得到直线检测图像如图7B所示,可以将图7B中多条直线的交汇点所在的区域中的对象确定为显著对象。
需要说明的是,上述只是以示例的形式示意确定显著对象的方式,当然,还可以通过其它可行的实现方式在第一图像中确定显著对象,本申请实施例对此不作具体限定。
在第一图像中确定得到显著对象之后,可以根据显著对象在第一图像中确定图像区域,并对该图像区域进行处理,以确定得到第二图像。可选的,图像区域可以为矩形区域、圆形区域等。下面,以图像区域为第一圆形区域为例进行说明。
S402、根据显著对象,在第一图像中确定第一圆形区域。
其中,第一圆形区域中包括显著对象。例如,第一圆形区域可以为包括显著对象的最小圆形区域。包括显著对象的最小圆形区域是指,可以包括显著对象中所有像素的直径最小的圆形区域。
下面,结合图8,对第一圆形区域进行说明。
图8为本申请实施例提供的另一种图像示意图。请参加图8,假设确定得到的显著对象为右边的一朵花,则图8中的圆形框中的区域即为第一圆形区域。
S403、获取第一圆形区域的第一直径与第一图像的最短边长的第一比值。
S404、判断第一比值是否在第一阈值和第二阈值之间。
若是,则执行S405-S408。
若否,则执行S409。
其中,第一阈值与第二阈值为0-1之间的数,第一阈值小于第二阈值。
例如,第一阈值可以为0.33,第二阈值可以为0.618。
S405、在第一图像中确定第三圆形区域。
其中,第一圆形区域的直径与第三圆形区域的直径的比值为预设比值,所述第三圆形区域的圆心、所述第一圆形区域的圆心和所述第一图像的中心位于同一直线,所述第一圆形区域与所述第三圆形区域内切(第一圆形区域为第三圆形区域的内切圆)。
可选的,预设比值为0.5与1之间的数值。例如,预设比值可以为0.618。
可选的,可以根据第一圆形区域的圆形和第一图像的中心,确定初始圆心。根据第一圆形区域的直径和预设比值,确定第三圆形区域的直径。并根据该初始圆心和第三圆形区域的直径做圆,使得第一圆形区域为第三圆形区域的内切圆。
S406、判断第三圆形区域是否存在部分区域位于第一图像之外。
若是,则执行S407。
若否,则执行S408。
S407、对第三圆形区域进行平移操作和/或旋转操作,直至处理后的第三圆形区域全部位于第一图像之内时,将第一图像中的、处理后第三圆形区域确定为第二圆形区域。
可选的,可以通过如下可行的实现方式对第三圆形区域进行平移操作和/或旋转操作。
一种可能的情况:第三圆形区域中存在部分区域位于第一图像的一条边之外。
在该种可能的情况下,可以先确定第一圆形区域的圆心与第三圆形区域的圆心之间的连线,获取该连线与水平线(第一图像的横向边)的第一夹角、以及该连线与垂直线(第一图像的纵向边)的第二夹角。
在第一夹角和第二夹角中存在一个夹角小于第一预设夹角(例如5度、8度等)时,将第三圆形区域沿着水平方向或者垂直方向进行平移,直至平移后的第三圆形区域全部位于第一图像之内(第三圆形区域与第一图像的边缘相切)时,将平移后的第三圆形区域确定为第二圆形区域。例如,当第三圆形区域的上半部分位于第一图像之外时,则将第三圆形区域沿垂直方向向下平移,当第三圆形区域的左半部分位于第一图像之外时,则将第三圆形区域沿水平方向向右平移。
下面,结合图9,对该种可行的实现方式进行说明。图9为本申请实施例提供的再一种图像示意图。请参见图9,第一图像的中心为O,在第一图像中确定得到第一圆形区域的圆心为A1,平移前的第三圆形区域的圆心为A2,平移后的第三圆形区域的圆心为A3。
在对第三圆形区域平移之前,O、A1和A2位于同一直线上,第一圆形区域与第三圆形区域内切。由图9可知,第三圆形区域的上半部分位于第一图像之外。A1与A2之间的连线与垂直线(第一图像的纵向边)之间的夹角小于第一夹角,则对第三圆形区域向下平移,直至第三圆形区域全部位于第一图像中。
在对第三圆形区域平移之后,第三圆形区域的圆心为A3,第三圆形区域全部位于第一图像中。O、A1和A3不位于同一直线上,且第一圆形区域与第三圆形区域不内切。将平移之后的第三圆形区域确定为第二圆形区域。
在上述过程中,在第一夹角和第二夹角中存在一个夹角小于第一预设夹角时,对第三圆形区域平移即可实现第三圆形区域的全部位于第一图像,且使得平移后的第三圆形区域可以覆盖第一圆形区域,操作方法简单,使得可以快速获取得到第二圆形区域。进一步的,还可以使得显著对象在第二圆形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像中的构图与第一图像的构图一致,提高了图像裁剪的质量。例如,显著对象位于第一图像的上三分线位置,则显著对象也位于第二圆形区域的上三分线位置。
在第一夹角和第二夹角均大于第一预设角度(例如5度、8度等)时,对第三圆形区域进行旋转。例如,可以以第一圆形区域的圆心为圆心、第一圆形区域的圆心和第三圆形区域的圆心之间的线段为半径做旋转圆,控制第三圆形区域的圆心在该旋转圆上移动,进而实现旋转第三圆形区域,在第三圆形区域的圆心移动的过程中,将第三圆形区域的圆形和第一圆形区域的圆心之间的连线的旋转角度称为第三圆形区域的旋转角度。其中,旋转后的第三圆形区域仍与第一圆形区域内切(第一圆形区域仍为第三圆形区域的内切圆)。在对第三圆形区域进行旋转的过程中,在将第三圆形区域旋转第二预设角度(例如30度、35度等)之前,当第三圆形区域全部位于第一图像之内时,将该旋转后的第三圆形区域确定为第二圆形区域。若将第三圆形区域旋转至第二预设角度时,旋转后的第三圆形区域仍有部分区域位于第一图像之外时,则对旋转后的第三图像进行平移,直至第三图像全部位于第一图像之内。
下面,结合图10-图11,对该种可行的实现方式进行说明。
图10为本申请实施例提供的另一种图像示意图。请参见图10,第一图像的中心为O,在第一图像中确定得到第一圆形区域的圆心为A1,旋转前的第三圆形区域的圆心为A2,旋转后的第三圆形区域的圆心为A3。
在对第三圆形区域旋转之前,O、A1和A2位于同一直线上,第一圆形区域与第三圆形区域内切。由图10可知,第三圆形区域的下半部分位于第一图像之外。A1与A2之间的连线与垂直线(第一图像的纵向边)之间的夹角、以及A1与A2之间的连线与水平线(第一图像的横向边)之间的夹角均大于第一夹角,则可以对第三圆形区域进行旋转。由于第三圆形区域的下半部分位于第一图像之外、第一圆形区域和第三圆形区域的切点位于圆形区域的右下方,因此,可以对第三圆形区域向右上方旋转。
可以以A1为圆心,A1与A2之间的线段为半径做旋转圆,控制第三圆形区域的圆心在该旋转圆上向右上方旋转,这样,在第三圆形区域旋转的过程中,依然可以保证第三圆形区域与第一圆形区域内切。第一连线(A1与A3之间的连线)与第二连线(A1与A2之间的连线)之间的夹角可以成为第三圆形区域的旋转角度。
由图10可知,在第三圆形区域的旋转角度小于第二预设角度时,第三圆形区域全部位于第一图像之内,则停止对第三圆形区域旋转。旋转之后的第三圆形区域的圆心为A3,O、A1和A3不位于同一直线上,且第一圆形区域与第三圆形区域内切。将平移之后的第三圆形区域确定为第二圆形区域。
图11为本申请实施例提供的又一种图像示意图。请参见图11,第一图像的中心为O,在第一图像中确定得到第一圆形区域的圆心为A1,旋转前的第三圆形区域的圆心为A2,旋转后的第三圆形区域的圆心为A3,平移后的第三圆形区域为A4。
在对第三圆形区域旋转之前,O、A1和A2位于同一直线上,第一圆形区域与第三圆形区域内切。由图11可知,第三圆形区域的上半部分位于第一图像之外。A1与A2之间的连线与垂直线(第一图像的纵向边)之间的夹角、以及A1与A2之间的连线与水平线(第一图像的横向边)之间的夹角均大于第一夹角,则可以对第三圆形区域进行旋转。由于第三圆形区域的上半部分位于第一图像之外、第一圆形区域和第三圆形区域的切点位于圆形区域的右下方,因此,可以对第三圆形区域向左下方旋转。对第三圆形区域的旋转过程可以参见图10实施例中所示的旋转过程,此处不再进行赘述。
在对第三圆形区域旋转第二预设角度之后,第三圆形区域中仍有部分区域位于第一图像之外,则对第三圆形区域进行平移。由于第三圆形区域中的上半部分位于第一图像之外,则对第三圆形区域向下平移,直至第三圆形区域全部位于第一图像中。在对第三圆形区域平移之后,第三圆形区域的圆心为A4,第三圆形区域全部位于第一图像中。O、A1和A4不位于同一直线上,且第一圆形区域与第三圆形区域不内切。将平移之后的第三圆形区域确定为第二圆形区域。
在上述过程中,在第一夹角和第二夹角均大于第一预设夹角时,对第三圆形区域进行旋转,或者对第三圆形区域进行旋转和平移,即可实现第三圆形区域的全部位于第一图像,且使得平移后的第三圆形区域可以覆盖第一圆形区域,进一步的,通过上述方法还可以使得显著对象在第二圆形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像中的构图与第一图像的构图一致,提高了图像裁剪的质量。
另一种可能的情况:第三圆形区域中存在部分区域位于第一图像的两条边之外。
在该种可能的情况下,可以对第三圆形区域在水平方向和垂直方向进行平移,直至第三圆形区域的全部位于第一图像之内时,将第三圆形区域确定为第二圆形区域。
下面,结合图12,对该种可行的实现方式进行说明。图12为本申请实施例提供的另一种图像示意图。请参见图12,第一图像的中心为O,在第一图像中确定得到第一圆形区域的圆心为A1,水平平移前、垂直平移之前的第三圆形区域的圆心为A2,水平平移后、垂直平移 前的第三圆形区域的圆心为A3,水平平移后、垂直平移后的第三圆形区域的圆心为A4。
在对第三圆形区域平移之前,O、A1和A2位于同一直线上,第一圆形区域与第三圆形区域内切。由图12可知,第三圆形区域的下半部分和右半部分位于第一图像之外,则可以对第三圆形区域进行水平方向和垂直方向的平移。
可以先对第三圆形区域在水平方向上平移,由于第三圆形区域的右半部分位于第一图像之外,则可以向左边平移第三圆形区域,直至第三圆形区域与第一图像的右边缘相切时,停止向左平移第三圆形区域。对第三圆形区域进行水平平移之后,第三圆形区域的圆心为A3。
在对第三圆形区域在水平方向上平移之后,继续对第三圆形区域在垂直方向上平移,由于第三圆形区域的下半部分位于第一图像之外,则可以向上平移第三圆形区域,直至第三圆形区域与第一图像的下边缘相切时,停止向上平移第三圆形区域。对第三圆形区域进行垂直平移之后,第三圆形区域的圆心为A4。O、A1和A4不位于同一直线上,且第一圆形区域与第三圆形区域不内切。将平移之后的第三圆形区域确定为第二圆形区域。
在上述过程中,在第三圆形区域中存在部分区域位于第一图像的两条边之外时,对第三圆形区域平移即可实现第三圆形区域的全部位于第一图像,操作方法简单,使得可以快速获取得到第二圆形区域。进一步的,还可以使得显著对象在第二圆形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量。
在S407之后,执行S415。
S408、将第三圆形区域确定为第二圆形区域。
在确定第三圆形区域不存在部分区域位于所述第一图像之外,即,第三圆形区域全部位于第一图像之内时,将第三圆形区域确定为第二圆形区域。
在S408之后,执行S415。
S409、在第一图像中确定矩形区域、以及正方形区域的边长。
其中,矩形区域为包括显著对象的最小的矩形区域。
下面,结合图13,对矩形区域进行说明。
图13为本申请实施例提供的另一种图像示意图。请参加图13,假设确定得到的显著对象为右边的一朵花,则图13中的矩形框中的区域即为矩形区域。
其中,正方形区域的边长等于第一图像的最短的边长。例如,正方形区域的边长等于图13所示的第一图像的宽度。
需要说明的是,在S409中,仅确定了正方形区域的边长,并未确定得到正方形区域在第一图像中的位置。
S410、根据矩形区域的尺寸和正方形区域的边长,判断所述正方形区域是否能够完全覆盖矩形区域。
若是,则执行S411-S412。
若否,则执行S413。
可选的,可以判断正方形区域的边长是否大于矩形区域的所有边长,若是,则确定正方形区域能够完全覆盖矩形区域,若否,则确定正方形区域不能够完全覆盖矩形区域。
S411、获取第一图像的重心在第一图像中的位置、以及显著对象的重心。
可选的,第一图像的重心在第一图像中的位置为如下位置中的至少一种:靠近中心位置、靠近三分线位置或靠近边缘位置。靠近三分线位置包括:靠近上三分线位置、靠近下三分线位置、靠近左三分线位置和靠近右三分线位置。靠近边缘位置包括:靠近上边缘位置、靠近 下边缘位置、靠近左边缘位置和靠近右边缘位置。
可选的,可以通过如下可行的实现方式获取第一图像的重心在第一图像中的位置:确定第一图像的重心;获取第一图像的重心与第一图像的中心之间的第一距离、第一图像的重心与第一图像的第一三分线之间的第二距离、以及第一图像的重心与第一图像的第一边缘的第三距离;根据第一距离、第二距离和第三距离,确定第一图像的重心在第一图像中的位置。其中,在第一图像的多条三分线中,第一图像的重心与第一三分线之间的距离最近,在第一图像的多个边缘中,第一图像的重心与第一边缘的距离最近。
若第一距离小于第二距离和第三距离,则确定第一图像的重心在第一图像中的位置为靠近中心位置。
若第二距离小于第一距离和第三距离,则确定第一图像的重心在第一图像中的位置为靠近三分线位置。其中,若第一三分线为上三分线,则第一图像的重心在第一图像中的位置为靠近上三分线位置。若第一三分线为下三分线,则第一图像的重心在第一图像中的位置为靠近下三分线位置。若第一三分线为左三分线,则第一图像的重心在第一图像中的位置为靠近左三分线位置。若第一三分线为右三分线,则第一图像的重心在第一图像中的位置为靠近右三分线位置。
若第三距离小于第一距离和第二距离,则确定第一图像的重心在第一图像中的位置为靠近边缘位置。若第一边缘为上边缘,则第一图像的重心在第一图像中的位置为靠近上边缘位置。若第一边缘为下边缘,则第一图像的重心在第一图像中的位置为靠近下边缘位置。若第一边缘为左边缘,则第一图像的重心在第一图像中的位置为靠近左边缘位置。若第一边缘为右边缘,则第一图像的重心在第一图像中的位置为靠近右边缘位置。
S412、根据第一图像的重心在第一图像中的位置、以及显著对象的重心,确定正方形区域。
一种可能的情况:第一图像的重心在第一图像中的位置为靠近中心位置。
根据显著对象的重心和正方形区域的中心确定正方形区域,显著对象的重心位于正方形区域的中心位置。
下面,结合图14,对该种情况下确定正方形区域的过程进行说明。
图14为本申请实施例提供的再一种图像示意图。请参见图14,假设在第一图像中确定的显著对象为动物,则矩形区域如图14所示,图14中的矩形区域为包括显著对象(动物)的最小矩形区域。由图14可知,动物位于第一图像的中心位置,进而可以确定第一图像的重心位于第一图像的中心位置,因此,可以确定得到图14所示的正方形区域,其中,正方形区域的边长等于第一图像的宽度,矩形区域位于正方形区域的中心位置。
另一种可能的情况:第一图像的重心在第一图像中的位置为靠近三分线位置。
根据显著对象的重心和正方形区域的第二三分线,确定正方形区域,显著对象的重心位于第二三分线上。其中,第一三分线和第二三分线的类型相同,三分线的类型包括上三分线、下三分线、左三分线和右三分线。
下面,结合图15,对该种情况下确定正方形区域的过程进行说明。
图15为本申请实施例提供的另一种图像示意图。请参见图15,假设在第一图像中确定的显著对象为球,则矩形区域如图15所示,图15中的矩形区域为包括显著对象(球)的最小矩形区域。由图15可知,球位于第一图像的右三分线位置,进而可以确定第一图像的重心位于第一图像的右三分线位置,因此,可以确定得到图15所示的正方形区域,其中,正方形区域的边长等于第一图像的宽度,矩形区域位于正方形区域的右三分线位置。
又一种可能的情况:第一图像的重心在第一图像中的位置为靠近边缘位置。
根据显著对象的重心和正方形区域的第二边缘,确定正方形区域,显著对象的重心与第二边缘的距离小于预设距离。其中,第二边缘与第一边缘的类型相同,边缘的类型包括上边缘、下边缘、左边缘和右边缘。
下面,结合图16,对该种情况下确定正方形区域的过程进行说明。
图16为本申请实施例提供的又一种图像示意图。请参见图16,假设在第一图像中确定的显著对象为卡通人物,则矩形区域如图16所示,图16中的矩形区域为包括显著对象(卡通人物)的最小矩形区域。由图16可知,卡通人物位于第一图像的左边缘,进而可以确定第一图像的重心位于第一图像的左边缘位置,因此,可以确定得到图16所示的正方形区域,其中,正方形区域的边长等于第一图像的宽度,矩形区域位于正方形区域的左边缘位置。
在上述过程中,根据第一图像的重心在第一图像中的位置确定矩形区域在正方形区域中的位置,可以使得显著对象在正方形区域中的位置,与显著对象在第一图像中的位置一致,进而可以使得裁剪后的图像的构图与第一图像的构图一致,提高了图像裁剪的质量。
在S412之后,执行S414。
S413、根据矩形区域确定正方形区域,正方形区域位于矩形区域的中间位置。
下面,结合图17,对该种情况下确定正方形区域的过程进行说明。
图17为本申请实施例提供的再一种图像示意图。请参见图17,假设在第一图像中确定的显著对象为卡通人物,则矩形区域如图17所示,图17中的矩形区域为包括显著对象(卡通人物)的最小矩形区域。在图17中确定的矩形区域的边长等于第一图像的宽度,但是,正方形区域位于第一图像的任意位置都无法使得正方形区域完全覆盖矩形区域,因此,可以将正方形区域设置在矩形区域的中间位置。
S414、将正方形区域的内切圆确定为第二圆形区域。
S415、按照所第二圆形区域对第一图像进行裁剪,得到第二图像。
下面,结合图18,对裁剪得到的第二图像进行说明。
图18为本申请实施例提供的图像裁剪示意图。请参见图18,示出了多个图像以及对多个图像进行裁剪得到的第二图像。
需要说明的是,在图4实施例所示的各个处理步骤(S401-S415)并不构成对图像处理过程的具体限定。在本申请另一些实施例中,图像处理过程可以包括比图4实施例更多或者更少的步骤,例如,图像处理过程可以包括图4实施例中的部分步骤,或者,图4实施例中的一些步骤可以由具有相同功能的步骤替换,或者,图4实施例中的一些步骤可以被拆分成多个步骤等。
本申请实施例提供的图像处理方法,先在待处理的第一图像中获取显著对象,并根据显著对象在第一图像中的位置,对第一图像进行裁剪处理,得到裁剪后的第二图像,这样,不但可以使得第二图像中包括显著对象,还可以使得显著对象在第一图像中的位置与显著对象在第二图像中的位置一致,进而可以使得裁剪后的第二图像的构图与第一图像的构图一致,提高了图像裁剪的质量。
在上述任意一个实施例的基础上,下面,结合图19,对本申请所示的图像处理方法进行说明。
图19为本申请实施例提供的另一种图像处理方法的流程示意图。请参见图19,该方法可以包括:
S1901、终端设备显示第一图像。
其中,第一图像具有第一尺寸。
可选的,第一图像可以为终端设备本地的图像(例如,终端设备的图库中的图像),也可以为网络图像等。
第一图像的形状可以为正方形、矩形、多边形等。
可选的,终端设备可以根据第一图像的尺寸显示第一图像的最大化图像。例如,请参见图3A和图3D,终端设备按照第一图像的尺寸,显示第一图像的最大化图像。
可选的,终端设备还可以显示第一图像的缩略图。例如,请参见图3B,终端设备显示第一图像的缩略图。
可选的,终端设备可以接收用户的操作,以显示第一图像。例如,用户可以打开终端设备的本地图库,并在本地图库中打开第一图像,以使终端设备显示第一图像。或者,用户可以对终端设备中的终端功能进行操作,以使终端设备显示第一图像,例如,请参见图3B,用户对社交应用程序中的“发表照片”图标进行点击操作,以使终端设备显示第一图像。
S1902、终端设备接收用户的操作。
其中,用户的操作为如下操作中的任意一种:头像设置操作、屏幕设置操作、图片分享操作、通讯录操作、图片发送操作。
例如,请参见图3A,头像设置操作可以包括:用户通过对界面A1中的“指定给联系人”图标进行点击操作、以及用户对界面A2中的“小红”图标进行点击操作。
例如,请参见图3B,图像分享操作可以包括:用户对界面B1中的“发表照片”图标进行点击操作、以及用户对照片输入的点击操作。
例如,请参见图3C,屏幕设置操作可以包括:用户界面C1中的“表盘图像”图标进行点击操作、以及用户对照片输入的点击操作。
需要说明的是,上述只是以示例的形式示意用户的操作,并非对用户的操作进行的限定。
S1902、终端设备在第一图像中获取第二图像。
其中,第二图像具有第二尺寸,第二尺寸小于第一尺寸,第二图像包括第一图像上的显著内容。
显著内容是指包括显著对象的图像内容。例如,请参见图1A,图1A中的显著对象为卡通人物,则显著内容为该卡通对象所在的圆形图像区域。例如,请参见图1B,图1B中的显著对象为动物,则显著内容为该动物所在的圆形图像区域。
可选的,终端设备可以通过图4实施例所示的方法对第一图像进行处理,以得到第二图像。
可选的,终端设备可以请求其它设备(例如服务器等设备)通过图4实施例所示的方法对第一图像进行处理,得到第二图像,终端设备再从其它设备获取该第二图像。
需要说明的是,在终端设备或服务器通过图4实施例所示的方法对第一图像进行处理的过程中,可以采用图4实施例中的部分步骤对第一图像进行处理,或者,采用图4实施例中
S1903、终端设备显示第二图像。
可选的,可以在终端设备的终端功能对应的显示页面中显示第二图像。
例如,请参见图3A,终端功能为头像设置功能,界面A3为该终端功能对应的显示页面。
例如,请参见图3B,终端功能为图片分享功能,界面B3为该终端功能对应的显示页面。
例如,请参见图3C,终端功能为屏幕设置功能,界面C3为该终端功能对应的显示页面。
在图19所示的实施例中,在终端设备显示第一图像后,用户可以在终端设备中输入操作,以使终端设备显示第一图像中的第二图像,第二图像为第一图像中的一部分,且第二图像包 括第一图像中的显著内容。其中,在获取第二图像的过程中,先在待处理的第一图像中获取显著对象,并根据显著对象在第一图像中的位置,对第一图像进行裁剪处理,得到裁剪后的第二图像,这样,不但可以使得第二图像中包括显著对象,还可以使得显著对象在第一图像中的位置与显著对象在第二图像中的位置一致,进而可以使得裁剪后的第二图像的构图与第一图像的构图一致,提高了图像裁剪的质量。
图20为本申请实施例提供的图像处理装置的结构示意图。请参见图20,图像处理装置10可以包括存储器11和处理器12,其中,存储器11和处理器12通信;示例性的,存储器11和处理器12可以通过通信总线13通信,所述存储器11用于存储计算机程序,所述处理器12执行所述计算机程序实现上述图像处理方法。
图21为本申请实施例提供的终端设备的结构示意图。请参见图21,终端设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示器194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本申请实施例示意的结构并不构成对终端设备100的具体限定。在本申请另一些实施例中,终端设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现终端设备100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。
MIPI接口可以被用于连接处理器110与显示器194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示器串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现终端设备100的拍摄功能。处理器110和显示器194通过DSI接口通信,实现终端设备100的显示功能。
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对终端设备100的结构限定。在本申请另一些实施例中,终端设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
移动通信模块150可以提供应用在终端设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示器194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。
无线通信模块160可以提供应用在终端设备100上的包括无线局域网(wireless local  area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,终端设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得终端设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
终端设备100通过GPU,显示器194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示器194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示器194用于显示图像,视频等。显示器194包括显示面板。显示面板可以采用液晶显示器(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,终端设备100可以包括1个或N个显示器194,N为大于1的正整数。
终端设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示器194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当终端设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。终端设备100可以支持一种或多种视频编解码器。这样,终端设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以 实现终端设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展终端设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储终端设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行终端设备100的各种功能应用以及数据处理。
终端设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。
本申请实施例提供一种存储介质,所述存储介质用于存储计算机程序,所述计算机程序被计算机或处理器执行时用于实现上述图像处理方法。
本申请实施例提供一种计算机程序产品,所述计算机程序产品包括指令,当所述指令被执行时,使得计算机执行上述图像处理方法。
本申请实施例提供一种芯片上系统或系统芯片,所述芯片上系统或系统芯片可应用于终端设备,所述芯片上系统或系统芯片包括:至少一个通信接口,至少一个处理器,至少一个存储器,所述通信接口、存储器和处理器通过总线互联,所述处理器通过执行所述存储器中存储的指令,使得所述终端设备可执行上述图像处理方法。
实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一可读取存储器中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储器(存储介质)包括:只读存储器(read-only memory,ROM)、RAM、快闪存储器、硬盘、固态硬盘、磁带(magnetic tape)、软盘(floppy disk)、光盘(optical disc)及其任意组合。
本申请实施例是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理单元以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理单元执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请实施例进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请实施例的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。
在本申请中,术语“包括”及其变形可以指非限制性的包括;术语“或”及其变形可以指“和/或”。本本申请中术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。本申请中,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。

Claims (14)

  1. 一种图像处理方法,其特征在于,包括:
    显示第一图像,第一图像具有第一尺寸;
    接收用户的操作,所述用户的操作为如下操作中的任意一种:头像设置操作、屏幕设置操作、图片分享操作、通讯录操作、图片发送操作;
    显示第二图像,所述第二图像具有第二尺寸,所述第二尺寸小于所述第一尺寸,所述第二图像包括第一图像上的显著内容。
  2. 根据权利要求1所述的方法,其特征在于,所述显示第二图像之前,还包括:
    在所述第一图像中确定显著对象和包括所述显著对象的第二圆形区域,所述第二圆形区域的第二直径大于第一圆形区域的第一直径,所述第二直径小于或等于所述第一图像的最短边长,所述第一圆形区域为包括所述显著对象的最小圆形区域;
    按照所述第二圆形区域对所述第一图像进行裁剪,得到所述第二图像。
  3. 根据权利要求2所述的方法,其特征在于,所述在所述第一图像中确定包括所述显著对象的第二圆形区域,包括:
    获取所述第一直径与所述第一图像的最短边长之间的第一比值;
    若所述第一比值在第一阈值与第二阈值之间,则根据所述第二直径和所述第一直径之间的预设比值,确定所述第二圆形区域;
    若所述第一比值小于所述第一阈值或者大于所述第二阈值,则在所述第一图像中确定正方形区域,并将所述正方形区域的内接圆区域确定为所述第二圆形区域,所述正方形区域中包括所述显著对象,所述正方形区域的边长为所述第一图像的最短边长。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述第二直径和所述第一直径之间的预设比值,确定所述第二圆形区域,包括:
    在所述第一图像中确定所述第一圆形区域;
    根据所述第一圆形区域的圆心、所述第一图像的中心、所述第一直径和所述预设比值,在所述第一图像中确定所述第二圆形区域。
  5. 根据权利要求4所述的方法,其特征在于,所述根据所述第一圆形区域的圆心、所述第一图像的中心、所述第一直径和所述预设比值,在所述第一图像中确定所述第二圆形区域,包括:
    根据所述第一圆形区域的圆心、所述第一图像的中心,在所述第一图像中确定初始圆心,所述第一圆形区域的圆心、所述第一图像的中心和所述初始圆心在一条直线上;
    根据所述第一直径和所述预设比值,确定所述第二直径;
    根据所述初始圆心和所述第二直径,在所述第一图像中确定所述第二圆形区域。
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述初始圆心和所述第二直径,在所述第一图像中确定所述第二圆形区域,包括:
    以所述初始圆心为圆心、以所述第二直径为直径确定第三圆形区域,所述第一圆形区域与所述第三圆形区域内切;
    判断所述第三圆形区域是否存在部分区域位于所述第一图像之外;
    若是,则对所述第三圆形区域进行平移操作和/或旋转操作,直至处理后的第三圆形区域全部位于所述第一图像之内时,将所述第一图像中的、处理后第三圆形区域确定为所述第二圆形区域;
    若否,则将所述第三圆形区域确定为所述第二圆形区域。
  7. 根据权利要求3所述的方法,其特征在于,所述在所述第一图像中确定正方形区域,包括:
    在所述第一图像中确定矩形区域,所述矩形区域为包括所述显著对象的最小的矩形区域;
    根据所述矩形区域的尺寸和所述正方形区域的边长,在所述第一图像中确定所述正方形区域。
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述矩形区域的尺寸和所述正方形区域的边长,在所述第一图像中确定所述正方形区域,包括:
    根据所述矩形区域的尺寸和所述正方形区域的边长,判断所述正方形区域是否能够完全覆盖所述矩形区域;
    若是,则获取所述第一图像的重心在所述第一图像中的位置、以及所述显著对象的重心,并根据所述第一图像的重心在所述第一图像中的位置、以及所述显著对象的重心,确定所述正方形区域;
    若否,根据所述矩形区域确定所述正方形区域,所述正方形区域位于所述矩形区域的中间位置。
  9. 根据权利要求8所述的方法,其特征在于,所述获取所述第一图像的重心在所述第一图像中的位置,包括:
    确定所述第一图像的重心;
    获取所述第一图像的重心与所述第一图像的中心之间的第一距离、所述第一图像的重心与所述第一图像的第一三分线之间的第二距离、以及所述第一图像的重心与所述第一图像的第一边缘的第三距离;其中,在所述第一图像的多条三分线中,所述第一图像的重心与所述第一三分线之间的距离最近,在所述第一图像的多个边缘中,所述第一图像的重心与所述第一边缘的距离最近;
    根据所述第一距离、所述第二距离和所述第三距离,确定所述第一图像的重心在所述第一图像中的位置,所述第一图像的重心在所述第一图像中的位置为如下位置中的至少一种:靠近中心位置、靠近三分线位置或靠近边缘位置。
  10. 根据权利要求9所述的方法,其特征在于,所述根据所述第一距离、所述第二距离和所述第三距离,确定所述第一图像的重心在所述第一图像中的位置,包括:
    若所述第一距离小于所述第二距离和所述第三距离,则确定所述第一图像的重心在所述第一图像中的位置为靠近中心位置;
    若所述第二距离小于所述第一距离和所述第三距离,则确定所述第一图像的重心在所述第一图像中的位置为靠近三分线位置;
    若所述第三距离小于所述第一距离和所述第二距离,则确定所述第一图像的重心在所述第一图像中的位置为靠近边缘位置。
  11. 根据权利要求9或10所述的方法,其特征在于,根据所述第一图像的重心在所述第一图像中的位置、以及所述显著对象的重心,确定所述正方形区域,包括:
    若所述第一图像的重心在所述第一图像中的位置为靠近中心位置,则根据所述显著对象的重心和所述正方形区域的中心确定所述正方形区域,所述显著对象的重心位于所述正方形区域的中心位置;
    若所述第一图像的重心在所述第一图像中的位置为靠近三分线位置,则根据所述显著对象的重心和所述正方形区域的第二三分线,确定所述正方形区域,所述显著对象的重心位于 所述第二三分线上,所述第一三分线和所述第二三分线的类型相同,三分线的类型包括上三分线、下三分线、左三分线和右三分线;
    若所述第一图像的重心在所述第一图像中的位置为靠近边缘位置,则根据所述显著对象的重心和所述正方形区域的第二边缘,确定所述正方形区域,所述显著对象的重心与所述第二边缘的距离小于预设距离,所述第二边缘与所述第一边缘的类型相同,边缘的类型包括上边缘、下边缘、左边缘和右边缘。
  12. 根据权利要求2-11任一项所述的方法,其特征在于,所述在所述第一图像中确定显著对象,包括:
    对所述第一图像进行显著性检测处理、语义分割处理、直线检测处理中的至少一种处理,以在所述第一图像中确定所述显著对象。
  13. 一种图像处理装置,其特征在于,包括存储器和处理器,所述处理器执行所述存储器中的程序指令,用于实现权利要求1-12任一项所述的图像处理方法。
  14. 一种存储介质,其特征在于,所述存储介质用于存储计算机程序,所述计算机程序被计算机或处理器执行时用于实现权利要求1-12任一项所述的图像处理方法。
PCT/CN2020/087529 2019-05-09 2020-04-28 图像处理方法、装置及设备 WO2020224488A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US17/609,948 US12008761B2 (en) 2019-05-09 2020-04-28 Image processing method and apparatus, and device
EP20801648.5A EP3951574A4 (en) 2019-05-09 2020-04-28 IMAGE PROCESSING METHOD AND APPARATUS, AND DEVICE

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910386382.9 2019-05-09
CN201910386382.9A CN110456960B (zh) 2019-05-09 2019-05-09 图像处理方法、装置及设备

Publications (1)

Publication Number Publication Date
WO2020224488A1 true WO2020224488A1 (zh) 2020-11-12

Family

ID=68480940

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/087529 WO2020224488A1 (zh) 2019-05-09 2020-04-28 图像处理方法、装置及设备

Country Status (4)

Country Link
US (1) US12008761B2 (zh)
EP (1) EP3951574A4 (zh)
CN (1) CN110456960B (zh)
WO (1) WO2020224488A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110456960B (zh) 2019-05-09 2021-10-01 华为技术有限公司 图像处理方法、装置及设备
CN110286813B (zh) * 2019-05-22 2020-12-01 北京达佳互联信息技术有限公司 图标位置确定方法和装置
CN111462121A (zh) * 2020-03-23 2020-07-28 上海携程商务有限公司 基于图像语义理解的图像裁切方法、系统、设备和介质
CN114067096A (zh) * 2020-08-06 2022-02-18 Oppo广东移动通信有限公司 表盘推送方法、装置、电子设备和计算机可读存储介质
CN112016548B (zh) * 2020-10-15 2021-02-09 腾讯科技(深圳)有限公司 一种封面图展示方法及相关装置
CN112270745B (zh) * 2020-11-04 2023-09-29 北京百度网讯科技有限公司 一种图像生成方法、装置、设备以及存储介质
CN113159026A (zh) * 2021-03-31 2021-07-23 北京百度网讯科技有限公司 图像处理方法、装置、电子设备和介质
CN113934342A (zh) * 2021-10-21 2022-01-14 深圳市爱都科技有限公司 一种表盘设置方法、装置、终端设备及可读存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104063444A (zh) * 2014-06-13 2014-09-24 百度在线网络技术(北京)有限公司 缩略图的生成方法和装置
US20150110348A1 (en) * 2013-10-22 2015-04-23 Eyenuk, Inc. Systems and methods for automated detection of regions of interest in retinal images
CN108510574A (zh) * 2018-04-17 2018-09-07 福州大学 一种基于样例学习并增强视觉质量的3d图像裁剪方法
CN108921859A (zh) * 2018-06-28 2018-11-30 努比亚技术有限公司 图片处理方法、程序和计算机可读储存介质
CN109146892A (zh) * 2018-07-23 2019-01-04 北京邮电大学 一种基于美学的图像裁剪方法及装置
CN110456960A (zh) * 2019-05-09 2019-11-15 华为技术有限公司 图像处理方法、装置及设备

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103489107B (zh) * 2013-08-16 2015-11-25 北京京东尚科信息技术有限公司 一种制作虚拟试衣模特图像的方法和装置
EP3036715B1 (en) 2013-08-21 2018-12-19 Koninklijke Philips N.V. Segmentation apparatus for interactively segmenting blood vessels in angiographic image data
KR20160034065A (ko) * 2014-09-19 2016-03-29 엘지전자 주식회사 이동 단말기 및 그 제어 방법
CN104484854A (zh) * 2014-12-24 2015-04-01 北京奇虎科技有限公司 人物图片裁剪方法和装置
US10262229B1 (en) * 2015-03-24 2019-04-16 Hrl Laboratories, Llc Wide-area salient object detection architecture for low power hardware platforms
CN105279755B (zh) * 2015-09-11 2018-06-29 西安科技大学 一种无人机全天候着舰合作目标鲁棒检测及匹配方法
EP3633612A4 (en) 2017-06-30 2020-06-03 Shanghai United Imaging Healthcare Co., Ltd. IMAGE SEGMENTATION METHOD AND SYSTEM
CN107622504B (zh) * 2017-09-30 2020-11-10 北京百度网讯科技有限公司 用于处理图片的方法和装置
CN108876791B (zh) * 2017-10-23 2021-04-09 北京旷视科技有限公司 图像处理方法、装置和系统及存储介质
CN108492246B (zh) * 2018-03-12 2023-01-24 维沃移动通信有限公司 一种图像处理方法、装置及移动终端
CN108776970B (zh) * 2018-06-12 2021-01-12 北京字节跳动网络技术有限公司 图像处理方法和装置
CN109448001B (zh) * 2018-10-26 2021-08-27 世纪开元智印互联科技集团股份有限公司 一种图片自动裁剪方法
CN109461167B (zh) * 2018-11-02 2020-07-21 Oppo广东移动通信有限公司 图像处理模型的训练方法、抠图方法、装置、介质及终端

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150110348A1 (en) * 2013-10-22 2015-04-23 Eyenuk, Inc. Systems and methods for automated detection of regions of interest in retinal images
CN104063444A (zh) * 2014-06-13 2014-09-24 百度在线网络技术(北京)有限公司 缩略图的生成方法和装置
CN108510574A (zh) * 2018-04-17 2018-09-07 福州大学 一种基于样例学习并增强视觉质量的3d图像裁剪方法
CN108921859A (zh) * 2018-06-28 2018-11-30 努比亚技术有限公司 图片处理方法、程序和计算机可读储存介质
CN109146892A (zh) * 2018-07-23 2019-01-04 北京邮电大学 一种基于美学的图像裁剪方法及装置
CN110456960A (zh) * 2019-05-09 2019-11-15 华为技术有限公司 图像处理方法、装置及设备

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
See also references of EP3951574A4
WANG TING;FANG SHUAI;YU LEI: "Saliency region detection method based on stereo vision analysis", JOURNAL OF ELECTRONIC MEASUREMENT AND INSTRUMENTATION, vol. 29, no. 3, 15 March 2015 (2015-03-15), pages 399 - 407, XP055751505, ISSN: 1000-7105, DOI: 10.13382/j.jemi.2015.03.012 *

Also Published As

Publication number Publication date
US20220245823A1 (en) 2022-08-04
CN110456960B (zh) 2021-10-01
US12008761B2 (en) 2024-06-11
CN110456960A (zh) 2019-11-15
EP3951574A1 (en) 2022-02-09
EP3951574A4 (en) 2022-06-01

Similar Documents

Publication Publication Date Title
WO2020224488A1 (zh) 图像处理方法、装置及设备
WO2021136050A1 (zh) 一种图像拍摄方法及相关装置
CN111724293B (zh) 图像渲染方法及装置、电子设备
WO2020151580A1 (zh) 一种屏幕控制和语音控制方法及电子设备
US20220319077A1 (en) Image-text fusion method and apparatus, and electronic device
WO2021078001A1 (zh) 一种图像增强方法及装置
US12020472B2 (en) Image processing method and image processing apparatus
WO2022017261A1 (zh) 图像合成方法和电子设备
WO2022127787A1 (zh) 一种图像显示的方法及电子设备
WO2021036853A1 (zh) 一种图像处理方法及电子设备
CN114140365B (zh) 基于事件帧的特征点匹配方法及电子设备
WO2021115483A1 (zh) 一种图像处理方法及相关装置
WO2020259623A1 (zh) 页面绘制的控制方法、装置及设备
US20240153209A1 (en) Object Reconstruction Method and Related Device
US20240046604A1 (en) Image processing method and apparatus, and electronic device
WO2022179604A1 (zh) 一种分割图置信度确定方法及装置
CN113538227B (zh) 一种基于语义分割的图像处理方法及相关设备
WO2020103732A1 (zh) 一种皱纹检测方法和终端设备
WO2021185232A1 (zh) 一种条码识别方法以及相关设备
WO2023011302A1 (zh) 拍摄方法及相关装置
CN114943976A (zh) 模型生成的方法、装置、电子设备和存储介质
WO2022179271A1 (zh) 反馈搜索结果的方法、装置及存储介质
CN116074624B (zh) 一种对焦方法和装置
EP4246426A1 (en) Image processing method and electronic device
CN116343247B (zh) 表格图像矫正方法、装置和设备

Legal Events

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

Ref document number: 20801648

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020801648

Country of ref document: EP

Effective date: 20211027

NENP Non-entry into the national phase

Ref country code: DE