Image processing method, electronic device, storage medium and chip system
Patent Information
- Application Number
- CN202510200637.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2026-08-21
AI Technical Summary
[0003]目前,基于传统技术得到的胶片图像往往无法与真实胶片图像相媲美,尤其是在颗粒感层次方面,这种差异导致基于传统技术得到的胶片图像的质感不足,用户视觉体验差
[0041]采用本申请提供的上述技术方案,初始胶片颗粒图像是通过将至少一种胶片颗粒图像(第一种胶片颗粒图像)进行随机角度旋转而获得的,因此,电子设备生成的初始胶片颗粒图像具有较强的随机性,且初始胶片颗粒图像具有的颗粒的形态也呈现出较强的随机性。之后,电子设备基于待处理图像、初始胶片颗粒图像和颗粒权重集合得到的第一胶片图像,使得第一胶片图像包括的颗粒的形态更加接近真实胶片图像的颗粒的形态,可以提高图像的质感,提升用户视觉体验。
Smart Images

Figure CN122617643A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to an image processing method, electronic device, storage medium, and chip system. Background Technology
[0002] With the continuous development of terminal technology, electronic devices can provide users with a wide variety of services. In practical applications, users can use the camera of an electronic device (such as a mobile phone) to take pictures of the subject, obtaining an image including the subject. To enhance the image quality, electronic devices can add grain effects to the image, thereby generating film-like images with a film effect.
[0003] Currently, film images obtained using traditional techniques often cannot compare to real film images, especially in terms of graininess. This difference results in insufficient texture and a poor visual experience for users. Summary of the Invention
[0004] This application provides an image processing method, image processing apparatus, electronic device, storage medium, chip system, and computer program product that makes the film effect of film images closer to the film effect of real film images, thereby improving image quality and enhancing the user's visual experience.
[0005] In a first aspect, embodiments of this application provide an image processing method, the method comprising: acquiring an image to be processed, wherein the image to be processed includes Q first regions, where Q is a positive integer greater than 1; acquiring an initial film grain image, wherein the initial film grain image has uniformly distributed grains, the Q second regions included in the initial film grain image correspond one-to-one with the Q first regions, and the position of each second region in the initial film grain image is the same as the position of the corresponding first region in the image to be processed; determining a grain weight set, wherein the grain weight set includes the grain weight of each first region, and different first regions have different grain weights; and obtaining a first film image based on the image to be processed, the initial film grain image, and the grain weight set, wherein the first film image includes Q third regions corresponding one-to-one with the Q first regions, each third region is determined based on a corresponding first region, the grain weight of the corresponding first region, and a corresponding second region, and different third regions correspond to grains of different sizes.
[0006] The image processing method provided in this application embodiment can be executed by an electronic device, such as, but not limited to, a mobile phone or tablet computer.
[0007] An initial film grain image is an image with uniformly distributed grains. That is, an initial film grain image may include one or more grain shapes (also known as patterns), and the grains included in the initial film grain image are uniformly distributed in the initial film grain image. For example, the one or more grain shapes (patterns) may include, but are not limited to, one or more shapes selected from circles, triangles, teardrop shapes, hexagons, and thin lines.
[0008] Different particle weights correspond to different particle sizes. In one example, a larger particle weight corresponds to a larger particle size, and a smaller particle weight corresponds to a smaller particle size. In another example, a larger particle weight corresponds to a smaller particle size, and a smaller particle weight corresponds to a larger particle size.
[0009] Different third regions correspond to particles of different sizes, also known as different third regions corresponding to particles of different sizes, or different third regions corresponding to particles of different dimensions. The particle size is not specifically limited; for example, particle size can include fine, medium, and coarse particles.
[0010] Film images obtained using traditional techniques contain grains of the same size in different regions, while real film images contain grains of different sizes in different regions. In other words, the film effect of film images obtained using traditional techniques does not match that of real film images, making it difficult to improve the image quality and resulting in a poor visual experience for users.
[0011] Using the technical solution provided in this application, the electronic device does not assign the same grain weight (corresponding to grains of the same size) to all first regions included in the image to be processed. Instead, it assigns different grain weights (corresponding to grains of different sizes) to different first regions included in the image to be processed, resulting in a set of grain weights. Then, based on the image to be processed, the initial film grain image, and the set of grain weights, the electronic device obtains a first film image with a film effect (grain shape and grain size), such that different third regions included in the first film image have grains of different sizes. Based on this method, it is possible to avoid the final first film image having grains of the same size in all different first regions, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thereby improving image quality and enhancing the user's visual experience.
[0012] In one possible implementation, determining the set of granular weights includes: determining Q first granular weights based on a first preset relationship and Q first regions, wherein the first preset relationship includes at least Q one-to-one correspondences between the Q first regions and the Q first granular weights; and determining the set of granular weights based on the Q first granular weights.
[0013] Using the technical solution provided in this application, the electronic device can obtain Q first particle weights corresponding one-to-one with the Q first regions based on a predefined preset relationship (first preset relationship) and the Q first regions included in the image to be processed. Different first regions correspond to particles of different granularities. Then, the electronic device determines the particle weight set based on the Q first particle weights. This implementation process is relatively simple and helps improve image processing efficiency.
[0014] In another possible implementation, the set of granular weights includes Q first granular weights.
[0015] Using the technical solution provided in this application, the electronic device assigns a first grain weight to each of the Q first regions included in the image to be processed, and different first regions correspond to different first grain weights (corresponding to grains of different sizes). Then, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the set of grain weights, such that different third regions included in the first film image have grains of different sizes. Based on this method, it is possible to avoid the final first film image having grains of the same size in all different first regions, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thereby improving image texture and enhancing the user's visual experience.
[0016] In another possible implementation, there is a one-to-one correspondence between Q brightness ranges and Q first regions, where the brightness of each first region is the brightness within the corresponding brightness range, and different first regions correspond to different brightness ranges; there is also a one-to-one correspondence between Q brightness ranges and Q first particle weights, where the particle weight of each first region is the first particle weight corresponding to the corresponding brightness range, and different brightness ranges correspond to different first particle weights.
[0017] Any one of the Q brightness ranges can include one brightness or multiple brightness levels, without specific limitations.
[0018] Using the technical solution provided in this application, the electronic device determines the grain weight set based solely on the Q brightness ranges corresponding to the Q first regions. Then, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set, resulting in different brightness regions within the first film image having grains of different grain sizes. This method avoids the final first film image having grains of the same grain size in different brightness regions, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thus improving image quality and enhancing the user's visual experience.
[0019] In another possible implementation, there is a one-to-one correspondence between Q first regions and Q semantic information, with the semantic information of each first region being the corresponding semantic information, and different first regions corresponding to different semantic information; there is a one-to-one correspondence between Q semantic information and Q first particle weights, with the particle weight of each first region being the first particle weight corresponding to the semantic information, and different semantic information corresponding to different first particle weights.
[0020] Using the technical solution provided in this application, the electronic device determines the grain weight set based solely on the Q semantic information corresponding to the Q first regions. Then, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set. This results in different grain sizes for regions with different semantic information included in the first film image. Based on this method, it avoids the situation where different semantic regions in the final first film image all have grains of the same size, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image. This improves image quality and enhances the user's visual experience.
[0021] In another possible implementation, Q brightness ranges correspond one-to-one with Q first regions, the brightness of each first region is the brightness within the corresponding brightness range, different first regions correspond to different brightness ranges, and; a set of particle weights is determined based on the Q first particle weights, including: determining second particle weights based on a second preset relationship and semantic information of the target region in the image to be processed, wherein the second preset relationship includes at least the correspondence between semantic information and second particle weights; determining the particle weight of the region in the i-th first region that does not overlap with the target region, which is the particle weight of the i-th first region; and determining the particle weight of the region in the i-th first region that overlaps with the target region, which is the product of the particle weight of the i-th first region and the second particle weight; wherein the i-th first region is any one of the Q first regions, the Q brightness ranges correspond one-to-one with the Q first particle weights, the particle weight of the i-th first region is the i-th first particle weight corresponding to the i-th brightness range, and i is a positive integer less than or equal to Q.
[0022] The target region can be a region of interest in the image to be processed, and there are no specific limitations on the content included in the target region. For example, the target region can be a face region or a facial skin region in the image to be processed. For example, the target region can be a plant region in the image to be processed.
[0023] Using the technical solution provided in this application, the electronic device determines a grain weight set based on Q brightness ranges corresponding one-to-one with Q first regions included in the image to be processed, and semantic information of the target region included in the image to be processed. Then, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set, such that the grain size of different brightness regions included in the first film image is different, and that the grain size of the region overlapping with the target region (overlapping region) within the same brightness region of the first film image is different from the grain size of the region not overlapping with the target region (non-overlapping region) within the same brightness region. Based on this method, it is possible to avoid the final first film image having grains of the same grain size in different brightness regions. Simultaneously, it is possible to distinguish the grain size of the grains in the overlapping region and the grain size of the grains in the non-overlapping region within the same brightness region, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thereby improving image texture and enhancing the user's visual experience.
[0024] In another possible implementation, the target region is the face region.
[0025] Using the technical solution provided in this application, the electronic device sets different grain weights for the target area and different brightness areas (i.e., first areas with different brightness ranges) included in the image to be processed, thereby obtaining a grain weight set. Then, the electronic device generates a first film image based on the image to be processed, the initial film grain image, and the grain weight set. For example, when the grain weight (second grain weight) of the target region in the image to be processed is set to be small (i.e., the corresponding grain size is small), the grain weight of the brighter areas (bright areas) in the image to be processed is set to be small, and the grain weight of the darker areas (dark areas) in the first film image is set to be large (i.e., the corresponding grain size is large), the grain size of the face region in the first film image is small, the grain size of the brighter areas (e.g., bright areas or highlight areas) in the first film image is small (more delicate), and the grain size of the darker areas (e.g., dark areas) in the first film image is large (more coarse). This makes the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, which can improve the image quality and enhance the user's visual experience.
[0026] In another possible implementation, a first film image is obtained based on the image to be processed, an initial film grain image, and a grain weight set. This includes: obtaining a first luminance image and a first chroma image in a second color space based on the image to be processed located in a first color space. The first luminance image is obtained by extracting the luminance of the first image, which is obtained by converting the image to be processed to the second color space. The first luminance image includes Q fourth regions and Q luminance ranges that correspond one-to-one. The luminance of each fourth region is the luminance within the corresponding luminance range, and different fourth regions correspond to different luminance ranges. The first chroma image is obtained by extracting the chroma of the first image. A first fused image is obtained based on the first luminance image, the initial film grain image, and the grain weight set. The first chroma image and the first fused image are superimposed to obtain a second film image. The second film image is then converted to the first color space to obtain the first film image.
[0027] Q fourth regions correspond one-to-one with Q first regions. Each fourth region is obtained by extracting the brightness of the region after converting the corresponding first region to the second color space.
[0028] Using the technical solution provided in this application, the electronic device segments a first image located in the second color space into a first luminance image and a first chroma image located in the second color space. Then, based on the initial film grain image and grain weight set, the electronic device independently adds grain effects to the first luminance image, avoiding interference with the chroma information of the first chroma image. Subsequently, during the superposition processing of the first chroma image and the first fused image, the chroma information of the first chroma image is not affected; that is, the chroma information of the resulting first fused image is closer to the chroma information of the first chroma image. Therefore, this method, while ensuring that the film effect (i.e., grain size) of the first film image obtained after image processing is closer to the film effect (i.e., grain size) of the real film image, also helps to improve the color quality of the first film image, enhance the image texture, and better meet the user's visual needs.
[0029] In another possible implementation, the first brightness range and the second brightness range are any two different brightness ranges among Q brightness ranges; the brightness of the first brightness range is higher than the brightness of the second brightness range, and the first particle weight corresponding to the first brightness range is less than the first particle weight corresponding to the second brightness range.
[0030] By adopting the above-mentioned technical solution provided in this application, the electronic device sets the grain weight of the first region with higher brightness to be smaller, so that the grain size of the third region corresponding to the first region with higher brightness in the first film image is smaller (more delicate); and sets the grain weight of the first region with lower brightness to be larger, so that the grain size of the third region corresponding to the first region with lower brightness in the first film image is larger (more coarser), thereby making the film effect (i.e. grain size) of the first film image closer to the film effect (i.e. grain size) of a real film image, which can improve the image texture and enhance the user's visual experience.
[0031] In another possible implementation, the first color space is the RGB color space, and the second color space is one of the following: YUV color space, HSV color space, or LAB color space.
[0032] In another possible implementation, the initial film grain image is a film image obtained by taking pictures of a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image.
[0033] For example, the preset proportion of neutral gray area may be, but is not limited to, 18% neutral gray area.
[0034] In traditional techniques, noise extracted from the original RAW image is used as particles, which are then superimposed onto the image to be processed to obtain a film-like image. The noise extracted from the original RAW image typically has a fixed shape (e.g., thin lines). However, in practical applications, the shape of particles in a real film image can be random. For example, the shape of particles in a real film image can include, but is not limited to, at least one of the following shapes: circular, triangular, rectangular, pentagonal, hexagonal, thin lines, etc. Therefore, the shape of the noise in the noise image extracted using traditional techniques does not match the shape of the particles in the real film image, resulting in a discrepancy between the particle shape of the obtained film image and the particle shape of the real film image.
[0035] Using the technical solution provided in this application, the electronic device does not use noise with a fixed shape obtained by noise extraction from the original RAW image as grain. Instead, it uses a film image obtained by shooting a central gray area of a preset proportion with a film camera as the initial film grain image, or it optimizes (uniformly distributes) the local film grains in the film image obtained by shooting a gray area of a preset proportion with a film camera, and uses the optimized film image as the initial film grain image. In other words, the grain shape of the initial film grain image obtained above is the same as the grain shape of the real film image. Furthermore, the first film image with film effect obtained by the electronic device based on the initial film grain image makes the grain shape of the first film image closer to the grain shape of the real film image, which can further improve the image texture and enhance the user's visual experience.
[0036] In another possible implementation, obtaining an initial film grain image includes: obtaining at least one film grain image, wherein each of the at least one film grain image is a film image obtained by taking pictures of a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image; and obtaining an initial film grain image based on the at least one film grain image.
[0037] Using the technical solution provided in this application, the electronic device needs to pre-store one or more film grain images. Then, the electronic device can obtain an initial film grain image based on these one or more film grain images. This acquisition method is relatively simple and helps improve image processing efficiency.
[0038] In another possible implementation, obtaining an initial film grain image based on at least one film grain image includes: randomly selecting a film grain image from at least one film grain image to obtain the initial film grain image.
[0039] Using the technical solution provided in this application, the initial film grain image is a film grain image randomly selected from at least one film grain image. That is, the initial film grain image obtained by the electronic device has a high degree of randomness, resulting in a high degree of randomness in the morphology of the grains. Subsequently, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and a grain weight set. This makes the morphology of the grains in the first film image closer to that of the grains in a real film image, thereby improving image quality and enhancing the user's visual experience.
[0040] In another possible implementation, at least one film grain image includes a first film grain image, wherein the angle between the central axis of the first film grain image and the central axis of the image to be processed is zero degrees; and, based on the at least one film grain image, obtaining an initial film grain image includes: rotating the first film grain image to obtain a rotated first film grain image, wherein the angle between the central axis of the rotated first film grain image and the central axis of the image to be processed is non-zero degrees; if the size of the rotated first film grain image is different from the size of the image to be processed, cropping or expanding the rotated first film grain image to obtain the initial film grain image; or, if the size of the rotated first film grain image is the same as the size of the image to be processed, determining the rotated first film grain image as the initial film grain image to obtain the initial film grain image.
[0041] Using the technical solution provided in this application, the initial film grain image is obtained by randomly rotating at least one film grain image (the first type of film grain image). Therefore, the initial film grain image generated by the electronic device has strong randomness, and the shape of the grains in the initial film grain image also exhibits strong randomness. Subsequently, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set, making the shape of the grains in the first film image closer to the shape of the grains in a real film image, which can improve the image quality and enhance the user's visual experience.
[0042] In another possible implementation, at least one film grain image specifically includes a first film grain image having a two-dimensional morphology, and; obtaining an initial film grain image based on at least one film grain image includes: generating a first rotating sequence film grain image having a three-dimensional hollow cylindrical morphology based on the first film grain image; randomly cropping a second rotating sequence film grain image having a three-dimensional hollow cylindrical morphology to obtain an initial film grain image having a two-dimensional morphology, wherein the second rotating sequence film grain image is the first rotating sequence film grain image, or is an image obtained by rotating the first rotating sequence film grain image.
[0043] Using the technical solution provided in this application, the initial film grain image is an image obtained by randomly cropping a second-rotation sequence of film grain images based on at least one film grain image (the first type of film grain image). That is, the initial film grain image obtained by the electronic device has a high degree of randomness, resulting in a high degree of randomness in the grain morphology. Subsequently, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and a grain weight set. This makes the grain morphology of the first film image closer to that of real film images, thereby improving image quality and enhancing the user's visual experience.
[0044] In another possible implementation, acquiring the image to be processed includes: displaying a first interface; detecting a first operation on a first control included in the first interface; and acquiring the image to be processed in response to the first operation.
[0045] In another possible implementation, the first interface is a portrait mode photo-taking interface, and the first control is a control used to indicate taking a photo.
[0046] Using the above-mentioned technical solution provided in this application, an electronic device can process the image to be processed acquired in the portrait mode shooting interface to obtain a first film image with film effect corresponding to the image to be processed.
[0047] Secondly, embodiments of this application provide an image processing apparatus, which includes a unit for performing any of the image processing methods in the first aspect.
[0048] Thirdly, an electronic device is provided, including a unit for performing any of the image processing methods in the first aspect. The electronic device may be a terminal device or a chip within a terminal device. The electronic device may include an input unit and a processing unit.
[0049] When the electronic device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may also include a memory for storing computer program code, which, when the processor executes the computer program code stored in the memory, causes the terminal device to execute any of the image processing methods in the first aspect.
[0050] When the electronic device is a chip within a terminal device, the processing unit can be an internal processing unit of the chip, and the input unit can be an output interface, pin, or circuit, etc.; the chip can also include a memory, which can be an internal memory of the chip (e.g., registers, cache, etc.) or an external memory (e.g., read-only memory, random access memory, etc.); the memory is used to store computer program code, and when the processor executes the computer program code stored in the memory, the chip performs any of the image processing methods in the first aspect.
[0051] In one possible implementation, the memory is used to store computer program code; the processor executes the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor is used to perform any of the image processing methods in the first aspect.
[0052] Fourthly, a computer-readable storage medium is provided that stores computer program code, which, when executed by an electronic device, causes the electronic device to perform any of the image processing methods described in the first aspect.
[0053] Fifthly, embodiments of this application provide a chip system applied to an electronic device. The chip system includes one or more processors, which are used to invoke computer instructions to cause the electronic device to perform any of the image processing methods described in the first aspect.
[0054] In a sixth aspect, a computer program product is provided, comprising: computer program code, which, when executed by an electronic device, causes the electronic device to perform any of the image processing methods described in the first aspect.
[0055] It is understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.
[0056] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description
[0057] Figure 1 This is a schematic diagram illustrating an application scenario of the image processing method provided in the embodiments of this application.
[0058] Figure 2 This is a schematic flowchart of an image processing method.
[0059] Figure 3 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application.
[0060] Figure 4 This is a schematic diagram of a software system for an electronic device provided in an embodiment of this application.
[0061] Figure 5 This is a schematic flowchart of an image processing method provided in an embodiment of this application.
[0062] Figure 6 The above Figure 5 A schematic diagram of an image involved in an image processing method is provided.
[0063] Figure 7 The above Figure 5 A schematic diagram illustrating the division of brightness regions involved in an image processing method is provided.
[0064] Figure 8 The above Figure 5 A schematic diagram illustrating the division of brightness regions in a first brightness image involved in an image processing method is provided.
[0065] Figure 9 The above Figure 5 A flowchart illustrating an execution step S508 in an image processing method is provided.
[0066] Figure 10 The above Figure 9 A schematic diagram of various film grain images provided in step S508-1a.
[0067] Figure 11 The above Figure 9 A schematic diagram of the first film grain image in step S508-2a.
[0068] Figure 12 The above Figure 5 A flowchart illustrating another execution step S508 in an image processing method is provided.
[0069] Figure 13 The above Figure 12 A schematic diagram of the first film grain image in step S508-2b.
[0070] Figure 14 The above Figure 5 A flowchart illustrating another execution step S508 in an image processing method is provided.
[0071] Figure 15 The above Figure 14 A schematic diagram of the images involved in the provided steps.
[0072] Figure 16 The above Figure 5 A flowchart illustrating another execution step S509 in an image processing method is provided.
[0073] Figure 17 The above Figure 16 A schematic diagram of the images involved in the provided execution step S509.
[0074] Figure 18 Is to execute the above Figure 5 A schematic diagram comparing the effects of the film image obtained later with those obtained using traditional techniques.
[0075] Figure 19 This is a schematic flowchart of another image processing method provided in the embodiments of this application.
[0076] Figure 20 The above Figure 19 A schematic diagram of the images involved in the provided image processing method.
[0077] Figure 21 This is a schematic flowchart of another image processing method provided in the embodiments of this application.
[0078] Figure 22 This is a schematic diagram of the interface of an electronic device provided in an embodiment of this application.
[0079] Figure 23 This is a schematic diagram of the interface of another electronic device provided in an embodiment of this application.
[0080] Figure 24 This is a schematic diagram of the interface of another electronic device provided in an embodiment of this application.
[0081] Figure 25 This is a schematic diagram of an image processing apparatus provided in an embodiment of this application. Detailed Implementation
[0082] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0083] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0084] It should be understood that "one or more" as mentioned in this application refers to one, two, or more, and "multiple" as mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0085] Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first" and "second" are used to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" do not necessarily imply differences.
[0086] The terms "one embodiment" or "some embodiments" used in this application mean that one or more embodiments of this application include the specific features, structures, or characteristics described in that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this application do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0087] In the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0088] The technical solution provided in this application will now be described in detail.
[0089] To facilitate a better understanding of the image processing method provided in the embodiments of this application, the relevant terms involved in the embodiments of this application will be briefly introduced first.
[0090] 1. Film images
[0091] A film image is an image that exhibits a film effect (also known as film texture). This film effect can be the result of the film grain layers included in the film image. A film image can be obtained by processing a digital image, or it can be obtained by processing a film image with a specific film effect; there is no specific limitation in either case.
[0092] In practical applications, film effects in film images can include the shape of the grain (e.g., triangles, circles, hexagons, irregular shapes, fine lines, etc.) and the grain size (also known as grain intensity, grain size, or grain coarseness). The grain shape, also called the grain pattern or grain type, refers to the type of pattern the grain belongs to. Grain size refers to the coarseness or size of the grain. For example, a film effect can specifically include fine, round grains. Another example is a coarse (larger) hexagonal grain. Yet another example is a film effect that can include both fine triangular grains and coarse hexagonal grains.
[0093] 2. YUV color space
[0094] The YUV color space, also known as the YUV color space, is a method for color encoding. It consists of a luminance component (Y) and two chrominance components (U and V). The Y component represents the brightness of the image, while the U and V components contain chrominance information, namely the type and saturation of the color. The YUV color space is designed with human perception of luminance in mind, which is higher than chrominance. Therefore, in video transmission, the bandwidth of the chrominance component can be reduced to decrease the amount of data without significantly affecting image quality.
[0095] The YUV color space is derived from the red-green-blue (RGB) color space. In RGB mode, color is represented by a mixture of red (R), green (G), and blue (B). The YUV color space converts this representation into a format that includes luminance (Y) and two chromaticity components (U and V). The luminance component Y is a weighted sum of the three RGB colors, while the U and V components can be considered as the luminance minus the blue and red components.
[0096] The following is combined with Figure 1 This paper introduces the application scenarios of the image processing method provided in the embodiments of this application.
[0097] Figure 1 This is a schematic diagram illustrating an application scenario of the image processing method provided in the embodiments of this application.
[0098] For example, Figure 1 The illustrated application scenarios may include at least one electronic device 100, which may also be referred to as a terminal device, terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The electronic device 100 can execute the image processing method provided in the embodiments of this application on the image to be processed to obtain a film image corresponding to the image to be processed. Afterwards, the electronic device can display or save the obtained film image corresponding to the image to be processed.
[0099] In this application embodiment, the specific device form of electronic device 100 is not specifically limited. For example, electronic device 100 may be, but is not limited to, at least one of mobile phone, tablet computer, wearable device (WD), camera, ultra-mobile personal computer (UMPC), augmented reality (AR) / virtual reality (VR), desktop computer, netbook, e-book reader, smart TV, wireless terminal in smart home, personal digital assistant (PDA), game console, in-vehicle device, and laptop computer. Mobile phone may include foldable screen phone, candybar phone, etc.
[0100] It should be noted that electronic device 100 can refer to one of multiple terminals or a collection of multiple terminals.
[0101] It should be understood that Figure 1 The application scenarios shown are for illustrative purposes only and do not constitute any limitation on the application scenarios applicable to the image processing methods provided in the embodiments of this application. Optionally, Figure 1 The application scenarios shown can also include a greater number of electronic devices 100.
[0102] With the continuous development of terminal technology, electronic devices can provide users with a wide variety of services. In practical applications, users can use the camera of an electronic device (such as a mobile phone) to take pictures of the subject and obtain an image containing the subject. To enhance the image quality, electronic devices can add film effects (such as grain) to the image, thereby generating a film-like image similar to that obtained by a film camera.
[0103] For example, Figure 2 This is a schematic flowchart of an image processing method. See also... Figure 2 In traditional techniques, a noise extraction algorithm is first applied to the original image (e.g., a raw RAW image captured by a camera on an electronic device) to obtain a noisy image with noise effects. Next, the image to be processed undergoes noise reduction and enhancement processes sequentially to obtain a processed image. Then, the noisy image with noise effects obtained in the previous steps is superimposed onto the processed image to obtain a film image 1 with a film effect. If film image 1 includes a facial region, a portrait mode morphological beautification algorithm can be used to optimize the facial region included in film image 1 (e.g., slimming the face, enlarging the eyes, etc.) to obtain a film image 2 with a film effect.
[0104] In practical applications, the shape of grains in real film images can be random. For example, the shape of grains in real film images can include, but is not limited to, at least one of the following shapes: circular, triangular, rectangular, pentagonal, hexagonal, thin line, etc. However, in the above image processing, noise with a fixed shape (e.g., thin line) is superimposed on the processed image, resulting in a significant difference between the shape of the noise in the noise image extracted based on traditional techniques and the shape of grains in the real film image. In addition, the above noise reduction algorithm can eliminate or affect the extracted noise, the above enhancement algorithm can increase the noise, and the above portrait mode morphology beautification algorithm can change the shape of stretched or distorted noise, resulting in a greater difference between the shape of grains in the final film image 2 and the shape of grains in the real film image. Furthermore, the grain size (also known as intensity, size, or coarseness) of the grains in the film image obtained based on the above method does not match the grain size of the grains in the real film image. In summary, the film effect (i.e., grain shape and grain size) of film images obtained by traditional techniques differs significantly from the film effect of real film images, making it difficult to improve image quality and resulting in a poor visual experience for users.
[0105] Therefore, to solve the above problems, this application provides an image processing method, an image processing apparatus, an electronic device, a storage medium, a chip system, and a computer program product. The image processing method includes: acquiring an image to be processed, wherein the image to be processed includes Q first regions, where Q is a positive integer greater than 1; acquiring an initial film grain image, wherein the initial film grain image has uniformly distributed grains, and the Q second regions and Q first regions included in the initial film grain image correspond one-to-one, with each second region located at the same position in the initial film grain image as the corresponding first region located in the image to be processed; determining a grain weight set, wherein the grain weight set includes the grain weight of each first region, and different first regions have different grain weights; and obtaining a first film image based on the image to be processed, the initial film grain image, and the grain weight set, wherein the first film image includes Q third regions and Q first regions, each third region being determined based on a corresponding first region, the grain weight of the corresponding first region, and a corresponding second region, with different third regions corresponding to grains of different sizes. Based on the above solution, the film effect of the film image is made closer to that of the real film image, which can improve the image quality and enhance the user's visual experience.
[0106] Below, in conjunction with Figure 3 and Figure 4 The hardware and software structures of electronic devices are described in detail.
[0107] Figure 3This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application.
[0108] Please see Figure 3 The electronic 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, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0109] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0110] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0111] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0112] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from this memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0113] For example, in some embodiments, the processor 110 is configured to: acquire an image to be processed, wherein the image to be processed includes Q first regions, where Q is a positive integer greater than 1; acquire an initial film grain image, wherein the initial film grain image has uniformly distributed grains, and the Q second regions and Q first regions included in the initial film grain image correspond one-to-one, with each second region located at the same position in the initial film grain image as the corresponding first region located at the same position in the image to be processed; determine a grain weight set, wherein the grain weight set includes the grain weight of each first region, and different first regions have different grain weights; and obtain a first film image based on the image to be processed, the initial film grain image, and the grain weight set, wherein the first film image includes Q third regions and Q first regions, each third region being determined based on a corresponding first region, the grain weight of the corresponding first region, and a corresponding second region, with different third regions corresponding to grains of different sizes.
[0114] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0115] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0116] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via a USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device 100 via the power management module 141.
[0117] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0118] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0119] Antennas 1 and 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. Mobile communication module 150 can provide solutions for wireless communication applications in electronic device 100, including 2G / 3G / 4G / 5G. Wireless communication module 160 can provide solutions for wireless communication applications in electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), and other wireless communication technologies.
[0120] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0121] Display screen 194 is used to display camera application interfaces, images, videos, etc. For example, the application interface displayed on display screen 194 may include, but is not limited to, […]. Figure 22 , Figure 23 or Figure 24The user interface of the mobile phone is shown. The display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Micro-LED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N displays 194, where N is an integer greater than 1.
[0122] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0123] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's image sensor. The light signal is converted into an electrical signal, and the image sensor transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimizations on image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be integrated into the camera 193.
[0124] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, electronic device 100 may include one or N cameras 193, where N is an integer greater than 1. For example, with N equal to 2, electronic device 100 may include a front-facing camera and a rear-facing camera.
[0125] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP performs Fourier transforms on the frequency energy.
[0126] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0127] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions, such as saving music, video, and other files on the external memory card.
[0128] Internal memory 121 can be used to store computer-executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created by electronic device 100 during use (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0129] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D and application processor.
[0130] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A may be disposed on display screen 194. When a touch operation is applied to display screen 194, electronic device 100 detects the intensity of the touch operation based on pressure sensor 180A. For example, taking electronic device 100 as an example... Figure 23 Taking the mobile phone shown as an example, when the user... Figure 23When the camera application control 2320 on the desktop 2310, as shown in diagram (b), performs a touch operation, the touch sensor in the mobile phone can detect the pressure intensity of the touch operation. The electronic device 100 can also calculate the touch position based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with a touch operation intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed; when a touch operation with a touch operation intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.
[0131] The ambient light sensor 180L is used to sense the brightness of ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 based on the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also work with the proximity sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0132] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. Touch sensor 180K can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194. For example, taking electronic device 100 as... Figure 23 Taking the mobile phone shown as an example, when the user... Figure 23 When the camera application control 2320 on the desktop 2310 shown in diagram (b) performs a touch operation, the touch sensor in the mobile phone can detect the touch operation. For example, taking electronic device 100 as an example... Figure 24 Taking the mobile phone shown as an example, when the user... Figure 24 When the control 2441 with superimposed film grains in the interface 2440 shown in (b) performs a touch operation, the touch sensor in the mobile phone can detect the touch operation.
[0133] It should be understood that the above Figure 3 The connection relationships between the modules shown are merely illustrative and do not constitute a limitation on the connection relationships between the modules of the electronic device 100. Optionally, the modules of the electronic device 100 may also adopt a combination of various connection methods described in the above embodiments.
[0134] The hardware system of electronic device 100 has been described in detail above. The software system of electronic device 100 is described below. The software system can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment takes a layered architecture as an example to exemplarily describe the software system of electronic device 100.
[0135] Figure 4 This is a schematic diagram of a software system for an electronic device provided in an embodiment of this application.
[0136] Please see Figure 4 The software system of electronic device 100 adopts a layered architecture. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom: application layer 410, application framework layer 420, Android Runtime and core library layer 430, hardware abstraction layer (HAL) 440, and kernel layer 450.
[0137] Application layer 410 may include a series of application packages. For example, application packages may include applications such as lock screen, chat, maps, calendar, music, gallery, camera, navigation, Bluetooth, and video.
[0138] The applications mentioned above can include more specific functional modules. For example, a gallery can include business modules and notification modules. A camera can include a photo-taking module.
[0139] The applications mentioned above can be used to generate application data. For example, a lock screen application can be used to generate lock screen wallpapers. A gallery application can be used to generate photo data.
[0140] The application framework layer 420 provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer 420 includes some predefined functions.
[0141] like Figure 4 As shown, the application framework layer 420 may include a window manager, notification manager, activity manager, input manager, view system, content provider, resource manager, etc.
[0142] The window manager provides a window management service (WMS), which can be used for window management, window animation management, surface management, and as a relay station for the input system.
[0143] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, etc.
[0144] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon can include views for displaying text and views for displaying images. For example, a display interface can be, but is not limited to, […]. Figure 22 , Figure 23 or Figure 24 The page showing the electronic device.
[0145] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and so on.
[0146] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0147] The Activity Manager Service (AMS) can be used to start, switch, and schedule system components (such as activities, services, content providers, and broadcast receivers), as well as manage and schedule application processes.
[0148] The input manager can provide an input management service (IMS), which can be used to manage system inputs, such as touchscreen input, keypad input, and sensor input. IMS retrieves events from input device nodes and, through interaction with the WMS, distributes these events to the appropriate windows.
[0149] The Android Runtime consists of core libraries and a virtual machine. The Android Runtime is responsible for scheduling and managing the Android system.
[0150] The core library consists of two parts: one part is the functionalities that need to be called by programming languages (such as Java), and the other part is the Android core library.
[0151] Application layer 410 and application framework layer 420 run in a virtual machine. The virtual machine executes the programming files (e.g., Java files) of application layer 410 and application framework layer 420 as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0152] The core library layer 430 can include multiple functional modules, such as: surface manager, media framework, libc, SQLite, etc.
[0153] The Surface Manager is used to manage the display subsystem and provides the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications.
[0154] The media framework supports playback and recording of various commonly used audio and video formats, as well as still image files.
[0155] libc (the C library) is the standard library for the C programming language. libc is one of the lowest-level libraries in the system, implemented through Linux system calls. For example, libc can be used to connect or disconnect camera services, set camera shooting parameters, start and stop previewing, and take photos.
[0156] The Hardware Abstraction Layer (HAL) 440 is an interface layer located between the operating system kernel and upper-level software, its purpose being to abstract hardware. The HAL is an abstract interface for device kernel drivers, used to provide application programming interfaces for accessing the underlying devices to higher-level Java API frameworks. The HAL contains several library modules, such as... Figure 4 The examples shown include display modules, audio modules, camera modules, and Bluetooth modules. Each library module implements an interface for a specific type of hardware component. When the system framework layer API requests access to the portable device's hardware, the Android operating system loads the library module for that hardware component.
[0157] Kernel layer 450 is the foundation of the Android operating system; all the final functions of the Android operating system are implemented through the kernel layer. The kernel layer may include, but is not limited to, […]. Figure 4 The driver shown includes the display driver, audio driver, camera driver, and Bluetooth driver.
[0158] It should be noted that the application provides Figure 4The illustrated software architecture diagram of the electronic device is merely an example and does not limit the specific module divisions within different layers of the Android operating system. For details, please refer to the descriptions of the Android operating system software architecture in conventional technologies. Furthermore, the image processing method provided in this application can also be implemented on other operating systems (e.g., mobile operating systems (iPhone Operating System, iOS) or HarmonyOS, etc.), which will not be listed here.
[0159] The following is combined with Figures 5 to 21 The image processing method provided in the embodiments of this application will be described in detail.
[0160] The image processing method in this application embodiment can be applied to, but is not limited to, the field of photography; through the image processing method in this application embodiment, the original image obtained by shooting can be processed so that the processed image presents a film effect that is closer to the film effect of a real film image, thereby improving the image quality and enhancing the user's visual experience.
[0161] Optionally, the image processing method of this application embodiment can be applied to the portrait mode of a camera application.
[0162] Optionally, if the electronic device has sufficient computing power, the image processing method in this application embodiment can also be applied to the fields of video recording, video calling, or other image processing fields.
[0163] For example, video call scenarios may include, but are not limited to, the following: video calls, video conferencing applications, long and short video applications, live video applications, online video courses, intelligent portrait camera movement applications, video recording by system camera recording function, video surveillance, or portrait shooting scenarios such as smart doorbells.
[0164] Optionally, if the electronic device has sufficient computing power, the image processing method in this application embodiment can also be applied to preview scenarios, including but not limited to the following scenarios: photo preview, aperture preview, night scene preview, portrait preview, video preview, or professional preview.
[0165] It should be understood that a preview scene can refer to a scene in which the electronic device is in a certain shooting mode and before the button indicating shooting is clicked, in which the electronic device captures an image.
[0166] It should be understood that the above are illustrative examples of application scenarios and do not constitute any limitation on the application scenarios to which the image processing method provided in the embodiments of this application is applicable.
[0167] Example 1
[0168] Figure 5This is a schematic flowchart illustrating an image processing method provided in an embodiment of this application. The image processing method 500 provided in this embodiment can be... Figure 1 or Figure 3 The electronic device shown performs the image processing method 500, which includes steps S501 to S513. Steps S501 to S513 are described in detail below.
[0169] In step S501, the camera application is run.
[0170] For example, a user can instruct the electronic device to run the camera app by clicking the "Camera" app icon; alternatively, when the electronic device is locked, the user can instruct the electronic device to run the camera app by swiping right on the screen. Alternatively, when the electronic device is locked, the lock screen may include a camera app icon, which the user can click to instruct the electronic device to run the camera app. Or, when the electronic device is running another app that has permission to access the camera app, the user can instruct the electronic device to run the camera app by clicking the corresponding control.
[0171] For example, when an electronic device is running an instant messaging application, the user can instruct the electronic device to run the camera application by selecting the camera function control.
[0172] It should be understood that the above is an example of operating a camera application; the camera application can also be operated by voice commands or other methods; this application does not limit this in any way.
[0173] Once an electronic device runs a camera application, the shooting mode in the camera application's preview interface is not specifically limited. For example, the shooting mode in the preview interface could be portrait mode, or a film mode within portrait mode. Alternatively, the shooting mode in the preview interface could be a still image mode.
[0174] In step S502, the image to be processed is acquired.
[0175] For example, a user can click the shooting control in the camera application's photo preview interface to make the electronic device take a picture of the subject and obtain an image to be processed.
[0176] For example, the image to be processed may be, but is not limited to, Figure 6 The image to be processed shown in (a) includes a face region and a background region. Figure 6 In (a) shown in the image to be processed, the eye region in the face region has been occluded.
[0177] In step S503, the image to be processed is converted to the YUV color space to obtain a first image, wherein the first image is an image in the YUV color space.
[0178] The first image is an image in the YUV color space, meaning it is an image in the YUV domain. In the YUV color space, the Y component represents luminance, while the U and V components contain chromaticity information, i.e., the type and saturation of the color. Therefore, the first image located in the YUV domain consists of three components, which can each correspond to a separate layer. The first image is obtained by superimposing these three layers.
[0179] For example, taking an image in RGB color format as the example, an electronic device can convert an image in RGB color format to YUV color space using the following formula:
[0180] Y=0.2990×R+0.5870×G+0.1140×B
[0181] U=-0.1684×R-0.3316×G+0.5×B+128
[0182] V=0.5×R-0.4187×G-0.083×B+128
[0183] In the above formula, R represents the red component of a pixel, G represents the green component of the pixel, B represents the blue component of the pixel, Y represents the luminance component of the pixel, and U and V represent the chrominance components of the pixel.
[0184] Optionally, when the image to be processed in step S502 is an image in the YUV color space, step S503 can be replaced by the following step: determining the image to be processed as a first image to obtain the first image. That is, in this implementation, the image to be processed is the first image.
[0185] In step S504, the luminance component is extracted from the first image to obtain the first luminance image.
[0186] After obtaining a first image located in the YUV color space, the electronic device can extract the luminance component from the first image to obtain an image corresponding to the luminance component of the first image, i.e., a first luminance image. In other words, the first luminance image only includes the luminance component of the first image.
[0187] For example, when the image to be processed is Figure 6 When processing the image shown in Figure (a), the first brightness image can be... Figure 6(b) shows the first brightness image.
[0188] In step S505, the chromaticity components of the first image are extracted to obtain the first chromaticity image.
[0189] After obtaining the first image in the YUV color space, the electronic device can extract the chromaticity components of the first image to obtain the image corresponding to the chromaticity components in the first image, i.e., the first chromaticity image. In other words, the first chromaticity image only includes the chromaticity components in the first image.
[0190] The execution order of steps S504 and S505 by the electronic device is not specifically limited. For example, the electronic device may execute step S504 first and then step S505. Or, the electronic device may execute step S505 first and then step S504.
[0191] The above technical solution involves the electronic device segmenting the first image in the YUV color space into a luminance image (first luminance image) and a chrominance image (first chrominance image) in the YUV color space. This allows the electronic device to independently add the desired film effects to the luminance image (first luminance image) in the YUV color space during subsequent image processing, avoiding interference with the chrominance information of the chrominance image (first chrominance image). This method makes the color quality of the resulting film image after processing closer to the color quality of the original image, and also makes the film effect of the resulting film image closer to the film effect of a real film image, thereby improving the color quality and image texture of the film image and better meeting the user's visual needs.
[0192] In step S506, the electronic device adjusts the film grain weight of the first brightness image based on the brightness of the first brightness image, or based on the brightness of the first brightness image and region #2 in the first brightness image, to obtain a brightness image with the first superimposed film grain weight.
[0193] For example, when the image to be processed is Figure 6 The image to be processed shown in (a) is the first brightness image. Figure 6 When the first brightness image is shown in (b) above, the brightness image with the first superimposed film grain weight can be... Figure 6 (c) shows the brightness image with the first superimposed film grain weight.
[0194] The electronic device executes step S506, which involves setting different film grain weights for different brightness regions included in the first brightness image based on the brightness of the first brightness image, or based on the brightness of the first brightness image and region #2. The film grain weights corresponding to different brightness regions can be different. In other words, the electronic device can execute step S506 in two ways, which will be described in detail below (i.e., implementation method one and implementation method two below).
[0195] Implementation Method 1
[0196] In implementation method one, the electronic device performs the above step S506, that is, the electronic device adjusts the film grain weight of the first brightness image according to the brightness of the first brightness image to obtain a brightness image with the first superimposed film grain weight.
[0197] In implementation method one, the first brightness image with superimposed film grain weights is an image obtained by setting different film grain weights on different brightness regions included in the first brightness image, and there is a mapping relationship between the brightness regions and the film grain weights. That is, in implementation method one, different brightness regions in the first brightness image with superimposed film grain weights have different film grain weights. Therefore, the brightness image with superimposed film grain weights (i.e., the first brightness image with superimposed film grain weights) can accurately reflect the brightness values of the first brightness image and can reflect the film grain weights corresponding to different brightness regions.
[0198] In implementation method one, different brightness regions included in the first brightness image can correspond to different film grain weights. The bright regions (i.e., regions with brightness greater than a preset brightness value) in the first brightness image have smaller film grain weight values (corresponding to smaller grain size), while the dark regions (i.e., regions with brightness less than or equal to a preset brightness value) in the first brightness image have larger film grain weight values (corresponding to larger grain size). Based on this setting, the film effect of the first film image obtained after image processing can better match the film effect of a real film image, which can improve the image quality and thus better meet the user's visual needs.
[0199] The first brightness image may include different brightness regions, and the method of dividing the first brightness image into brightness regions to obtain different brightness regions is not specifically limited.
[0200] For example, the electronic device can divide the first brightness image into Q brightness regions according to a preset black and white scale, where each of the Q brightness regions corresponds to a specific brightness level, and Q is a positive integer greater than 1. For instance, the Q brightness regions obtained by the electronic device from dividing the first brightness image could be... Figure 7The brightness region shown includes 5 regions (i.e., Q equals 5), with the brightness of these 5 regions gradually increasing: the darkest region (darkest), dark region, intermediate region, bright region, and brightest region (brightest). The different brightness regions included in the first brightness image can correspond to different film grain weights; that is, there is a mapping relationship between brightness regions and film grain weights. The mapping relationship between brightness regions and film grain weights is not specifically limited, nor is the division of brightness regions specifically limited; it can be set according to the actual situation.
[0201] For example, when the brightness value of a region included in the first brightness image is 255 (i.e., the brightest white region in the image), the film grain weight corresponding to that region can be 0.1; when the brightness value of a region included in the first brightness image is 128 (i.e., the neutral gray region in the image), the film grain weight corresponding to that region can be 0.5; when the brightness of a region included in the first brightness image is 10 (i.e., the dark region in the image), the film grain weight corresponding to that region can be 0.9.
[0202] In the first implementation method, the electronic device employs the aforementioned technical solution: by assigning different film grain weights to different brightness regions within the brightness image (i.e., the first brightness image) extracted from the image to be processed, the electronic device obtains a brightness image superimposed with different film grain weights (i.e., a first brightness image with superimposed film grain weights). Subsequently, the electronic device uses these brightness images with different superimposed film grain weights to obtain a final grain-superimposed film image (i.e., the first film image). This method allows different brightness regions in the grain-superimposed film image to exhibit different grain sizes. Therefore, the grain size of the film image (i.e., the first film image) obtained using this method more closely matches the grain size of a real film image, improving image quality and better meeting user visual needs. It should be understood that in the first implementation method, the electronic device does not set the same film grain weight for all brightness areas of the image to be processed. This avoids the problem that different brightness areas of the final film image (i.e., the first film image) have the same grain size, thus effectively solving the problem that the grain size of the final film image does not match the grain size of the real film image. This is beneficial to improving the image quality and enhancing the user's visual experience.
[0203] Implementation Method Two
[0204] In the second implementation method, the electronic device performs the above step S506, that is, the electronic device adjusts the film grain weight of the first brightness image according to the brightness of the first brightness image and region #2 in the first brightness image to obtain a brightness image with the first superimposed film grain weight.
[0205] Region #2 is a region located in the first brightness image. Region #2 is the region obtained by extracting the brightness component from region #1, which is included in the image to be processed. The position of region #1 in the image to be processed is the same as the position of region #2 in the first brightness image. Region #1 is also called the region of interest to the user. Region #1 can be a preset region and can be set according to actual needs. There are no specific limitations on region #1.
[0206] For example, when the image to be processed includes a face region, region #1 can be the face region in the image to be processed. Therefore, region #2 can be the brightness region in the first brightness image corresponding to the face region in the image to be processed.
[0207] For example, when the image to be processed includes two different colored flowers (the brightness of the areas where the two different colored flowers are located is different), region #1 can be a region of a flower of a certain color in the image to be processed. Therefore, region #2 can be the brightness region in the first brightness image corresponding to the region of a flower of a certain color in the image to be processed.
[0208] For example, when the image to be processed includes a face region and a plant region, region #1 can be the plant region in the image to be processed. Therefore, region #2 can be the brightness region in the first brightness image corresponding to the plant region in the image to be processed.
[0209] Optionally, before performing step S506, the electronic device may also perform a step of determining the position of region #2 in the first brightness image. The implementation method of the electronic device performing the step of determining the position of region #2 is not specifically limited. For example, determining the position of region #2 in the first brightness image may include the following steps: the electronic device performs semantic segmentation processing on the image to be processed to obtain region #1; the electronic device determines the position of region #2 in the first brightness image based on the position of region #1 in the image to be processed.
[0210] In the second implementation, the electronic device can divide the first brightness image into Q brightness regions, where each of the Q brightness regions corresponds to a brightness of Q, and the brightness of each brightness region is the corresponding brightness. Region #2 in the first brightness image can include at least a portion of the brightness region of each of the P brightness regions among the Q brightness regions, where Q is a positive integer and P is a positive integer not exceeding Q (i.e., P is a positive integer less than or equal to Q).
[0211] In one example, region #2 includes all the brightness regions of each of the P brightness regions out of the Q brightness regions. In this method, the film grain weight corresponding to each brightness region in the P brightness regions is the product of the preset film grain weight corresponding to that brightness region and the preset film grain weight corresponding to region #2. The film grain weight corresponding to any brightness region in the Q brightness regions other than the P brightness regions is the preset film grain weight corresponding to the brightness of that particular brightness region.
[0212] For example, taking region #2 as an example, with a preset film grain weight of 0.5, and region #2 including all the brightness regions of 1 out of 4 (Q equals 4) brightness regions (P equals 1) in the first brightness image, Figure 8 The brightness image shown in (a) is a specific example of the first brightness image described above. Figure 8 The four brightness regions shown in (a) are a specific example of the aforementioned Q brightness regions. Figure 8 The region #2 shown in (a) is a specific example of the aforementioned region #2. It can be seen that... Figure 8 The area shown in (a) is #2. Figure 8 (a) shows the brightness regions among the four brightness regions. When Figure 8 When the preset film grain weights for the darkest region, the darkest region, the middle region, and the brightest region shown in (a) are 0.9, 0.7, 0.5, and 0.2 respectively, the film grain weights for the darkest region, the darkest region, the middle region, and the brightest region are 0.9, 0.7, 0.5, and 0.1 respectively (i.e., the product of 0.2 and 0.5).
[0213] In another example, region #2 includes a portion of each of the P brightness regions out of the Q brightness regions. In this approach, the film grain weight corresponding to a portion of each brightness region in the P brightness regions is the product of the preset film grain weight corresponding to that brightness region and the preset film grain weight corresponding to region #2. The film grain weight corresponding to the region within each brightness region excluding that portion is the preset film grain weight corresponding to that brightness region. The film grain weight corresponding to any brightness region in the Q brightness regions excluding the P brightness regions is the preset film grain weight corresponding to the brightness of that arbitrary brightness region.
[0214] For example, taking region #2 as an example, with a preset film grain weight of 0.5, and region #2 being a portion of one (P equals 1) of the four (Q equals 4) brightness regions in the first brightness image, Figure 8 The brightness image shown in (b) is a specific example of the first brightness image described above. Figure 8 The four brightness regions shown in (b) are a specific example of the aforementioned Q brightness regions. Figure 8 (b) shows region #2 as a specific example of the aforementioned region #2, which can be seen that Figure 8 (b) shows area #2 as Figure 8 (b) shows a portion of the brightness region. When Figure 8 When the preset film grain weights for the darkest region, the darkest region, the middle region, and the brightest region shown in (a) are 0.9, 0.7, 0.5, and 0.2 respectively, the film grain weights for the darkest region, the darkest region, the middle region, region #2 in the brightest region, and the regions in the brightest region excluding region #2 are 0.9, 0.7, 0.5, 0.1 (i.e., the product of 0.2 and 0.5) and 0.2 respectively.
[0215] For example, taking region #2 as an example, with a preset film grain weight of 0.5, and region #2 being a partial area of 2 out of 4 (K equals 4) brightness regions (P equals 2) in the first brightness image, Figure 8 The brightness image shown in (c) is a specific example of the first brightness image described above. Figure 8 The four brightness regions shown in (c) are a specific example of the aforementioned Q brightness regions. Figure 8 The region #2 shown in (c) is a specific example of the aforementioned region #2. It can be seen that... Figure 8 Area #2 shown in (c) includes Figure 8 (c) shows a portion of the intermediate region (denoted as region A) and a portion of the brightness region (denoted as region B). When Figure 8When the preset film grain weights for the darkest region, the darkest region, the middle region, and the brightest region shown in (a) are 0.9, 0.7, 0.5, and 0.2 respectively, the film grain weights for the darkest region, the darkest region, region A in region #2, the middle region excluding region A, region B in region #2, and the brightest region excluding region B are 0.9, 0.7, 0.25 (i.e., the product of 0.5 and 0.5), 0.5, 0.1 (i.e., the product of 0.5 and 0.2), and 0.2 respectively.
[0216] The method by which the electronic device adjusts the film grain weight of the first brightness image based on the brightness of the first brightness image and region #2 in the second implementation described above to obtain a brightness image with the first superimposed film grain weight is not specifically limited.
[0217] For example, the electronic device adjusts the film grain weight of the first brightness image based on the brightness of the first brightness image and region #2 to obtain a brightness image with first superimposed film grain weight. This can include the following steps: the electronic device determines the film grain weight corresponding to each brightness region in the different brightness regions included in the first brightness image based on the brightness of the first brightness image; the electronic device adjusts the film grain weight of the first brightness image based on the film grain weight corresponding to each brightness region in the different brightness regions included in the first brightness image to obtain a brightness image with third superimposed film grain; the electronic device determines the film grain weight of region #2; the electronic device adjusts the film grain weight of the corresponding region in the brightness image with third superimposed film grain based on the film grain weight of region #2 to obtain a brightness image with first superimposed film grain weight, wherein the film grain weight corresponding to the region #2 in the brightness image with third superimposed film grain is different from the film grain weight of the corresponding region in the brightness image with first superimposed film grain weight.
[0218] The film grain weight of region #2 can be a preset film grain weight. There are no specific limitations on the preset film grain weight. It can be set according to the shooting objects included in region #2.
[0219] The method by which the electronic device determines the film grain weight corresponding to each brightness region among the different brightness regions included in the first brightness image is the same as the method described in Implementation Method 1 above for determining the film grain weight corresponding to any brightness region other than the P brightness regions among the Q brightness regions. For details not elaborated here, please refer to the relevant description above.
[0220] The electronic device adjusts the film grain weight of the corresponding region in the brightness image of the third superimposed film grain according to the film grain weight corresponding to region #2. That is, the electronic device multiplies the film grain weight of the corresponding region in the brightness image of the third superimposed film grain by the film grain weight corresponding to region #2.
[0221] It should be understood that the brightness image of the third superimposed film grain in the above example is the same as the brightness image of the second superimposed film grain weight in the first implementation method described above. Details not elaborated here can be found in the relevant description in the first implementation method described above. The film grain weight corresponding to region #2 in the brightness image of the first superimposed film grain weight in the above example is different from the film grain weight corresponding to region #2 in the brightness image of the first superimposed film grain weight in the first implementation method described above.
[0222] For example, the electronic device adjusts the film grain weight of the first brightness image based on the brightness of the first brightness image and region #2 to obtain a brightness image with a first superimposed film grain weight. This may include the following steps: the electronic device determines the film grain weight corresponding to each brightness region in the different brightness regions included in the first brightness image based on the brightness of the first brightness image and region #2 in the first brightness image; the electronic device adjusts the film grain weight of the first brightness image based on the film grain weight corresponding to each brightness region in the different brightness regions included in the first brightness image to obtain a brightness image with a first superimposed film grain weight.
[0223] Each brightness region in the first brightness image in the above example can be each of the P brightness regions among the Q brightness regions described above, or it can be any brightness region other than the P brightness regions among the Q brightness regions described above. There is no specific limitation on this. For details not elaborated here, please refer to the relevant descriptions above.
[0224] It should be understood that the film grain weight corresponding to region #2 in the brightness image of the first superimposed film grain weight in the above example is different from the film grain weight corresponding to region #2 in the brightness image of the first superimposed film grain weight in the above implementation method one.
[0225] In the second implementation method, the electronic device adopts the above technical solution, that is, the electronic device sets different film grain weights for the first brightness image extracted from the image to be processed, including region #2 and different brightness regions, to obtain a brightness image superimposed with different film grain weights (i.e., the first brightness image with superimposed film grain weights). Subsequently, the electronic device obtains a final film image with film grain (i.e., the first film image) by superimposing brightness images with different film grain weights. Based on this setting, different brightness areas in the film image with film grain (i.e., the first film image below) can present grains of different sizes. At the same time, the grain weight of region #2 and the grain weight of the brighter highlight areas in the film image with film grain are both small (corresponding to smaller grain size), and the grain weight of the darker dark areas in the film image with film grain is large (corresponding to larger grain size). In this way, it can avoid different brightness areas in the film image with film grain having grains of the same size, thereby effectively solving the problem that the grain size of the final film image obtained by image processing does not match the grain size of the real film image, which is conducive to improving the image quality and enhancing the user's visual experience. For example, taking region #2 as the face region, the electronic device can use the image processing method provided by the above-mentioned implementation method 2 to reduce the grain weight of the face skin region and highlight region in the image to be processed. At the same time, it can also increase the grain weight of the background region, which is the dark region in the image to be processed, so that the grain of the face skin region and highlight region in the final first film image is more delicate (smaller grain), and the grain of the background dark region and other regions in the first film image is more coarse (larger grain).
[0226] In step S507, the electronic device normalizes and filters the brightness image of the first superimposed film grain weight to obtain the brightness image of the second superimposed film grain weight, and obtains the film grain weight corresponding to different brightness regions in the brightness image of the second superimposed film grain weight based on the brightness image of the second superimposed film grain weight.
[0227] For example, when the image to be processed is Figure 6 The image to be processed shown in (a) is the first brightness image. Figure 6 The first brightness image shown in (b) can be a first brightness image with film grain weighting. Figure 6 When the brightness image with the first superimposed film grain weight is shown in (c), the brightness image with the second superimposed film grain weight can be... Figure 6 (d) shows the brightness image with the second overlay film grain weight.
[0228] The electronic device normalizes the brightness image of the first superimposed film grain weight, which can successfully scale the film grain weight in the brightness image of the first superimposed film grain weight to the range of [0, 1], thereby reducing the impact of computational load, feature and distribution differences.
[0229] The electronic device filters the brightness image of the first superimposed film grain weight, which can solve the problem of excessive differences in film grain weight at the intersection of different brightness regions in the brightness image of the first superimposed film grain weight. This makes the change of film grain weight value at the intersection of different brightness regions more average, avoids the abrupt change in the shape of film grain, and is more consistent with the shape of grain in real film images.
[0230] For example, the electronic device can first normalize the brightness image with the first superimposed film grain weight to obtain a normalized image, and then the electronic device can filter the normalized image to obtain a brightness image with the second superimposed film grain weight.
[0231] Since different brightness regions in the brightness image of the second superimposed film grain weight contain film grain weights, the electronic device can obtain the film grain weights corresponding to different brightness regions in the brightness image of the second superimposed film grain weight based on the brightness image of the second superimposed film grain weight.
[0232] In step S508, the electronic device acquires a first film grain image, wherein the size of the first film grain image is different from the size of the image to be processed.
[0233] The first film grain image is an image with a grainy morphology, and the grain morphology included in the first film grain image can be uniformly distributed within the first film grain image. It should be understood that the grain morphology of the first film grain image is closer to the grain morphology of the real film image; that is, the difference in grain morphology between the first film grain image and the real film image is very small and can be ignored.
[0234] The shape of the grains included in the first film grain image is not specifically limited. For example, the shape of the grains included in the first film grain image may be, but is not limited to, at least one of the following: circular, triangular, rectangular, pentagonal, hexagonal, thin line, etc.
[0235] The method for acquiring the first film grain image by the electronic device is not specifically limited. Below, three methods (method one, method two, and method three hereinafter referred to as method three) for acquiring the first film grain image by the electronic device provided in the embodiments of this application are introduced.
[0236] Method 1
[0237] In method one, the process by which the electronic device performs step S508 described above may include... Figure 9 Steps S508-1a and S508-2a are shown. Steps S508-1a and S508-2a are described below.
[0238] In step S508-1a, the electronic device generates various film grain images.
[0239] Multiple film grain images correspond to multiple different grain morphologies, wherein each film grain image can have at least one grain morphology.
[0240] For example, various film grain images may include Figure 10 (a) to Figure 10 The image shown in (h) contains eight types of film grain.
[0241] The method for generating each type of film grain image by an electronic device can be the same. For example, generating a film grain image by an electronic device may include the following steps: the electronic device acquires a film image, wherein the film image is a film image obtained by a film camera capturing a gray area with a preset percentage (e.g., 18%); if the local film grain distribution in the film image is uneven, the electronic device uses drawing software (e.g., Photoshop) to optimize the local film grain in the film image to generate a film grain image; if the film grain distribution in the film image is uniform, the electronic device uses the film image as the film grain image to generate a film grain image.
[0242] Film cameras do not have specific limitations on the shooting mode when shooting areas with a preset percentage (e.g., 18%) of gray area. The background color of the resulting film image may differ depending on the shooting mode. Figure 10 (a) to Figure 10 The eight types of film grain images shown in (h) have different grain shapes, and the background colors of the different film grain images also differ.
[0243] By employing the aforementioned technical solution, the electronic device captures an image of the 18% gray area (central gray area) of the film camera to obtain a film grain image, or optimizes a localized portion of the film grain in the 18% gray area captured by the film camera, using the optimized film image as the film grain image. This results in the grain morphology in the obtained film grain image being closer to the grain morphology in the real film image. This method effectively avoids the problem in traditional techniques where the grain morphology extracted from RAW images does not match the grain morphology in the real film image.
[0244] In step S508-2a, the electronic device randomly selects one film grain image from a variety of film grain images as the first film grain image, thereby obtaining the first film grain image.
[0245] The electronic device can randomly select different film grain images from a variety of film grain images each time. Therefore, the grain shape of the first film grain image obtained by the electronic device each time is random (not fixed), which is closer to the grain shape of the film image obtained by a real film camera.
[0246] For example, using various film grain images as... Figure 10 (a) to Figure 10 Taking the eight types of film grain images shown in (h) as an example, the first film grain image can be (a) to (h) in 10. Figure 10 (h) shows the morphology of any one of the eight types of film grain images.
[0247] For example, the first film grain image can be Figure 11 Image 1 of film grain shown in (a) Figure 11 Image 2 of film grain shown in (b) Figure 11 Image 3 of film grain shown in (c) Figure 11 (a) to Figure 11 The image to be processed shown in (c) can be the same image or different images. Figure 11 (a) to Figure 11 If the images to be processed shown in (c) are the same image, then the electronic device can overlay film grain images with different grain morphologies onto the same image. Figure 11 (a) to Figure 11 If the images to be processed shown in (c) are all different, then the electronic device will overlay film grain images with different grain morphologies onto the different images to be processed.
[0248] In the above-mentioned method one scheme of electronic device, electronic device needs to pre-store a variety of film grain images. Then, electronic device can randomly select one film grain image from the pre-stored variety of film grain images as the first film grain image. This acquisition method is relatively simple. This method not only ensures that the shape of the grain in the obtained first film grain image is closer to the shape of the grain in the film image taken by the real film camera, but also helps to improve the image processing efficiency.
[0249] Method 2
[0250] In method two, the process by which the electronic device performs step S508 may include... Figure 12 Steps S508-1b and S508-2b are shown. Steps S508-1b and S508-2b will be described below.
[0251] In step S508-1b, the electronic device generates a film grain image.
[0252] The method by which the electronic device performs step S508-1b is the same as the method by which the electronic device generates each type of film grain image in step S508-1a of the above method one. For details not described in detail here, please refer to the relevant description in step S508-1a above.
[0253] In step S508-2b, the electronic device performs rotation processing on a film grain image to obtain a first film grain image.
[0254] In Method 2, there is a certain angle between the central axis of the first film grain image and the central axis of one of the film grain images in step S508-1b. The size of this angle is not specifically limited. For example, the angle can be any angle in the range of [0°, 360°].
[0255] For example, Figure 13 (a) shows the overlap between the central axis of the image to be processed and the central axis of the film grain image. This film grain image can be a specific example of a film grain image from step S508-1b above. After rotating this film grain image, the resulting first film grain image can be... Figure 13 The first film grain image shown in (b) is either Figure 13 Image (c) shows the first film grain image, which is visible in the image. Figure 13 (b) or Figure 13 In (c), it is shown that there is an angle between the central axis of the first film grain image and the central axis of the overlapping film grain image (i.e., the central axis of the image to be processed).
[0256] The procedure for performing step S508-2b on electronic devices is not specifically limited.
[0257] For example, an electronic device may perform rotation processing on a film grain image to obtain a first film grain image, which may include the following steps: the electronic device performs rotation processing on a film grain image at a random angle to obtain the first film grain image.
[0258] For example, an electronic device performs rotation processing on a film grain image to obtain a first film grain image, which may include the following steps: the electronic device performs rotation processing on the film grain image multiple times to obtain multiple film grain images, with each rotation processing corresponding to a different rotation angle; the electronic device randomly selects one film grain image from the multiple film grain images as the first film grain image to obtain the first film grain image.
[0259] In the electronic device employing Method Two, the device only needs to rotate the acquired film grain image at least once to obtain a first film grain image with random grain morphology. Based on this method, the grain morphology of the obtained first film grain image is closer to that of the grain morphology in film images captured by a real film camera. Compared to Method One, Method Two eliminates the need for the electronic device to pre-store a large number of different types of film grain images, thus saving storage space.
[0260] Method 3
[0261] In method three, the process by which the electronic device performs step S508 described above may include... Figure 14 Steps S508-1c to S508-3c are shown. Steps S508-1c to S508-3c are described below.
[0262] In step S508-1c, the electronic device generates the first rotation sequence of film grain data.
[0263] For example, generating first rotational sequence film grain data by an electronic device may include the following steps: the electronic device takes a film grain image of a specific two-dimensional form and makes it into a first rotational sequence film grain data of a hollow cylinder with a three-dimensional form, wherein the data on the surface of the hollow cylinder with a three-dimensional form is the first rotational sequence film grain data.
[0264] For example, generating first rotation sequence film grain data by an electronic device may include the following steps: the electronic device sequentially stitches together multiple film grain images to obtain a stitched film grain image; the electronic device creates first rotation sequence film grain data in the form of a hollow cylinder with a three-dimensional shape based on the stitched film grain image with a two-dimensional shape, wherein the data on the surface of the hollow cylinder with a three-dimensional shape is the first rotation sequence film grain data.
[0265] For example, the first rotation sequence film grain data can be Figure 15 (a) shows the data contained on the surface of a hollow cylinder with a three-dimensional shape.
[0266] In step S508-2c, the electronic device performs rotation processing on the first rotation sequence film grain data to obtain the second rotation sequence film grain data.
[0267] The electronic device can rotate the first rotation sequence film grain data at a random angle to obtain the second rotation sequence film grain data. For example, the random angle can be any angle within the range of [0°, 360°].
[0268] For example, when the first rotation sequence film grain data is Figure 15 When the data contained on the surface of the hollow cylinder shown in (a) are considered, the second rotation sequence film grain data can be... Figure 15 (a) shows the data contained on the surface of the hollow cylinder, i.e., the random angle is 0°.
[0269] For example, when the first rotation sequence film grain data is Figure 15 When the data contained on the surface of the hollow cylinder shown in (a) are presented, the second rotation sequence film grain data is... Figure 15 (b) shows the data contained on the surface of the hollow cylinder, i.e., random angles greater than 0°.
[0270] In step S508-3c, the electronic device performs random cropping processing on the second rotation sequence film grain data to obtain the first film grain image.
[0271] The size of the first film grain image is not specifically limited; that is, the size of the first film grain image can be any size.
[0272] For example, when the first rotation sequence film grain data is Figure 15 When the data contained on the surface of the hollow cylinder shown in (a) are considered, the second rotation sequence film grain data can be... Figure 15 The data contained on the surface of the hollow cylinder shown in (a) are such that, with a random angle of 0°, the first film grain image can be... Figure 15 Image (a) shows the first film grain image.
[0273] For example, when the first rotation sequence film grain data is Figure 15 When the data contained on the surface of the hollow cylinder shown in (a) are presented, the second rotation sequence film grain data is... Figure 15 The data contained on the surface of the hollow cylinder shown in (b) are random angles greater than 0°. The first film grain image can be... Figure 15 (b) shows the first film grain image.
[0274] In the electronic device employing Method 3 described above, the electronic device generates a rotating grain layer data based on at least one film grain image. Then, the electronic device randomly rotates this rotating grain layer data in any direction (e.g., horizontally or laterally) to obtain a new rotating grain layer data. Finally, the electronic device randomly crops from the new rotating grain layer data to obtain a first film grain image. Based on this method, the resulting first film grain image has a grain morphology that more closely resembles the grain morphology of film images captured by a real film camera.
[0275] In practical applications, the grain morphology of any two film images obtained from multiple film images of the same scene will be different. Based on the methods for obtaining the first film grain image provided in the embodiments of this application, the grain morphology of the first film grain image obtained by the electronic device each time is random, that is, the grain morphology of multiple first film grain images obtained by the electronic device is highly likely to be different.
[0276] In step S509, the electronic device performs cropping or enlargement processing on the first film grain image to obtain a second film grain image. The size of the second film grain image is the same as the size of the image to be processed.
[0277] For example, the process by which the electronic device performs step S509 can be found in [reference needed]. Figure 16 Steps S509-1 to S509-3 are shown below. Steps S509-1 to S509-3 will now be described in detail.
[0278] In step S509-1, the electronic device determines whether the size of the first film grain image is larger than the size of the image to be processed.
[0279] After the electronic device executes step S509-1, if it determines that the size of the first film grain image is not larger than the size of the image to be processed, the electronic device continues to execute step S509-2. It should be understood that "the size of the first film grain image is not larger than the size of the image to be processed" can mean that the size of the first film grain image is smaller than the size of the image to be processed, or it can mean that the size of the first film grain image is smaller than or equal to the size of the image to be processed.
[0280] After the electronic device performs step S509-1, if it is determined that the size of the first film grain image is larger than the size of the image to be processed, the electronic device continues to perform step S509-3.
[0281] In step S509-2, the electronic device expands the first film grain image according to the size of the image to be processed to obtain the second film grain image.
[0282] The electronic device executes step S509-2 above, that is, when the size of the first film grain image is not larger than the size of the image to be processed, the electronic device enlarges the first film grain image according to the size of the image to be processed to obtain a second film grain image. When the size of the first film grain image is equal to the size of the image to be processed, the electronic device enlarges the first film grain image according to the size of the image to be processed, and the resulting second film grain image is the first film grain image. For example... Figure 17 Image (a) shown in the figure is the image to be processed. Figure 17 (b) shows the first film grain image. Figure 17 The second film grain image is shown in (c). When the size of the first film grain image is smaller than the size of the image to be processed, the electronic device enlarges the first film grain image according to the size of the image to be processed. The resulting second film grain image is different from the first film grain image, for example... Figure 17 Image (d) in the figure shows the image to be processed. Figure 17 (e) shows the first film grain image. Figure 17 The second film grain image shown in (f) is... Figure 17 The second film grain image shown in (f) is obtained using... Figure 17 The randomly selected region pair shown in (e) Figure 17 The first film grain image shown in (e) is obtained by augmentation (filling).
[0283] In step S509-3, the electronic device performs cropping processing on the first film grain image according to the size of the image to be processed, to obtain the second film grain image.
[0284] The electronic device performs step S509-3 above, that is, when the size of the first film grain image is larger than the size of the image to be processed, the electronic device crops the first film grain image according to the size of the image to be processed to obtain the second film grain image, for example. Figure 17 (g) shows the image to be processed. Figure 17 (h) shows the first film grain image. Figure 17 The second film grain image is shown in (i).
[0285] It should be noted that, in steps S508 and S509 above, taking the example that the size of the first film grain image is different from the size of the image to be processed, an electronic device is provided to construct a second film grain image with the same size as the image to be processed based on the size of the image to be processed. Optionally, in step S508 above, the size of the first film grain image is the same as the size of the image to be processed. In this implementation, the first film grain image is the second film grain image.
[0286] It should be understood that steps S501 to S507, as well as steps S508 and S509, are steps that the electronic device needs to perform before executing step S509. However, there is no specific limitation on the order in which the electronic device executes steps S501 to S507, and steps S508 and S509. For example, the electronic device can first execute steps S501 to S507 in sequence, and then execute steps S508 and S509 in sequence. Alternatively, the electronic device can first execute steps S508 and S509 in sequence, and then execute steps S501 to S507 in sequence.
[0287] In step S510, the electronic device obtains a first fused image based on the film grain weights corresponding to different brightness regions in the brightness image with second superimposed film grain weights, the second film grain image, and the first brightness image.
[0288] For example, when the image to be processed is Figure 6 The image to be processed shown in (a) is the first brightness image. Figure 6 The first brightness image shown in (b) is a brightness image with a first superimposed film grain weight. Figure 6 (c) shows the brightness image with the first superimposed film grain weight, and the brightness image with the second superimposed film grain weight is... Figure 6 When the brightness image with second film grain weighting is shown in (d) in the figure, the first fused image can be Figure 6 (e) shows the first fused image.
[0289] The electronic device executes the above step S510, that is, the electronic device obtains a first fused image based on the film grain weights corresponding to different brightness regions in the brightness image with second superimposed film grain weights, the second film grain image, and the first brightness image. For example, it may include the following steps: the electronic device obtains a third film grain image based on the film grain weights corresponding to different brightness regions in the brightness image with second superimposed film grain weights and the second film grain image, wherein the third film grain image is an image obtained by superimposing the film grain weights corresponding to different brightness regions in the brightness image with second superimposed film grain weights on different brightness regions in the second film grain image; the electronic device performs a fusion process on the third film grain image and the first brightness image to obtain the first fused image.
[0290] In the example above, the second film grain image is a grain image obtained from the first film grain image based on an 18% gray area. Therefore, during the process of obtaining the first fused image by the electronic device, the electronic device can use a preset algorithm to turn the gray area presented by the third film grain image into a transparent color. This allows the black and white grains in the third film grain image to be successfully superimposed onto the first fused image without affecting the chromaticity components of the first fused image. Subsequently, the grain shape of the first film image obtained by the electronic device based on the first fused image and the first chromaticity image is the same as the grain shape of the third film grain image, and the chromaticity of the first film image is not affected by the chromaticity of the third film grain image.
[0291] In step S511, the electronic device overlays the first chroma image and the first fused image to obtain the second film image.
[0292] The second film image includes the same subject as the image to be processed. The difference is that the second film image is an image with a film effect, while the image to be processed may be an image without a film effect, or the film effect included in the image to be processed may be different from that included in the second film image.
[0293] For example, when the image to be processed is Figure 6 The image to be processed shown in (a) is the first brightness image. Figure 6 The first brightness image shown in (b) can be a first brightness image with film grain weighting. Figure 6 (c) shows the brightness image with the first superimposed film grain weight, and the brightness image with the second superimposed film grain weight can be... Figure 6 Image (d) shows the brightness image with second overlay film grain weighting, where the first fused image is... Figure 6 When the first fused image is shown in (e) in the diagram, the second film image can be... Figure 6The second film image shown in (f) is shown in the figure.
[0294] In step S512, the electronic device performs format conversion processing on the second film image to obtain the first film image.
[0295] The electronic device performs the above step S512, that is, converts the second film image into the color format of the image to be processed, that is, the color format of the first film image and the color format of the image to be processed are the same.
[0296] For example, when the color format of the image to be processed is RGB and the color format of the second film image is YUV, the electronic device can perform format conversion processing on the second film image using the following formula to obtain a first film image with RGB color format:
[0297] R = Y + 1.4075 × (V - 128)
[0298] G=Y-0.3455×(U-128)-0.7169×(V-128)
[0299] B = Y + 1.779 × (U - 128)
[0300] In the above formula, Y represents the luminance component corresponding to the pixel in the second film image, U and V represent the chrominance components corresponding to the pixel in the second film image, R represents the red component corresponding to the pixel in the first film image, G represents the green component corresponding to the pixel in the first film image, and B represents the blue component corresponding to the pixel in the first film image.
[0301] It should be understood that the steps S503 to S512 described above can be steps performed by the electronic device in the background, i.e., not visible to the user.
[0302] In step S513, the electronic device displays or saves the first film image.
[0303] Optionally, when the electronic device is in preview mode, it can display the processed image. Examples of preview modes include: photo preview mode, night scene preview mode, large aperture preview mode, etc.
[0304] Optionally, when the electronic device is in photo mode, it can save the processed image; when the electronic device detects an action of clicking on an image in the gallery, it displays the processed image.
[0305] For example, with Figure 18 Taking the image to be processed, which includes a face region, shown in (a) as an example, it should be understood that the face region included in the image to be processed is not a real face region, i.e. Figure 18The image to be processed shown in (a) does not involve the disclosure of user privacy data. Figure 18 The image to be processed shown in (a) can be an image without a film effect. Based on traditional techniques, for Figure 18 Image processing of the image to be processed shown in (a) can produce an image with a film effect. Figure 18 The film image shown in (b) is as follows. It can be seen that... Figure 18 In the film image shown in (b), the grain morphology is the same across all regions (i.e., the entire image), and the grain size (grain size or coarseness) is the same across all regions. This means that the film image obtained using traditional techniques does not match the actual film quality, making it difficult to improve image texture and resulting in a poor user visual experience. Based on the image processing method provided in this application embodiment, for... Figure 18 Image processing of the image to be processed shown in (a) can produce an image with a film effect. Figure 18 The film image shown in (c) is as follows. It can be seen that... Figure 18 In (b) shown in the image, the grain morphology differs across all regions (i.e., the entire image), and the grain size (or coarseness) varies across different brightness areas. For example, Figure 18 In (c) shown in the film image, the cheekbone area of the face is a highlighted area, and the grains corresponding to this highlighted area are fine grains. Figure 18 In the film image shown in (c), the hair area is a dark area, and the grain in this dark area is high grain. Figure 18 In the film image shown in (c), the white shirt area is a bright area, and the grain corresponding to this bright area is medium to low grain. Therefore, the film effect (i.e., grain shape and grain size) of the first film image obtained based on the image processing method provided in this application embodiment is closer to the film effect of real film, which can improve the image texture and enhance the user's visual experience.
[0306] It should be understood that the above Figure 5 The image processing methods shown are for illustrative purposes only and do not constitute any limitation on the image processing methods provided in the embodiments of this application.
[0307] In this embodiment, the electronic device captures an image of the 18% gray area (central gray area) from a film camera to obtain a film grain image, or optimizes a localized film grain within the 18% gray area captured by the film camera to obtain a film image, using the optimized film image as the film grain image. Then, a first film grain image is obtained based on this film grain image, making the grain shape in the first film grain image closer to the grain shape in a real film image. This method effectively avoids the problem in traditional techniques where the grain shape extracted from RAW images does not match the grain shape in a real film image. Subsequently, the electronic device processes the image to be processed based on the first film grain image, making the grain shape of the first film image obtained from subsequent image processing even closer to the grain shape of a real film image, which helps improve the image quality of the first film image and better meets the user's visual needs. On one hand, the electronic device sets different film grain weights for different brightness regions included in the first brightness image extracted from the image to be processed, resulting in a brightness image superimposed with different film grain weights (i.e., a first brightness image with superimposed film grain weights). Subsequently, the electronic device uses these brightness images with different superimposed film grain weights to obtain a final first film image with grain, thus making different brightness regions in the grainy film image exhibit grains of different sizes (e.g., fine grains, medium-sized grains, or coarse grains). Therefore, the grain size of the first film image obtained by this method is closer to the grain size of a real film image, improving image quality and better meeting user visual needs. On the other hand, the electronic device sets different film grain weights for region #2 and different brightness regions included in the first brightness image extracted from the image to be processed, resulting in a brightness image superimposed with different film grain weights (i.e., a first brightness image with superimposed film grain weights). Subsequently, the electronic device obtains a final grainy film image (i.e., a first film image) based on brightness images superimposed with different film grain weights. This results in different brightness regions in the first film image exhibiting grain of different sizes. Simultaneously, region #2 and the brighter highlight regions in the first film image have smaller grain weights (corresponding to smaller grain sizes), while the darker, less bright regions in the first film image have extremely large grain weights (corresponding to larger grain sizes). This avoids the situation where different brightness regions in the resulting grainy film image all have grain of the same size. In summary, the image processing method provided by the embodiments of this application effectively solves the problem that the film effect (i.e., grain shape and grain size) of film images obtained based on traditional techniques does not match the film effect of real film images, which is beneficial for improving image quality and enhancing the user's visual experience.
[0308] Example 2
[0309] Figure 19 This is a schematic diagram of an image processing method provided in an embodiment of this application. It should be noted that in the first embodiment, the electronic device determines the film grain weight corresponding to each brightness region (or region #2) within the first brightness image (or different brightness regions and region #2) based on the different brightness regions included in the first brightness image obtained from the image to be processed. Different brightness regions can correspond to different film grain weights. In the second embodiment, the electronic device determines the film grain weight corresponding to each semantic region within the different semantic regions included in the semantic segmentation image obtained from the image to be processed. Different semantic regions can correspond to different film grain weights. The image processing method 1900 provided in this application embodiment can be... Figure 1 or Figure 3 The image processing method 1900 is executed by the electronic device shown; the image processing method includes steps S1901 to S1910, which are described in detail below.
[0310] In step S1901, the electronic device runs the camera application.
[0311] The electronic device performs the above-described step S1901 in the same way as the electronic device performs step S501 in the above-described embodiment. For details not described in detail here, please refer to the description in step S501 above.
[0312] In step S1902, the electronic device acquires the image to be processed.
[0313] The electronic device performs the above-described step S1902 in the same way as the electronic device performs step S502 in the above-described embodiment 1. For details not described in detail here, please refer to the description in step S502 above.
[0314] In step S1903, the electronic device performs semantic segmentation processing on the image to be processed to obtain a first semantic segmentation image. The first semantic segmentation image includes Q semantic regions, where Q is a positive integer greater than 1.
[0315] The electronic device performs the above step S1903, that is, the electronic device performs image segmentation processing on the image to be processed according to the semantic information included in the image to be processed, so as to obtain Q semantic regions corresponding to Q semantic information included in the image to be processed, wherein the Q semantic regions correspond to Q semantic information, and each semantic information is the semantic information included in the corresponding semantic region.
[0316] Q is a positive integer greater than 1. There is no specific restriction on the value of Q; it can be set according to the actual situation. For example, Q can be, but is not limited to, equal to 2, 3, 4, or 5, etc.
[0317] For example, the image to be processed is Figure 20 Taking the image to be processed shown in (a) as an example, the semantic information of the image to be processed can be... Figure 20 The semantic information shown in (b) indicates that the first semantic segmentation image can be... Figure 20 (c) shows the first semantic segmentation image, which includes two semantic regions (i.e., Q equals 2), namely the background region and the human figure region.
[0318] In step S1904, the electronic device adjusts the film grain weight of each of the Q semantic regions included in the first semantic segmentation image according to the preset mapping relationship between semantic information and film grain weight, to obtain a first semantic segmentation image with superimposed film grain weight. The first semantic segmentation image with superimposed film grain includes Q semantic regions with superimposed film grain weight, and different semantic regions correspond to different film grain weights.
[0319] The pre-defined mapping relationship between semantic information and film grain weights includes a one-to-one mapping between multiple semantic information pieces and multiple film grain weights. Each film grain weight is the film grain weight of the corresponding semantic information. There is no specific limitation on the film grain weight corresponding to each semantic information piece; the film grain weight corresponding to each semantic information piece can be determined based on the actual situation.
[0320] For example, if the semantic information is a highlight area on a face, the corresponding grain weight can be relatively small (e.g., 0.1 or 0.2). If the semantic information is a dark background area, the corresponding grain weight can be relatively large (e.g., 0.8 or 0.9). If the semantic information is a plant area, the corresponding grain weight can be moderate (e.g., 0.5). If the semantic information is a flower area, the corresponding grain weight can be relatively small (e.g., 0.2).
[0321] In step S1905, the electronic device normalizes and filters the semantic segmentation image with the first superimposed film grain weight to obtain the semantic segmentation image with the second superimposed film grain weight, and obtains the film grain weight corresponding to different semantic regions in the semantic segmentation image with the second superimposed film grain weight based on the semantic segmentation image with the second superimposed film grain weight.
[0322] The method of normalizing and filtering the semantic segmentation image with first-stacked film grain weights using electronic devices is similar to the method described above. Figure 5The method for normalizing and filtering the brightness image of the first superimposed film grain weight in step S507 of the provided image processing method is the same. For details not described here, please refer to the relevant description in step S507 above.
[0323] Since different semantic regions in the semantic segmentation image with second superimposed film grain weights contain film grain weights, the electronic device can obtain the film grain weights corresponding to different semantic regions in the semantic segmentation image with second superimposed film grain weights based on the semantic segmentation image with second superimposed film grain weights.
[0324] In step S1906, the electronic device acquires a first film grain image, wherein the size of the first film grain image is different from the size of the image to be processed.
[0325] The electronic device performs the above-described step S1906 in the same way as the electronic device performs step S508 in the above-described embodiment. For details not described in detail here, please refer to the description in step S508 above.
[0326] In step S1907, the electronic device performs a cropping or enlarging operation on the first film grain image to obtain a second film grain image. The size of the second film grain image is the same as the size of the image to be processed.
[0327] The electronic device performs the above-described step S1907 in the same way as the electronic device performs step S509 in the above-described embodiment. For details not described in detail here, please refer to the description in step S509 above.
[0328] It should be understood that steps S1901 to S1905, as well as steps S1906 and S1907, are steps that the electronic device needs to perform before executing step S509. However, there is no specific limitation on the order in which the electronic device executes steps S1901 to S1905, and steps S1906 and S1907. For example, the electronic device can first execute steps S1901 to S1905 in sequence, and then execute steps S1906 and S1907 in sequence. Alternatively, the electronic device can first execute steps S1906 and S1907 in sequence, and then execute steps S1901 to S1905 in sequence.
[0329] In step S1908, the electronic device performs fusion processing on the film grain weights corresponding to different semantic regions in the semantic segmentation image with second superimposed film grain weights, the second film grain image, and the image to be processed, to obtain the second film image.
[0330] The second film image contains the same subject as the image to be processed. The difference is that the second film image is an image with a grainy morphology, while the image to be processed can be an image without a grainy morphology, or the grain morphology in the image to be processed may be different from that in the second film image.
[0331] In step S1909, the electronic device performs format conversion processing on the second film image to obtain the first film image.
[0332] The electronic device performs the above-described step S1909 in the same way as the electronic device performs step S512 in the above-described embodiment. For details not described in detail here, please refer to the description in step S512 above.
[0333] It should be understood that in the embodiments of this application, the image to be processed, the first semantic segmentation image, the first semantic segmentation image with superimposed film grains, the second semantic segmentation image with superimposed film grains, the second film grain image, the second film image, and the first film image are all the same size.
[0334] In step S1910, the first film image is displayed or saved.
[0335] The electronic device performs the above-described step S1910 in the same way as the electronic device performs step S513 in the above-described embodiment 1. For details not described in detail here, please refer to the description in step S513 above.
[0336] It should be understood that the above Figure 19 The image processing methods shown are for illustrative purposes only and do not constitute any limitation on the image processing methods provided in the embodiments of this application.
[0337] In this embodiment, the electronic device captures an image of the 18% gray area (central gray area) from a film camera to obtain a film grain image, or optimizes a local film grain within the 18% gray area captured by the film camera to obtain a film image, using the optimized film image as the film grain image. Then, a first film grain image is obtained based on this film grain image, making the grain shape in the first film grain image closer to the grain shape in a real film image. This method effectively avoids the problem in traditional techniques where the grain shape extracted from RAW images does not match the grain shape in real film images. Furthermore, the electronic device sets different film grain weights on different semantic regions included in the first semantic segmentation image obtained by semantic segmentation of the image to be processed, resulting in a semantic segmentation image superimposed with different film grain weights (i.e., a first semantic segmentation image superimposed with film grain weights). Subsequently, the electronic device obtains a final grainy first film image based on semantic segmentation images superimposed with different film grain weights. This results in different semantic regions in the grainy film image exhibiting grains of different sizes (e.g., fine grains, medium-sized grains, or coarse grains), avoiding the situation where different semantic regions in film images obtained using traditional techniques all have grains of the same size. This improves image quality and better meets user visual needs. In summary, the image processing method provided by the embodiments of this application effectively solves the problem that the film effect (i.e., grain shape and grain size) of film images obtained using traditional techniques does not match the film effect of real film images (significant differences), thus improving image quality and enhancing the user visual experience.
[0338] Example 3
[0339] Figure 21 This is a schematic diagram of an image processing method provided in an embodiment of this application. The image processing method 2100 provided in this embodiment can be... Figure 1 or Figure 3 The image processing method 2100 is performed by the electronic device shown; the image processing method includes steps S2110 to S2140, which are described in detail below.
[0340] In step S2110, the electronic device acquires an image to be processed, wherein the image to be processed includes Q first regions, where Q is a positive integer greater than 1.
[0341] The image to be processed can be a digital image, meaning it can be an image without a film effect (i.e., the shape and size of the grains, also known as grain intensity, grain size, or grain coarseness). Therefore, the image processing method provided in this application can add a film effect to an image to be processed that does not have a film effect, thereby obtaining a film image with a film effect. The film effect of the film image obtained by this method is closer to that of a real film image, which can improve the image quality and better meet the user's visual needs.
[0342] Optionally, the image to be processed can also be a film image with a film effect. Therefore, the film effect added to the image to be processed by the image processing method provided in this application is different from the original film effect contained in the image to be processed. The film effect of the film image obtained by this method is closer to the film effect of the real film image, which can further improve the texture of the image and better meet the user's visual needs.
[0343] There are no specific limitations on the color format and file format of the image to be processed. That is, the image to be processed can be an image of any color format, which can be selected according to the actual application scenario. For example, the color format of the image to be processed can be, but is not limited to, any of the following: RGB format, YUV format, CMY format, or RAW format, etc. The image to be processed can be an image of any file format, which can be selected according to the actual application scenario. For example, the file format of the image to be processed can be, but is not limited to, any of the following: JPG format, BMP format, or PNG format, etc. For example, the image to be processed can be an RGB format JPG image, which refers to an image presented in RGB color mode and with a JPG file format.
[0344] The image to be processed can be a static image, a dynamic image, or any frame from a video, without specific limitations. For example, taking the image processing method provided in this application embodiment as an example applied to a mobile phone, the image to be processed can be a static image stored in the phone's photo album, a dynamic image obtained by the phone's camera in real time during the framing process, or any frame from a video.
[0345] The subjects included in the image to be processed are not specifically limited and can be set according to the user's shooting needs. For example, the subjects included in the image to be processed may include human faces. Alternatively, the subjects included in the image to be processed may include at least one of the following: human faces, flowers, trees, landscapes, and buildings. For example, the subjects included in the image to be processed may include flowers of various colors, such as yellow flowers and red flowers.
[0346] The image to be processed can be an image that includes Q first regions, where Q is a positive integer greater than 1. There is no specific limitation on the value of Q; for example, Q can be, but is not limited to, equal to 2, 3, 5, 6, 8, or 10.
[0347] The method by which an electronic device acquires an image to be processed is not specifically limited. In one example, the electronic device may acquire the image to be processed from another electronic device, wherein the image to be processed is an image captured by that other electronic device. In another example, the electronic device may acquire the image to be processed through a camera application running on the electronic device. Exemplarily, acquiring an image to be processed by an electronic device may include the following steps: the electronic device displays a first interface; the electronic device detects a first operation on a first control included in the first interface; and the electronic device acquires the image to be processed in response to the first operation.
[0348] Optionally, the first operation may be, but is not limited to, a single-click operation, a double-click operation, a series of clicks, etc.
[0349] Optionally, the first interface is the portrait mode photo-taking interface, and the first control is a control used to indicate taking the photo. For example, the first interface could be... Figure 23 The photo preview interface 2330 shown in (c) has a first control that can be... Figure 23 The shooting control 2331 is shown in (c) in the figure.
[0350] Optionally, the first interface is specifically the film mode shooting interface within portrait mode. For example, the first interface could be... Figure 22 The photo preview interface 2240 shown in (d) can have the first control as follows: Figure 22 The shooting control 2241 is shown in (d) in the figure.
[0351] Optionally, the first interface is the camera interface in photo mode, and the first control is a control used to instruct the user to take a photo.
[0352] For example, a specific example of the image to be processed in step S2110 above may be the one described above. Figure 5 The image to be processed in step S502 of the provided image processing method, or it may be the image mentioned above. Figure 19 The image to be processed in step S1902 of the provided image processing method, the details of which are not described in detail here, can be found in the relevant descriptions in step S502 or step S1902 above.
[0353] In step S2120, the electronic device acquires an initial film grain image, wherein the initial film grain image has uniformly distributed grains, and the initial film grain image includes Q second regions and Q first regions that correspond one-to-one. The position of each second region in the initial film grain image is the same as the position of the corresponding first region in the image to be processed.
[0354] An initial film grain image is an image with uniformly distributed grains; that is, an initial film grain image may include grains of one or more shapes (patterns), and the grains included in the initial film grain image are uniformly distributed within the initial film grain image. For example, the grains of one or more shapes (patterns) may include, but are not limited to, one or more shapes selected from circles, triangles, teardrop shapes, hexagons, and thin lines.
[0355] The initial film grain image includes Q second regions and Q first regions, each corresponding to a different region. The position of each second region in the initial film grain image is the same as the position of its corresponding first region in the image to be processed. It should be understood that the size of the initial film grain image and the size of the image to be processed are the same; however, the size of the image to be processed is not specifically limited and can be set according to the actual application scenario. It should also be understood that the size of each second region is the same as the size of its corresponding first region.
[0356] The method for acquiring initial film grain images by electronic devices is not specifically limited. Below, several methods for acquiring initial film grain images by electronic devices provided in embodiments of this application are described.
[0357] Method 1
[0358] In Method 1, the initial film grain image is either a film image obtained by taking a picture of a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image.
[0359] Optionally, the preset proportion of neutral gray area may be, but is not limited to, 18% neutral gray area.
[0360] The purpose of uniformly distributing grains in a film image is to ensure that the grains are evenly distributed throughout the film image.
[0361] In Method 1, the electronic device acquires an initial film grain image, which, exemplarily, may include the following steps: acquiring an initial film grain image from a film camera.
[0362] The electronic device employs Method 1, which involves not using the noise with a fixed shape obtained from noise extraction of the original RAW image as grain, but instead using a film image captured by a film camera at a preset proportion (18%) of the central gray area as the initial film grain image, or optimizing (uniformly distributing) the local film grain in the film image captured by a film camera at a preset proportion of the gray area, and using the optimized film image as the initial film grain image. In other words, the grain shape of the initial film grain image obtained is the same as that of the grain in a real film image. Furthermore, the electronic device obtains a first film image with a film effect based on the initial film grain image, making the grain shape of the first film image even closer to that of a real film image, thereby further improving image quality and enhancing the user's visual experience.
[0363] Method 2
[0364] In method two, the electronic device acquires an initial film grain image, which may include the following steps: acquiring at least one film grain image, wherein each of the at least one film grain image is a film image obtained by taking a picture of a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image; and obtaining an initial film grain image based on the at least one film grain image.
[0365] Optionally, in the above example, the electronic device obtains an initial film grain image based on at least one film grain image. For example, it may include the following steps: the electronic device randomly selects a film grain image from at least one film grain image to obtain the initial film grain image.
[0366] At least one film grain image may include one or more film grain images, and any two film grain images in the plurality of film grain images have different grain morphologies.
[0367] If the size of a randomly selected film grain image is the same as the size of the image to be processed, then the randomly selected film grain image is determined as the initial film grain image.
[0368] When the size of a randomly selected film grain image is larger than the size of the image to be processed, the electronic device can crop the randomly selected film grain image and determine the cropped film grain image as the initial film grain image.
[0369] When the size of a randomly selected film grain image is smaller than the size of the image to be processed, the electronic device can expand the randomly selected film grain image and determine the expanded film grain image as the initial film grain image.
[0370] For example, a specific example of the image to be processed in step S2110 above is given in the text above. Figure 5 Taking the image to be processed in step S502 of the provided image processing method as an example, a specific example of at least one film grain image can be multiple film grain images in step S508-1a above. A specific example of a randomly selected film grain image can be the first film grain image in step S508-2a above. A specific example of the initial film grain image can be the second film grain image in step S509 above. For details not elaborated here, please refer to the relevant descriptions in steps S508-1a, S508-2a and S509 above.
[0371] In the above-mentioned scheme for obtaining initial film grain images in electronic devices, the electronic devices need to pre-store one or more film grain images. Then, the electronic devices can obtain an initial film grain image based on a film grain image randomly selected from the one or more film grain images. This method is relatively simple. This method not only ensures that the grain shape of the obtained initial film grain image is closer to the grain shape of the film image taken by a real film camera, but also helps to improve image processing efficiency.
[0372] Optionally, in the above examples, at least one film grain image includes a first film grain image, wherein the angle between the central axis of the first film grain image and the central axis of the image to be processed is zero degrees; and, in the above examples, the electronic device obtains an initial film grain image based on at least one film grain image, which, exemplarily, may include the following steps: the electronic device rotates the first film grain image to obtain a rotated first film grain image, wherein the angle between the central axis of the rotated first film grain image and the central axis of the image to be processed is non-zero degrees; if the size of the rotated first film grain image is different from the size of the image to be processed, the electronic device performs cropping or expansion processing on the rotated first film grain image to obtain the initial film grain image; or, if the size of the rotated first film grain image is the same as the size of the image to be processed, the electronic device determines the rotated first film grain image as the initial film grain image to obtain the initial film grain image.
[0373] The angle between the central axis of the first type of film grain image after rotation and the central axis of the image to be processed is non-zero degrees, that is, there is a certain angle between the central axis of the first type of film grain image after rotation and the central axis of the image to be processed (e.g., 5°, 90°, 170°, etc.).
[0374] Optionally, if the size of the rotated first type of film grain image differs from the size of the image to be processed, the electronic device performs cropping or expansion processing on the rotated first type of film grain image to obtain an initial film grain image. This includes: if the size of the rotated first type of film grain image is larger than the size of the image to be processed, the electronic device performs cropping processing on the rotated first type of film grain image to obtain an initial film grain image; or, if the size of the rotated first type of film grain image is smaller than the size of the image to be processed, the electronic device performs expansion processing on the rotated first type of film grain image to obtain an initial film grain image.
[0375] For example, a specific example of the image to be processed in step S2110 above is given in the text above. Figure 5 Taking the image to be processed in step S502 of the provided image processing method as an example, a specific example of at least one film grain image can be a film grain image in step S508-1b above. A specific example of the first film grain image after rotation can be the first film grain image in step S508-2b above. A specific example of the initial film grain image can be the second film grain image in step S509 above. For details not elaborated here, please refer to the relevant descriptions in steps S508-1b, S508-2b and S509 above.
[0376] In the above-described scheme for acquiring an initial film grain image in an electronic device, since the grain morphology of each film grain image in at least one film grain image is closer to the grain morphology of a film image captured by a real film camera, the resulting initial film grain image also has a grain morphology that is closer to the grain morphology of a film image captured by a real film camera.
[0377] Optionally, in the above examples, at least one film grain image specifically includes a first type of film grain image with a two-dimensional morphology; and in the above examples, the electronic device obtains an initial film grain image based on at least one film grain image, which, exemplarily, may include the following steps: the electronic device generates a first rotating sequence film grain image with a three-dimensional hollow cylindrical morphology based on the first type of film grain image; the electronic device performs random cropping processing on a second rotating sequence film grain image with a three-dimensional hollow cylindrical morphology to obtain an initial film grain image with a two-dimensional morphology, wherein the second rotating sequence film grain image is the first rotating sequence film grain image, or is an image obtained by rotating the first rotating sequence film grain image.
[0378] For example, a specific example of the image to be processed in step S2110 above is given in the text above. Figure 5 Taking the image to be processed in step S502 of the provided image processing method as an example, a specific example of the first rotation sequence film grain image can be the first rotation sequence film grain data in step S508-1c above; a specific example of the second rotation sequence film grain image can be the second rotation sequence film grain data in step S508-2c above; and a specific example of the initial film grain image can be the second film grain image in step S509 above. Details not elaborated here can be found above. Figure 5 The relevant steps are described in the text.
[0379] In the above-described method for acquiring an initial film grain image using an electronic device, the electronic device generates a rotating sequence grain layer data based on at least one film grain image. Then, the electronic device performs a random rotation (e.g., horizontal or lateral) on this obtained rotating sequence grain layer data to obtain a new rotating sequence grain layer data. Finally, the electronic device randomly crops from the new rotating sequence grain layer data to obtain the initial film grain image. Based on this method, the resulting initial film grain image has a grain morphology that more closely resembles the grain morphology of film images captured by a real film camera.
[0380] In step S2130, the electronic device determines a set of particle weights, wherein the set of particle weights includes the particle weights of each first region, and the particle weights of different first regions are different.
[0381] The particle weight set includes the particle weight of each of the Q first regions. Different first regions have different particle weights, and the particle size (also known as strength, size, or coarseness) of particles with different particle weights is different.
[0382] The electronic device determines the set of particle weights, for example, by including the following steps: the electronic device determines Q first particle weights based on a first preset relationship and Q first regions, wherein the first preset relationship includes at least Q one-to-one correspondences between the Q first regions and the Q first particle weights; the electronic device determines the set of particle weights based on the Q first particle weights.
[0383] In the example above, the electronic device can determine the set of particle weights based on Q first particle weights in the following two ways, which are not limited to the following two methods.
[0384] Implementation Method 1
[0385] In implementation method one, the granular weight set includes Q first granular weights, where each of the Q first granular weights corresponds one-to-one with a Q first region; that is, the granular weight of each first region is the corresponding first granular weight. In other words, in implementation method one, each first region has one granular weight.
[0386] In implementation method one, there are two specific cases (i.e., case 1 and case 2). These two cases will be introduced separately below.
[0387] Case 1: There is a one-to-one correspondence between Q brightness ranges and Q first regions, where the brightness of each first region is the brightness within the corresponding brightness range, and different first regions correspond to different brightness ranges; there is a one-to-one correspondence between Q brightness ranges and Q first particle weights, where the particle weight of each first region is the first particle weight corresponding to the corresponding brightness range, and different brightness ranges correspond to different first particle weights.
[0388] Optionally, the first brightness range and the second brightness range are any two different brightness ranges among Q brightness ranges; the brightness of the first brightness range is higher than the brightness of the second brightness range, and the first particle weight corresponding to the first brightness range is less than the first particle weight corresponding to the second brightness range.
[0389] Each brightness range may include one or more different brightness levels, without being specifically limited to any one of them.
[0390] In Case 1 above, the particle weight of each first region in the image to be processed is specifically determined based on the brightness information (e.g., dark region, bright region, highlight region, etc.) of each first region.
[0391] For example, a specific example of the Q brightness ranges is as described above. Figure 5In the provided method, step S506 implements the first brightness image in method one, which includes Q brightness regions. A specific example of the Q first regions is the Q unprocessed regions in the image to be processed in step S502. The Q unprocessed regions correspond one-to-one with the Q brightness regions included in the first brightness image in method one in step S506. Each brightness region is obtained by extracting the brightness of the corresponding unprocessed region. A specific example of the Q first grain weights can include the film grain weight of each brightness region in the brightness image of the second superimposed film grain weight in step S507. For details not elaborated here, please refer to the relevant descriptions in steps S506 and S507 above.
[0392] By employing the aforementioned method, the electronic device sets a smaller grain weight for brighter first regions, meaning the grain size of brighter first regions needs to be adjusted to be smaller; conversely, it sets a larger grain weight for darker first regions, meaning the grain size of darker first regions needs to be adjusted to be larger. Based on this setting, the grain size in the first film image subsequently obtained by the electronic device based on the grain weight set is closer to the grain size in a real film image, which can improve image quality and enhance the user's visual experience.
[0393] Case 2: There is a one-to-one correspondence between Q first regions and Q semantic information. The semantic information of each first region is the corresponding semantic information, and different first regions correspond to different semantic information. There is also a one-to-one correspondence between Q semantic information and Q first particle weights. The particle weight of each first region is the first particle weight corresponding to the semantic information, and different semantic information corresponds to different first particle weights.
[0394] In scenario 2 above, the particle weight of each first region in the image to be processed is specifically determined based on the semantic information of each first region (e.g., facial skin, plants, buildings, black background, etc.).
[0395] For example, a specific example of the Q first regions is as described above. Figure 19 In the provided method, a specific example of the Q semantic regions and Q first grain weights in step S1903 may include the film grain weight of each of the Q semantic regions included in the semantic segmentation image of the second superimposed film grain weight in step S1905 above. For details not elaborated here, please refer to the relevant descriptions in steps S1903 and S1905 above.
[0396] The electronic device employs the aforementioned method, whereby it determines the grain weight set based solely on the Q semantic information corresponding to the Q first regions. Subsequently, the electronic device generates a first film image based on the image to be processed, the initial film grain image, and the grain weight set. This ensures that the grain size varies across regions with different semantic information within the first film image. This method avoids the final first film image having grain of the same size across different semantic regions, resulting in a film effect (i.e., grain size) that more closely resembles the grain size of a real film image. This improves image quality and enhances the user's visual experience.
[0397] Implementation Method Two
[0398] In implementation method two, there is a one-to-one correspondence between Q brightness ranges and Q first regions. The brightness of each first region is the brightness within the corresponding brightness range. Different first regions correspond to different brightness ranges. The electronic device determines a set of particle weights based on the Q first particle weights, including: the electronic device determining a second particle weight based on a second preset relationship and the semantic information of the target region in the image to be processed, wherein the second preset relationship includes at least the correspondence between semantic information and the second particle weight; the electronic device determining the particle weight of the region in the i-th first region that does not overlap with the target region, which is the particle weight of the i-th first region; and the electronic device determining the particle weight of the region in the i-th first region that overlaps with the target region, which is the product of the particle weight of the i-th first region and the second particle weight; wherein the i-th first region is any one of the Q first regions, there is a one-to-one correspondence between the Q brightness ranges and the Q first particle weights, and the particle weight of the i-th first region is the i-th first particle weight corresponding to the i-th brightness range, where i is a positive integer less than or equal to Q.
[0399] Optionally, the above-mentioned electronic device determines the particle weight of the region overlapping with the target region in the i-th first region, which is the product of the particle weight of the i-th first region and the second particle weight. Alternatively, the electronic device can determine the particle weight of the region overlapping with the target region in the i-th first region, which is the maximum particle weight between the particle weight of the i-th first region and the second particle weight.
[0400] i is a positive integer less than or equal to Q, that is, the value of i is 1, 2, ..., Q, that is, the i-th region is any one of the Q first regions.
[0401] When a portion of the i-th first region overlaps with the target region, the particle weight of the i-th first region includes the i-th first particle weight corresponding to the i-th brightness range, and the product of the i-th first particle weight and the second particle weight corresponding to the i-th brightness range. In this case, the i-th first region has two particle weights. When there is no overlap between the i-th first region and the target region, the particle weight of the i-th first region is the i-th first particle weight corresponding to the i-th brightness range. In this case, the i-th first region has one particle weight.
[0402] The target area is not specifically limited and can be set according to the actual situation. Optionally, the target area is a face area. Optionally, the target area is a non-face area, such as, but not limited to, background areas, plant areas, etc.
[0403] There is a correspondence between the second grain weight and the semantic information of the target region, and the second grain weight is not specifically limited. For example, when the target region is a facial skin region, that is, the semantic information of the target region is facial skin information, a smaller second grain weight can be set to make the grain size of the facial skin region in the first film image smaller or finer. Conversely, when the target region is a dark background region, that is, the semantic information of the target region is dark background region information, a larger second grain weight can be set to make the grain size of the dark background region in the first film image larger or coarser.
[0404] The granular weight of the region in the i-th first region that does not overlap with the target region is the granular weight of the i-th first region. There is no specific limitation on the region in the i-th first region that does not overlap with the target region. For example, the region in the i-th first region that does not overlap with the target region can be the i-th first region or at least a part of the region included in the i-th first region.
[0405] The granular weight of the region in the i-th first region that overlaps with the target region is the product of the granular weight of the i-th first region and the second granular weight. The region in the i-th first region that overlaps with the target region is not specifically limited. For example, the region in the i-th first region that overlaps with the target region can be the i-th first region or at least a portion of the region included in the i-th first region.
[0406] The target region overlaps with at least one of the Q first regions, meaning the target region is the overlapping region. When one of the Q first regions overlaps with the target region, that first region is the target region, or that first region includes the target region and regions other than the target region. When multiple of the Q first regions overlap with the target region, the target region and each of the multiple first regions at least partially overlap.
[0407] Optionally, the first brightness range and the second brightness range are any two different brightness ranges among Q brightness ranges; the brightness of the first brightness range is higher than the brightness of the second brightness range, and the first particle weight corresponding to the first brightness range is less than the first particle weight corresponding to the second brightness range.
[0408] The electronic device employs the aforementioned method, whereby it determines a grain weight set based on Q brightness ranges corresponding one-to-one with Q first regions included in the image to be processed, and semantic information of the target region included in the image to be processed. Subsequently, the electronic device generates a first film image based on the image to be processed, the initial film grain image, and the grain weight set. This first film image is designed such that the grain size differs in different brightness regions within the first film image, and that the grain size in regions within the same brightness region that overlap with the target region (overlapping regions) differs from the grain size in regions within the same brightness region that do not overlap with the target region (non-overlapping regions). This method avoids the final first film image having grain of the same size in all different brightness regions. Furthermore, it distinguishes between the grain size of overlapping and non-overlapping regions within the same brightness region, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thus improving image quality and enhancing the user's visual experience.
[0409] For example, a specific example of the Q brightness ranges is as described above. Figure 5In the provided method, step S506 of the second implementation includes Q brightness regions in the first brightness image. A specific example of the Q first regions is the Q unprocessed regions in the image to be processed in step S502. The Q unprocessed regions correspond one-to-one with the Q brightness regions in the first brightness image of the second implementation in step S506. Each brightness region is obtained by extracting the brightness of the corresponding unprocessed region. A specific example of the target region is region #1 in the second implementation in step S506. The grain weight of the i-th first region is the same as the grain weight of any one of the Q brightness regions in the first brightness image of the second implementation in step S506. A specific example of the second grain weight is the preset film grain weight corresponding to region #2 in the second implementation in step S506. A specific example of the Q first grain weights can include the film grain weight of each of the Q brightness regions in the brightness image of the second superimposed film grain weight in step S507. For details not elaborated here, please refer to the above. Figure 5 The relevant steps are described in the text.
[0410] In step S2140, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set. The first film image includes Q third regions and Q first regions that correspond one-to-one. Each third region is determined based on the corresponding first region, the grain weight of the corresponding first region, and the corresponding second region. Different third regions correspond to grains of different sizes.
[0411] Different third regions correspond to particles of different sizes, also known as different third regions corresponding to particles of different sizes, or different third regions corresponding to particles of different dimensions. The particle size is not specifically limited; for example, particle size can include fine, medium, and coarse particles.
[0412] Each third region is determined based on the corresponding first region, the corresponding granular weight of the first region, and the corresponding second region. That is, each third region is determined based on the corresponding first region, the corresponding granular weight of the first region, and the second region corresponding to the corresponding first region.
[0413] The method by which an electronic device obtains the first film image based on the image to be processed, the initial film grain image, and the grain weight set is not specifically limited.
[0414] In one example, the grain weight set is determined according to the method described in Case 1 of Implementation Method 1 of Step S2130 above, or according to the method described in Implementation Method 2 of Step S2130 above. Therefore, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set. Exemplarily, this may include the following steps: The electronic device obtains a first luminance image and a first chroma image located in a second color space based on the image to be processed located in a first color space. The first luminance image is an image obtained by extracting the luminance of the first image. The first image is an image obtained by converting the image to be processed to the second color space. The first luminance image includes Q fourth regions and Q luminance ranges that correspond one-to-one. The luminance of each fourth region is the luminance within the corresponding luminance range. Different fourth regions correspond to different luminance ranges. The first chroma image is an image obtained by extracting the chroma of the first image. The electronic device obtains a first fused image based on the first luminance image, the initial film grain image, and the grain weight set. The electronic device performs superposition processing on the first chroma image and the first fused image to obtain a second film image. The electronic device converts the second film image to the first color space to obtain the first film image.
[0415] Q fourth regions correspond one-to-one with Q first regions. Each fourth region is obtained by extracting the brightness of the region after converting the corresponding first region to the second color space.
[0416] Optionally, after obtaining the second film image, the electronic device may not perform the step of converting the second film image to the first color space to obtain the first film image.
[0417] The first and second film images are both film images with the same film effect, the difference being that the first film image is in a different color space (first color space) and the second film image is in a different color space (second color space).
[0418] For example, when the initial film grain image in the above example is a film image obtained by shooting a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image, the electronic device, during the process of obtaining the first fused image based on the initial film grain image, can use a preset algorithm to change the gray color presented by the initial film grain image to transparent, thereby successfully superimposing the black and white grains in the initial film grain image onto the first fused image without affecting the chromaticity components of the first fused image. Subsequently, the grain shape of the first film image obtained by the electronic device based on the first fused image and the first chromaticity image is the same as the grain shape of the initial film grain image, and the chromaticity of the first film image is not affected by the chromaticity of the initial film grain image. Therefore, this method makes the film effect (grain shape and grain size) of the film image (i.e., the first film image) closer to the film effect (grain shape and grain size) of a real film image, improving image texture and enhancing the user's visual experience.
[0419] The electronic device employs the aforementioned technical solution, which involves segmenting a first image located in the second color space into a first luminance image and a first chroma image located in the second color space. Then, based on the initial film grain image and grain weight set, the electronic device independently adds grain effects to the first luminance image, avoiding interference with the chroma information of the first chroma image. Subsequently, during the overlay processing of the first chroma image and the first fused image, the chroma information of the first chroma image remains unaffected; that is, the chroma information of the resulting first fused image is closer to that of the first chroma image. Therefore, this method, while ensuring that the film effect (i.e., grain size) of the first film image obtained after image processing is closer to the film effect (i.e., grain size) of a real film image, also helps improve the color quality of the first film image, enhances the image texture, and better meets the user's visual needs.
[0420] There are no specific limitations on the first and second color spaces; they can be set according to the actual situation. Optionally, the first color space is the RGB color space, and the second color space is one of the following: YUV color space, HSV color space, or LAB color space.
[0421] For example, taking the YUV color space as the second color space, luminance extraction is performed on the first image, that is, the Y component (luminance) in the first image is extracted. Chromaticity extraction is performed on the first image, that is, the U and V components (which contain chromaticity information, that is, the type and saturation of color, used to specify the color of a pixel) in the first image are extracted.
[0422] For example, taking the HSV color space as the second color space, the brightness of the first image is extracted, that is, the V component (value component, also known as the luminance component) of the first image is extracted. The chromaticity of the first image is extracted, that is, the H component (representing the type of color) and S component (representing the purity or intensity of color) of the first image are extracted.
[0423] For example, taking the LAB color space as the second color space, luminance extraction is performed on the first image, that is, the L component (luminance component) of the first image is extracted. Chroma extraction is performed on the first image, that is, the A component and B component (representing color) of the first image are extracted.
[0424] For example, a specific example of the image to be processed is the one described above. Figure 5 In the provided image processing method, the image to be processed in step S502 includes, for example, the second color space in step S503 (specifically, the YUV color space), the first image in step S504, the first luminance image in step S504, the Q fourth regions in step S506, the first chroma image in step S505, the second film grain image in step S510, the grain weight set in step S510 (specifically, the film grain weights of each luminance region in the luminance image with the second superimposed film grain weights in step S510), the first fused image in step S510, the second film image in step S511, and the first film image in step S512. Details not elaborated here can be found above. Figure 5 The relevant descriptions in the provided steps.
[0425] In another example, the grain weight set is determined according to the method described in case 2 of implementation method one in step S2130 above. Therefore, the electronic device obtains a first film image based on the image to be processed, the initial film grain image, and the grain weight set. Exemplarily, this may include the following steps: the electronic device performs a fusion process on the image to be processed, the initial film grain image, and the grain weight set to obtain a second film image; the electronic device converts the second film image to a first color space to obtain the first film image.
[0426] For example, when the initial film grain image in the above example is a film image obtained by shooting a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image, during the process of obtaining the second film image, the electronic device can use a preset algorithm to change the gray color presented by the initial film grain image to transparent, thereby successfully superimposing the black and white grains in the initial film grain image onto the second film image without affecting the chromaticity components of the second film image. Subsequently, the grain shape of the first film image obtained by the electronic device based on the second film image is the same as the grain shape of the initial film grain image, and the chromaticity of the first film image is not affected by the chromaticity of the initial film grain image. Therefore, this method makes the film effect (grain shape and grain size) of the film image (i.e., the first film image) closer to the film effect (grain shape and grain size) of a real film image, improving image texture and enhancing the user's visual experience.
[0427] For example, a specific example of the image to be processed is the one described above. Figure 19 In the provided image processing method, the image to be processed in step S1902 includes, in a specific example, the initial film grain image, which is the second film grain image in step S1907 above. A specific example of the grain weight set includes the film grain weights of each semantic region in the semantic segmentation image with the second superimposed film grain weights in step S1908 above. A specific example of the second film image is the second film image in step S1908 above, and a specific example of the first film image is the first film image in step S1909 above. Details not elaborated here can be found above. Figure 19 The relevant descriptions in the provided steps.
[0428] It should be understood that the above Figure 21 The image processing methods shown are for illustrative purposes only and do not constitute any limitation on the image processing methods provided in the embodiments of this application. For example, the morphology of the grains in the initial film grain image described above can also be noise obtained by noise extraction from the original RAW. In this implementation, the grain size of the grains in different regions (e.g., brightness regions or semantic regions) of the first film image is closer to the grain size of the grains in different regions of the real film image, which can improve the image texture and enhance the user's visual experience to a certain extent.
[0429] In this embodiment, the electronic device does not assign the same grain weight (corresponding to grains of the same size) to all first regions included in the image to be processed. Instead, it assigns different grain weights (corresponding to grains of different sizes) to different first regions included in the image to be processed, resulting in a set of grain weights. Then, based on the image to be processed, the initial film grain image, and the set of grain weights, the electronic device obtains a first film image with a film effect (grain shape and grain size), such that different third regions included in the first film image have grains of different sizes. Based on this method, it is possible to avoid the final first film image having grains of the same size in all different first regions, making the film effect (i.e., grain size) of the first film image closer to the film effect (i.e., grain size) of a real film image, thereby improving image texture and enhancing the user's visual experience.
[0430] The following is combined with Figures 22 to 24 The interface diagrams of the electronic devices according to embodiments of this application will be described in detail.
[0431] Figure 22 This is a schematic diagram of the interface of an electronic device provided in an embodiment of this application.
[0432] For example, such as Figure 22 As shown, Figure 22 The graphical user interface (GUI) shown in (a) is the desktop 2210 of the electronic device; the electronic device detects a click operation on the camera application control 2220 on the desktop 2210, such as... Figure 13 As shown in (b); after the electronic device detects a click operation on the camera application control 2220, the electronic device runs the camera application and displays a photo preview interface 2230. The camera mode in the photo preview interface 2230 is "Portrait" mode, and when the camera mode is "Portrait" mode, the photo preview interface 2230 includes a film control 2232 corresponding to the "Portrait" mode (gray indicates an unselected state), as shown in (b). Figure 22 As shown in (c); the electronic device detects a click operation on the film control 2232, as... Figure 22 As shown in (c); after the electronic device detects a click on the film control 2232, the electronic device runs the camera application and displays the photo preview interface 2240. The photo preview interface 2240 includes the film control 2242 (black indicates the selected state) and the shooting control 2241 corresponding to the "Portrait" mode. The film control 2242 corresponding to the "Portrait" mode is in the selected state, that is, the "Portrait" mode is specifically the "film" mode corresponding to the "Portrait" mode, as shown in (c); after the electronic device detects a click on the film control 2232, the electronic device runs the camera application and displays the photo preview interface 2240. Figure 22As shown in (d) in the diagram; after the electronic device detects a click operation on the shooting control 2241 in the photo preview interface 2240, it triggers the electronic device to acquire and process the image. Simultaneously, it also triggers the electronic device to execute the image processing method of this embodiment on the acquired image to be processed, and displays the photo preview interface 2250, as shown in the diagram. Figure 22 As shown in (e). It should be understood that the image displayed in the photo preview interface 2250 is a film image obtained by adding film effects (i.e., grain shape and grain size) to the image displayed in the photo preview interface 2230.
[0433] Figure 23 This is a schematic diagram of the interface of another electronic device provided in an embodiment of this application.
[0434] For example, such as Figure 23 As shown, Figure 23 The graphical user interface shown in (a) is the desktop 2310 of the electronic device; the electronic device detects a click operation on the camera application control 2320 on the desktop 2310, such as Figure 23 As shown in (b); after the electronic device detects a click operation on the camera application control 2320, the electronic device runs the camera application and displays the photo preview interface 2330; the photo preview interface 2330 includes a shooting control 2331 and a smart control 2332, such as Figure 23 As shown in (c); the electronic device detects a click operation on the shooting control 2331, and the electronic device can acquire the image to be processed; the electronic device detects a click operation on the smart control 2332, such as Figure 23 As shown in (d); after the electronic device detects a click operation on the smart control 2332, it triggers the electronic device to execute the image processing method of this application embodiment, displaying the photo preview interface 2340, as shown. Figure 23 As shown in (e). It should be understood that the image displayed in the photo preview interface 2340 is a film image obtained by adding film effects (i.e., grain shape and grain size) to the image displayed in the photo preview interface 2330.
[0435] Figure 24 This is a schematic diagram of the interface of another electronic device provided in an embodiment of this application.
[0436] For example, such as Figure 24 As shown, Figure 24 The graphical user interface shown in (a) is the desktop 2410 of the electronic device; the electronic device detects a click operation on the camera application control 2420 on the desktop 2410, such as Figure 24As shown in (b); after the electronic device detects a click operation on the camera application control 2420, the electronic device runs the camera application and displays the photo preview interface 2430; the photo preview interface 2430 includes settings controls 2431 and shooting controls 2432, such as Figure 24 As shown in (c); the electronic device detects a click operation on the shooting control 2432, and the electronic device acquires the image to be processed; the electronic device detects a click operation on the setting control 2431, as shown in (c). Figure 24 As shown in (d); after the electronic device detects a click on the setting control 2431, the electronic device displays the setting interface 2440; the setting interface 2440 includes a control 2441 for overlaying film grain, as shown in (d); Figure 24 As shown in (e); the electronic device detects a click operation on the control 2441 for overlaying film grains, as... Figure 24 As shown in (f); after the electronic device detects a click operation on the control 2441 that overlays film grains, it can trigger the electronic device to execute the image processing method of this application embodiment on the acquired image to be processed, so as to obtain a film image with film effect (i.e., the shape and grain size of the grains).
[0437] It should be understood that the above examples are provided to help those skilled in the art understand the embodiments of this application, and are not intended to limit the embodiments of this application to the specific values or scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of this application.
[0438] The above text combined Figures 1 to 24 The image processing method provided in the embodiments of this application has been described in detail; the following will be combined with Figure 25 The apparatus embodiments of this application are described in detail below. It should be understood that the apparatus in the embodiments of this application can perform the various methods described in the foregoing embodiments of this application, that is, the specific working processes of the various products described below can be referred to the corresponding processes in the foregoing method embodiments.
[0439] Figure 25 This is a schematic diagram of an image processing apparatus provided in an embodiment of this application.
[0440] For example, Figure 25 The illustrated image processing apparatus 2500 may include a processing unit 2510, which is configured to perform the operations described in the embodiments of this application above. Figure 5 , Figure 19 or Figure 21 The provided image processing methods.
[0441] It should be noted that the image processing device 2500 described above is embodied in the form of a functional unit. The term "unit" here can be implemented in software and / or hardware, and there is no specific limitation on this.
[0442] For example, a "unit" can be a software program, a hardware circuit, or a combination of both that implements the above functions. The hardware circuit may include an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components that support the described functions.
[0443] Therefore, the units of the various examples described in the embodiments of this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0444] This application also provides a computer program product that, when executed by a processor, implements the image processing method described in any of the method embodiments of this application.
[0445] The computer program product can be stored in memory, for example, it is a program. The program is eventually converted into an executable object file that can be executed by the processor after processes such as preprocessing, compilation, assembly and linking.
[0446] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, implements the image processing method described in any of the method embodiments of this application. The computer program may be a high-level language program or an executable object program.
[0447] This application also provides a chip for use in an electronic device. The chip includes one or more processors that invoke computer instructions to cause the electronic device to execute the image processing method described in any of the method embodiments of this application.
[0448] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0449] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0450] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0451] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0452] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0453] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0454] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0455] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image processing method, characterized in that, The method includes: Obtain the image to be processed, wherein the image to be processed includes Q first regions, where Q is a positive integer greater than 1; An initial film grain image is obtained, wherein the initial film grain image has uniformly distributed grains, and the initial film grain image includes Q second regions and Q first regions that correspond one-to-one. The position of each second region in the initial film grain image is the same as the position of the corresponding first region in the image to be processed. Determine a set of particle weights, wherein the set of particle weights includes the particle weights of each first region, and the particle weights of different first regions are different; A first film image is obtained based on the image to be processed, the initial film grain image, and the grain weight set. The first film image includes Q third regions that correspond one-to-one with the Q first regions. Each third region is determined based on the corresponding first region, the grain weight of the corresponding first region, and the corresponding second region. Different third regions correspond to grains of different sizes.
2. The method according to claim 1, characterized in that, The determination of the particle weight set includes: Based on the first preset relationship and the Q first regions, Q first particle weights are determined, wherein the first preset relationship includes at least Q correspondences between the Q first regions and the Q first particle weights; The set of particle weights is determined based on the Q first particle weights.
3. The method according to claim 2, characterized in that, The set of particle weights includes the Q first particle weights.
4. The method according to claim 3, characterized in that, Q brightness ranges correspond one-to-one with the Q first regions, wherein the brightness of each first region is the brightness within the corresponding brightness range, and different first regions correspond to different brightness ranges; The Q brightness ranges and the Q first particle weights correspond one-to-one, wherein the particle weight of each first region is the first particle weight corresponding to the corresponding brightness range, and different brightness ranges correspond to different first particle weights.
5. The method according to claim 3, characterized in that, The Q first regions and Q semantic information correspond one-to-one, and the semantic information of each first region is the corresponding semantic information. Different first regions correspond to different semantic information. The Q semantic information pieces and the Q first particle weights are in one-to-one correspondence. The particle weight of each first region is the first particle weight corresponding to the semantic information. Different semantic information corresponds to different first particle weights.
6. The method according to claim 2, characterized in that, Q brightness ranges correspond one-to-one with the Q first regions, the brightness of each first region is the brightness within the corresponding brightness range, different first regions correspond to different brightness ranges, and; The step of determining the set of particle weights based on the Q first particle weights includes: A second particle weight is determined based on a second preset relationship and semantic information of the target region in the image to be processed, wherein the second preset relationship includes at least the correspondence between the semantic information and the second particle weight; Determine the particle weight of the region in the i-th first region that does not overlap with the target region, and set it as the particle weight of the i-th first region; and, The particle weight of the region in the i-th first region that overlaps with the target region is determined to be the product of the particle weight of the i-th first region and the second particle weight; Wherein, the i-th first region is any one of the Q first regions, the Q brightness ranges and the Q first particle weights correspond one-to-one, the particle weight of the i-th first region is the i-th first particle weight corresponding to the i-th brightness range, and i is a positive integer less than or equal to Q.
7. The method according to claim 4 or 6, characterized in that, The step of obtaining the first film image based on the image to be processed, the initial film grain image, and the grain weight set includes: Based on the image to be processed located in the first color space, a first luminance image and a first chroma image located in the second color space are obtained. The first luminance image is an image obtained by extracting the luminance of the first image. The first image is an image obtained by converting the image to be processed to the second color space. The first luminance image includes Q fourth regions and Q luminance ranges that correspond one-to-one. The luminance of each fourth region is the luminance within the corresponding luminance range. Different fourth regions correspond to different luminance ranges. The first chroma image is an image obtained by extracting the chroma of the first image. A first fused image is obtained based on the first brightness image, the initial film grain image, and the grain weight set; The first chroma image and the first fused image are superimposed to obtain the second film image; The second film image is converted to the first color space to obtain the first film image.
8. The method according to claim 6, characterized in that, The target area is the face area.
9. The method according to any one of claims 4, 6 to 8, characterized in that, The first brightness range and the second brightness range are any two different brightness ranges among the Q brightness ranges; The brightness of the first brightness range is higher than that of the second brightness range, and the first particle weight corresponding to the first brightness range is less than that corresponding to the second brightness range.
10. The method according to claim 7, characterized in that, The first color space is the RGB color space, and the second color space is one of the following: YUV color space, HSV color space, or LAB color space.
11. The method according to any one of claims 1 to 10, characterized in that, The initial film grain image is a film image obtained by taking a picture of a neutral gray area of a preset ratio using a film camera, or an image obtained by uniformly distributing the grains in the film image.
12. The method according to any one of claims 1 to 10, characterized in that, The process of acquiring the initial film grain image includes: Acquire at least one film grain image, wherein each of the at least one film grain images is a film image obtained by taking a picture of a neutral gray area of a preset proportion using a film camera, or an image obtained by uniformly distributing the grains in the film image. The initial film grain image is obtained based on the at least one film grain image.
13. The method according to claim 12, characterized in that, Obtaining the initial film grain image based on the at least one film grain image includes: The initial film grain image is obtained by randomly selecting one film grain image from the at least one film grain image.
14. The method according to claim 12, characterized in that, The at least one film grain image includes a first film grain image, wherein the angle between the central axis of the first film grain image and the central axis of the image to be processed is zero degrees; Obtaining the initial film grain image based on the at least one film grain image includes: The first type of film grain image is rotated to obtain a rotated first type of film grain image, wherein the angle between the central axis of the rotated first type of film grain image and the central axis of the image to be processed is non-zero degrees. If the size of the rotated first type of film grain image differs from the size of the image to be processed, the rotated first type of film grain image is cropped or expanded to obtain the initial film grain image; or... If the size of the first type of film grain image after rotation is the same as the size of the image to be processed, the first type of film grain image after rotation is determined as the initial film grain image, and the initial film grain image is obtained.
15. The method according to claim 12, characterized in that, The at least one type of film grain image specifically includes a first type of film grain image having a two-dimensional morphology, and; Obtaining the initial film grain image based on the at least one film grain image includes: Based on the first type of film grain image, a first rotation sequence of film grain images with a three-dimensional hollow cylindrical shape is generated; The second rotating sequence film grain image with a three-dimensional hollow cylindrical shape is randomly cropped to obtain the initial film grain image with a two-dimensional shape. The second rotating sequence film grain image is either the first rotating sequence film grain image or an image obtained by rotating the first rotating sequence film grain image.
16. The method according to any one of claims 1 to 15, characterized in that, The process of acquiring the image to be processed includes: Display the first interface; A first operation on a first control included in the first interface is detected; In response to the first operation, the image to be processed is acquired.
17. The method according to claim 16, characterized in that, The first interface is the portrait mode photo-taking interface, and the first control is a control used to indicate taking a photo.
18. An electronic device, characterized in that, The device includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store a computer program that, when executed by the one or more processors, causes the electronic device to perform the image processing method as described in any one of claims 1 to 17.
19. A chip system applied to an electronic device, the chip system comprising one or more processors, characterized in that, The processor is used to invoke computer instructions to cause the electronic device to perform the image processing method as described in any one of claims 1 to 17.
20. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, the electronic device causes the electronic device to perform the image processing method as described in any one of claims 1 to 17.