Image generation method and device, electronic equipment and computer readable storage medium
By identifying the visual focus information of the image to be processed and determining the composition strategy, the target image is extracted, and the problem of difficulty in focusing on key content of the image in the prior art is solved, and the image generation quality is improved.
Patent Information
- Application Number
- CN202411774613.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-02-18
AI Technical Summary
Existing image generation solutions are difficult to focus on key content in the image, and the image generation quality still needs to be improved.
By acquiring the image to be processed and identifying its visual focus information, a composition strategy is determined based on the visual focus information, thereby extracting the target image.
This achieves a more focused focus on key content in the pending image and improves image generation quality.
Smart Images

Figure CN119478107A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image generation technology, and specifically to an image generation method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the development of computer technology, there are various ways to generate images. One-click generation methods such as screenshot-based and AI-based image generation have provided convenience for image generation.
[0003] However, current image generation schemes are still mainly focused on retaining the original image quality and content as much as possible, that is, a more conservative image generation method is usually adopted to retain more original image information for users. However, such an image generation method makes it difficult to focus on the key content in the image, and the image generation quality needs to be improved. Summary of the invention
[0004] The embodiments of the present application provide an image generation method, device, electronic device, and computer-readable storage medium, which can focus on key content in an image and improve image generation quality.
[0005] In a first aspect, an embodiment of the present application provides an image generation method, the method comprising:
[0006] Acquire an image to be processed and identify visual focus information of the image to be processed;
[0007] Determining a composition strategy according to the visual focus information;
[0008] A target image is extracted from the image to be processed according to the composition strategy.
[0009] In a second aspect, an embodiment of the present application further provides an image generating device, the device comprising:
[0010] An acquisition module, used to acquire an image to be processed and identify visual focus information of the image to be processed;
[0011] A determination module, used to determine a composition strategy according to the visual focus information;
[0012] The cropping module is used to extract a target image from the image to be processed according to the composition strategy.
[0013] Optionally, in some embodiments of the present application, extracting a target image from the image to be processed according to the composition strategy includes:
[0014] Determine composition ratio information according to the composition strategy;
[0015] Determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed;
[0016] A target image including the target reference point and a preset area around the target reference point is obtained according to the extraction of the target reference point.
[0017] Optionally, in some embodiments of the present application, determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed includes:
[0018] generating at least one horizontal line and at least one vertical line for the image to be processed according to the composition ratio information;
[0019] determining at least one intersection point based on the at least one horizontal line and the at least one vertical line;
[0020] According to the clarity, a target intersection point is screened from the at least one intersection point, and the target intersection point is set as a target reference point.
[0021] Optionally, in some embodiments of the present application, extracting a target image including the target reference point and a preset area around the target reference point according to the target reference point includes:
[0022] Determining a target subject from the image to be processed according to the target reference point;
[0023] Constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target subject to obtain a cropping area;
[0024] A target image is obtained by cropping the image to be processed according to the cropping area.
[0025] Optionally, in some embodiments of the present application, constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target body to obtain a cropping area includes:
[0026] Constructing a cropping frame with the target reference point as the center;
[0027] Filtering target feature points from the outline of the target subject, wherein the target feature points are composition key points contained in the outline of the target subject;
[0028] The cropping frame is stretched according to the position of the target feature point to obtain a cropping area.
[0029] Optionally, in some embodiments of the present application, determining a composition strategy according to the visual focus information includes:
[0030] identifying a target subject from the image to be processed according to the visual focus information;
[0031] Determining composition feature information of the target subject, wherein the composition feature information includes at least one of composition symmetry information, composition distribution information, composition ratio information and composition visual information;
[0032] A composition strategy is determined according to the composition feature information.
[0033] Optionally, in some embodiments of the present application, after extracting the target image from the image to be processed according to the composition strategy, the method further includes:
[0034] Identify the target image and determine the content definition result of the target image;
[0035] Adjust the color information of the target image according to the content definition result to obtain an optimized image;
[0036] or,
[0037] The target image is interpolated according to a preset cropping ratio to obtain an interpolated image, and according to a content definition result of the interpolated image, the color information of the interpolated image is adjusted to obtain an optimized image.
[0038] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and which implements the steps in the above-mentioned image generation method when the computer program is executed by the processor.
[0039] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned image generation method are implemented.
[0040] In a fifth aspect, the embodiments of the present application further provide a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations described in the embodiments of the present application.
[0041] The embodiment of the present application obtains an image to be processed and identifies visual focus information of the image to be processed, determines a composition strategy according to the visual focus information, and extracts a target image from the image to be processed according to the composition strategy.
[0042] Among them, the composition strategy is determined by the visual focus information of the image to be processed and the target image is extracted based on the composition strategy, so that the extracted target image can better focus on the key content of the image to be processed, thereby improving the quality of the generated image. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 is a schematic diagram of a scenario in which an electronic device provided in an embodiment of the present application executes the image generating method;
[0045] Figure 2 It is a flowchart of the image generation method provided in the embodiment of the present application;
[0046] Figure 3 is a schematic diagram of the structure of an image generating device provided in an embodiment of the present application;
[0047] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0049] The embodiments of the present application provide an image generation method, device, electronic device and computer-readable storage medium. Specifically, the embodiments of the present application provide an image generation device suitable for electronic devices, which is used to extract a target image with focused key content from an image to be processed, and the electronic device includes a terminal device or a server, and the terminal device includes but is not limited to mobile phones, tablet computers, laptop computers, televisions and other devices. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, etc. The server can be directly or indirectly connected via wired or wireless communication.
[0050] See also Figure 1 , Figure 1 : is a schematic diagram of a scenario in which an electronic device according to an embodiment of the present application performs the image generation method, wherein the specific execution process of the electronic device performing the image generation method is as follows:
[0051] The electronic device 10 acquires an image to be processed and identifies visual focus information of the image to be processed, determines a composition strategy according to the visual focus information, and extracts a target image from the image to be processed according to the composition strategy.
[0052] For example, a user selects an image to be processed through an electronic device, and then clicks an image generation control to generate a target image through the above steps.
[0053] In summary, the embodiments of the present application determine the composition strategy through the visual focus information of the image to be processed and extract the target image based on the composition strategy, so that the extracted target image can better focus on the key content in the image to be processed, thereby improving the quality of the generated image.
[0054] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.
[0055] See also Figure 2 , Figure 2 A flowchart of an image generation method provided in an embodiment of the present application. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the flowchart. Specifically, the process of the image generation method specifically includes:
[0056] 101. Acquire an image to be processed and identify visual focus information of the image to be processed.
[0057] Among them, the image to be processed is an image that needs to be processed. The image can be an image taken by a camera, an image searched through the network, or an image received from other users. In this embodiment of the application, the image to be processed is the original image before processing.
[0058] It should be noted that visual focus information refers to a specific area or element that attracts the audience's attention in a visual work (such as a painting, a photograph, a design work, etc.). It is a key concept in composition and design, and is essential for guiding the audience's sight, conveying information, and influencing emotional responses. That is, the visual focus refers to the most prominent part of the work, which is usually the first thing the audience notices and may continue to attract their attention. This focus can be an object, a color, a shape, or a specific scene. In layout, it can be formed through contrast. For example, placing a large element in the center surrounded by a group of small elements will easily become the visual focus. For example, in web design, a striking "Buy Now" button (much larger than the surrounding text and icons) will become the focus to guide user operations.
[0059] Color can also highlight visual focus. When the picture is mostly cold, an element with warm colors is easy to be noticed. For example, in a painting dominated by blue, a little red object will often be noticed first.
[0060] In addition, lines can also lead to visual focus. Converging lines usually lead people's eyes to their convergence point, and this point will become the focus. For example, in architectural photography, the place where the perspective lines of the building converge is likely to become the visual focus.
[0061] Optionally, in the embodiment of the present application, the visual focus information in the image to be processed may be identified based on content feature analysis, location-based rules, learning-based methods, or user interaction-based methods. Specifically:
[0062] For content-based feature analysis, you can:
[0063] Color contrast: Analyze the distribution and contrast of colors in the image. Generally, areas with high contrast are more likely to attract attention.
[0064] Brightness variation: Areas of high variation in brightness are likely to contain visual focal points because they are more visually noticeable.
[0065] Texture analysis: Analyze the texture features of the image. Complex texture changes may indicate visual focus.
[0066] For location-based rules, you can:
[0067] Rule of Thirds: Using the rule of thirds, analyze whether elements near the four intersection points in the image are more likely to be in focus.
[0068] Central Area: Elements in the central area of an image are usually more likely to be in focus.
[0069] For learning-based methods, this can be accomplished by:
[0070] Machine Learning Models: Use deep learning models, such as Convolutional Neural Networks (CNNs), to identify key areas in images.
[0071] Object detection: Identify the main objects in the image, which are often the visual focus, through object detection algorithms such as YOLO or SSD.
[0072] For methods based on user interaction, you can:
[0073] Click Analysis: By analyzing the user's click behavior on the image, determine which areas are paid more attention.
[0074] Gaze tracking: Use eye tracking technology to identify where the user is looking on an image to determine visual focus.
[0075] 102. Determine a composition strategy according to the visual focus information.
[0076] Different composition strategies can be used for different visual focus information. For example, composition strategies include the rule of thirds, symmetry and pattern, visual balance and golden ratio.
[0077] Among them, the rule of thirds means dividing the picture into nine equal parts, forming a three-by-three grid, and placing the main visual elements on these grid lines or intersections.
[0078] Symmetry and pattern: Symmetry refers to the elements or parts of an object or figure on both sides of a central axis or center point that are identical or mirror images of each other, and pattern refers to repeated elements or shapes, which can be consistent in time, space or form. Patterns can be simple, such as repeated lines or shapes, or complex, such as patterns or textures.
[0079] Among them, visual balance refers to enhancing the visual appeal of an image by adjusting certain parts of it to ensure the overall balance and harmony of the image. Visual balance refers to establishing a sense of balance between visual elements so that the viewer feels visually comfortable and harmonious. Balance can be divided into the following types:
[0080] Symmetrical balance: Both sides of the image are identical or mirror images.
[0081] Asymmetrical balance: The left and right sides of the image are not exactly the same, but still give a sense of balance.
[0082] Dynamic balance: Use visual guides (such as lines, shapes, etc.) to make the viewer's eyes flow naturally in the image.
[0083] Among them, the golden ratio is a composition technique based on the golden section, which is widely used in art, design, photography and architecture. The golden ratio, also known as the golden section, refers to dividing a line segment into two parts so that the ratio of the longer part to the whole is equal to the ratio of the shorter part to the longer part. This ratio is approximately 1:0.618.
[0084] 103. Extract a target image from the image to be processed according to the composition strategy.
[0085] That is, after determining the composition strategy, the target image can be extracted from the image to be processed according to the composition strategy. For example, the target image can be extracted according to the rule of thirds, according to the strategy of symmetry and pattern, according to the strategy of golden ratio, or according to the strategy of visual balance.
[0086] In summary, the embodiments of the present application determine the composition strategy through the visual focus information of the image to be processed and extract the target image based on the composition strategy, so that the extracted target image can better focus on the key content in the image to be processed, thereby improving the quality of the generated image.
[0087] Among them, different composition strategies are often manifested as differences in composition proportions. For example, the rule of thirds is manifested by whether the main body of the image is within two squares of the nine-square grid, the strategy for symmetry and pattern is manifested by whether the main body of the image is symmetrical along the central axis of the main body, the strategy for the golden ratio is manifested by whether the main body of the image conforms to the golden ratio of 1:0.618, and the strategy for visual balance is manifested by the contrast of visual elements.
[0088] Therefore, in the embodiment of the present application, the image to be processed can be processed based on the composition ratio information corresponding to the composition strategy to extract the target image. That is, optionally, in some embodiments of the present application, the step of "extracting the target image from the image to be processed according to the composition strategy" includes:
[0089] Determine composition ratio information according to the composition strategy;
[0090] Determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed;
[0091] A target image including the target reference point and a preset area around the target reference point is obtained according to the extraction of the target reference point.
[0092] For example, according to the composition ratio information and the clarity, a target reference point with higher clarity is selected from the image to be processed, and a target image is extracted from the image to be processed based on the target reference point.
[0093] In the embodiments of the present application, multiple intersection points may be determined from the image to be processed based on the composition ratio information, a target intersection point may be selected based on the clarity, and a target image may be extracted based on the target intersection point. That is, optionally, in some embodiments of the present application, the step of “determining a target reference point from the image to be processed based on the composition ratio information and the clarity of the image to be processed” includes:
[0094] generating at least one horizontal line and at least one vertical line for the image to be processed according to the composition ratio information;
[0095] determining at least one intersection point based on the at least one horizontal line and the at least one vertical line;
[0096] According to the clarity, a target intersection point is screened from the at least one intersection point, and the target intersection point is set as a target reference point.
[0097] Among them, the rule of thirds is used as an example to illustrate, and other composition strategies can be understood by reference.
[0098] The specific rules for the rule of thirds are:
[0099] 1. Divide the image into nine equally divided grids, forming two vertical lines and two horizontal lines. The intersection of these vertical and horizontal lines is the candidate position of the visual focus;
[0100] 2. Starting from the positions of the four intersection points, use an image processing library (such as OpenCV) to calculate the contrast or gradient of these intersection points to determine which intersection point is the clearest and obtain the target intersection point, that is, the target reference point;
[0101] Specifically, for the four intersection points, differential (derivative) filters such as Sobel operator or Laplace operator are respectively run, and the results are added pixel by pixel. The image with the highest sum is the clearest image, and the clearest target intersection point is then screened.
[0102] 3. Take the clearest target reference point as the analysis starting point and extract the target image from the image to be processed.
[0103] For example, taking the clearest target reference point as the center, the analysis is expanded to the surrounding areas, and a region with higher clarity is extracted to obtain the target image.
[0104] Among them, in the embodiment of the present application, a cropping frame can be set according to the target reference point, and the cropping frame can be stretched by the target subject contained in the image to be processed to obtain a final cropping area, and then the target image is cropped. That is, optionally, in some embodiments of the present application, the step of "extracting according to the target reference point to obtain a target image including the target reference point and a preset area around the target reference point" includes:
[0105] Determining a target subject from the image to be processed according to the target reference point;
[0106] Constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target subject to obtain a cropping area;
[0107] A target image is obtained by cropping the image to be processed according to the cropping area.
[0108] The target subject is a subject near a target reference point in the image to be processed, for example, a person, an animal, or food near the target reference point.
[0109] For example, the cropping frame is stretched to obtain a cropping area that encloses the target subject, thereby obtaining a target image that includes the target subject.
[0110] In the embodiment of the present application, if the target subject occupies a large proportion in the picture, or in order to improve the artistic quality of the target image, the target subject may also be analyzed to avoid cropping to obtain a target image with poor visual effects. Specifically, the step of "constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target subject to obtain a cropping area" includes:
[0111] Constructing a cropping frame with the target reference point as the center;
[0112] Filtering target feature points from the outline of the target subject, wherein the target feature points are composition key points contained in the outline of the target subject;
[0113] The cropping frame is stretched according to the position of the target feature point to obtain a cropping area.
[0114] Among them, the target feature points are the key points that reflect the characteristics of the target subject and are also the key points of the composition. For example, when the target subject is a person, the target feature points include ankles, knees, wrists and elbows, etc. When the target subject is food, the target feature points include food outline, packaging bag structure, food containers and food ingredients, etc.
[0115] For example, starting from the target reference point, check all around to ensure the integrity of the target body, avoid cutting off the head, feet, or other strange elements. For example, avoid "cutting off" the human body at the joints, and place the "cut-off" position in the middle of the limbs or torso, rather than at the ankles, knees, wrists, or elbows.
[0116] Among them, in the embodiments of the present application, for the visual focus information, the composition features of the target subject corresponding to it can be identified, and the composition strategy is determined according to the composition features, that is, optionally, in some embodiments of the present application, the step of "determining the composition strategy according to the visual focus information" includes:
[0117] identifying a target subject from the image to be processed according to the visual focus information;
[0118] Determining composition feature information of the target subject, wherein the composition feature information includes at least one of composition symmetry information, composition distribution information, composition ratio information and composition visual information;
[0119] A composition strategy is determined according to the composition feature information.
[0120] Among them, the composition symmetry information refers to whether the target subject is symmetrical with respect to the image to be processed. If so, a symmetry and pattern composition strategy is adopted. For example, the target subject in the image to be processed is identified through object segmentation technology, and the central axis of the target subject is used as the dividing line to determine whether the image is a symmetrical composition. If so, a symmetry and pattern composition strategy is adopted.
[0121] The composition distribution refers to the distribution of the target subject in the image to be processed. For example, the image to be processed is divided into nine-square grids, and it is determined whether the target subject is in two squares. If so, the composition strategy of the rule of thirds is adopted.
[0122] The composition ratio information refers to the composition ratio of the target subject. For example, if the target subject meets the golden ratio of 1:0.618, the composition strategy of the golden ratio is adopted.
[0123] Among them, composition visual information refers to the visual balance information of the target subject. For example, if the target subject contains multiple elements, the color contrast and distribution of the multiple elements are analyzed to determine whether to use a visual balance strategy.
[0124] Accordingly, in the embodiment of the present application, after the target image is extracted, the target image may be optimized to improve the quality of the final image. That is, optionally, in some embodiments of the present application, after the step of "extracting the target image from the image to be processed according to the composition strategy", the method further includes:
[0125] Identify the target image and determine the content definition result of the target image;
[0126] Adjust the color information of the target image according to the content definition result to obtain an optimized image;
[0127] or,
[0128] The target image is interpolated according to a preset cropping ratio to obtain an interpolated image, and according to a content definition result of the interpolated image, the color information of the interpolated image is adjusted to obtain an optimized image.
[0129] The content definition result is a result of defining a target image, which is a description of the target image. The content definition result can describe the target image from at least one of multiple dimensions such as color, subject style, subject type, size, etc. For example, the content definition result includes food, people, abstract, sports, green, fresh or rainy season, etc.
[0130] Among them, the adjustment of the color information of the target image includes adjusting the color tone of the target subject or the background color tone corresponding to the target subject, so that the overall color tone effect of the target image is better. For example, it can be adjusted to an optimized image with more obvious color contrast, or it can be adjusted to an optimized image with consistent color tone.
[0131] The preset cropping ratio refers to the ratio of the desired image to the image to be processed. If the cropped target image is smaller than the preset cropping ratio, an interpolated image can be obtained by pixel interpolation. In some embodiments, the interpolated image can be directly used as the optimized image, or the interpolated image can be further subjected to a tone adjustment process to obtain an optimized image with a higher tone effect.
[0132] In summary, the embodiments of the present application determine the composition strategy through the visual focus information of the image to be processed and extract the target image based on the composition strategy, so that the extracted target image can better focus on the key content in the image to be processed, thereby improving the quality of the generated image.
[0133] Among them, by selecting a target reference point and controlling the cropping area based on the target feature points of the target subject, the quality of the cropped target image is improved, and the visual effect of the target image is improved.
[0134] In order to better implement the image generation method of the present application, the present application also provides an image generation device based on the above image generation method. The meanings of the terms are the same as those in the above image generation method, and the specific implementation details can refer to the description in the method embodiment.
[0135] See also Figure 3 , Figure 3: is a schematic diagram of the structure of an image generating device provided in an embodiment of the present application. The image generating device may be specifically as follows:
[0136] An acquisition module 201 is used to acquire an image to be processed and identify visual focus information of the image to be processed;
[0137] A determination module 202, configured to determine a composition strategy according to the visual focus information;
[0138] The cropping module 203 is used to extract a target image from the image to be processed according to the composition strategy.
[0139] Optionally, in some embodiments of the present application, extracting a target image from the image to be processed according to the composition strategy includes:
[0140] Determine composition ratio information according to the composition strategy;
[0141] Determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed;
[0142] A target image including the target reference point and a preset area around the target reference point is obtained according to the extraction of the target reference point.
[0143] Optionally, in some embodiments of the present application, determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed includes:
[0144] generating at least one horizontal line and at least one vertical line for the image to be processed according to the composition ratio information;
[0145] determining at least one intersection point based on the at least one horizontal line and the at least one vertical line;
[0146] According to the clarity, a target intersection point is screened from the at least one intersection point, and the target intersection point is set as a target reference point.
[0147] Optionally, in some embodiments of the present application, extracting a target image including the target reference point and a preset area around the target reference point according to the target reference point includes:
[0148] Determining a target subject from the image to be processed according to the target reference point;
[0149] Constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target subject to obtain a cropping area;
[0150] A target image is obtained by cropping the image to be processed according to the cropping area.
[0151] Optionally, in some embodiments of the present application, constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target body to obtain a cropping area includes:
[0152] Constructing a cropping frame with the target reference point as the center;
[0153] Filtering target feature points from the outline of the target subject, wherein the target feature points are composition key points contained in the outline of the target subject;
[0154] The cropping frame is stretched according to the position of the target feature point to obtain a cropping area.
[0155] Optionally, in some embodiments of the present application, determining a composition strategy according to the visual focus information includes:
[0156] identifying a target subject from the image to be processed according to the visual focus information;
[0157] Determining composition feature information of the target subject, wherein the composition feature information includes at least one of composition symmetry information, composition distribution information, composition ratio information and composition visual information;
[0158] A composition strategy is determined according to the composition feature information.
[0159] Optionally, in some embodiments of the present application, after extracting the target image from the image to be processed according to the composition strategy, the method further includes:
[0160] Identify the target image and determine the content definition result of the target image;
[0161] Adjust the color information of the target image according to the content definition result to obtain an optimized image;
[0162] or,
[0163] The target image is interpolated according to a preset cropping ratio to obtain an interpolated image, and according to a content definition result of the interpolated image, the color information of the interpolated image is adjusted to obtain an optimized image.
[0164] In the embodiment of the present application, the acquisition module 201 acquires the image to be processed and identifies the visual focus information of the image to be processed, the determination module 202 determines the composition strategy according to the visual focus information, and the cropping module 203 extracts the target image from the image to be processed according to the composition strategy.
[0165] Among them, the embodiment of the present application determines the composition strategy through the visual focus information of the image to be processed and extracts the target image based on the composition strategy, so that the extracted target image can better focus on the key content in the image to be processed, thereby improving the quality of the generated image.
[0166] In addition, the present application also provides an electronic device, such as Figure 4 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically:
[0167] The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will appreciate that Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0168] The processor 301 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.
[0169] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0170] The electronic device also includes a power supply 303 for supplying power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 303 can also include any components such as one or more DC or AC power supplies, recharging systems, power supply device debugging circuits, power converters or inverters, and power status indicators.
[0171] The electronic device may further include an input unit 304, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0172] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 302 according to the following instructions, and the processor 301 will run the application programs stored in the memory 302, thereby implementing the steps in any one of the image generation methods provided in the embodiments of the present application.
[0173] The embodiment of the present application obtains an image to be processed and identifies visual focus information of the image to be processed, determines a composition strategy according to the visual focus information, and extracts a target image from the image to be processed according to the composition strategy.
[0174] Among them, the composition strategy is determined by the visual focus information of the image to be processed and the target image is extracted based on the composition strategy, so that the extracted target image can better focus on the key content of the image to be processed, thereby improving the quality of the generated image.
[0175] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0176] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0177] To this end, the present application provides a computer-readable storage medium, on which a computer program is stored. The computer program can be loaded by a processor to execute the steps in any image generation method provided in the present application.
[0178] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0179] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0180] Since the instructions stored in the computer-readable storage medium can execute the steps in any image generation method provided in the present application, the beneficial effects that can be achieved by any image generation method provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0181] The above is a detailed introduction to an image generation method, device, electronic device and computer-readable storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. An image generation method, characterized in that: The method comprises: Acquire an image to be processed and identify visual focus information of the image to be processed; Determining a composition strategy according to the visual focus information; A target image is extracted from the image to be processed according to the composition strategy.
2. The image generation method according to claim 1, characterized in that: The step of extracting a target image from the image to be processed according to the composition strategy includes: Determine composition ratio information according to the composition strategy; Determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed; A target image including the target reference point and a preset area around the target reference point is obtained according to the extraction of the target reference point.
3. The image generation method according to claim 2, characterized in that: The step of determining a target reference point from the image to be processed according to the composition ratio information and the clarity of the image to be processed includes: generating at least one horizontal line and at least one vertical line for the image to be processed according to the composition ratio information; determining at least one intersection point based on the at least one horizontal line and the at least one vertical line; According to the clarity, a target intersection point is screened from the at least one intersection point, and the target intersection point is set as a target reference point.
4. The image generation method according to claim 2, characterized in that: The step of extracting, according to the target reference point, a target image including the target reference point and a preset area around the target reference point comprises: Determining a target subject from the image to be processed according to the target reference point; Constructing a cropping frame with the target reference point as the center, and stretching the cropping frame according to the outline of the target subject to obtain a cropping area; A target image is obtained by cropping the image to be processed according to the cropping area.
5. The image generation method according to claim 4, characterized in that: The step of constructing a cropping frame with the target reference point as the center and stretching the cropping frame according to the outline of the target subject to obtain a cropping area includes: Constructing a cropping frame with the target reference point as the center; Filtering target feature points from the outline of the target subject, wherein the target feature points are composition key points contained in the outline of the target subject; The cropping frame is stretched according to the position of the target feature point to obtain a cropping area.
6. The image generation method according to claim 1, characterized in that: The determining of the composition strategy according to the visual focus information includes: identifying a target subject from the image to be processed according to the visual focus information; Determining composition feature information of the target subject, wherein the composition feature information includes at least one of composition symmetry information, composition distribution information, composition ratio information and composition visual information; A composition strategy is determined according to the composition feature information.
7. The image generation method according to claim 1, characterized in that: After extracting the target image from the image to be processed according to the composition strategy, the method further includes: Identify the target image and determine the content definition result of the target image; Adjust the color information of the target image according to the content definition result to obtain an optimized image; or, The target image is interpolated according to a preset cropping ratio to obtain an interpolated image, and according to a content definition result of the interpolated image, the color information of the interpolated image is adjusted to obtain an optimized image.
8. An image generating device, characterized in that: The device comprises: An acquisition module, used to acquire an image to be processed and identify visual focus information of the image to be processed; A determination module, used to determine a composition strategy according to the visual focus information; The cropping module is used to extract a target image from the image to be processed according to the composition strategy.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image generating method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the image generation method according to any one of claims 1 to 7 are implemented.