Image processing method and device
By configuring multiple processing strategies in the electronic device and selecting target processing strategies based on user operations or image characteristics, the problem that automatic image adjustment in the prior art cannot meet user needs is solved, and more efficient personalized image processing is achieved.
Patent Information
- Application Number
- CN202510524225.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-07-11
AI Technical Summary
When existing electronic devices automatically adjust image parameters, they cannot meet users' personalized needs, resulting in the adjusted images not fully meeting users' expectations.
An image processing method is provided, by preconfiguring two processing strategies (first processing strategy and second processing strategy) in an electronic device, selecting a target processing strategy according to user operations or image features, and adjusting image parameters to obtain a processed image that meets user needs.
It realizes the selection of appropriate processing strategies based on user preferences and image characteristics, meets the personalized adjustment needs of different users, and improves the flexibility and quality of image processing.
Smart Images

Figure CN120302168A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technologies, and particularly relates to an image processing method and device. Background Art
[0002] After an electronic device obtains an image, for example, after taking a photo, it is sometimes necessary to adjust specific image parameters of the image based on a user's operation instruction to obtain an adjusted image that meets the user's needs.
[0003] To improve the convenience of operation, some electronic devices provide a function of automatically adjusting image parameters, and can automatically adjust the image parameters of multiple images based on this function.
[0004] The defect of the above function is that an electronic device generally can only adjust the image parameters to specific values, resulting in some images still not meeting the user's needs after adjustment. Summary of the Invention
[0005] For this reason, the present application discloses the following technical solutions:
[0006] The first aspect of the present application provides an image processing method, including:
[0007] In response to obtaining an image to be processed, determine a target processing strategy from a first processing strategy and a second processing strategy;
[0008] Adjust the value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image;
[0009] Wherein, the values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different, and the first processing strategy and the second processing strategy are used to adjust the same type of image parameters.
[0010] Optionally, the "responding to obtaining an image to be processed" includes:
[0011] Responding to obtaining an image to be processed collected by an image acquisition device;
[0012] It further includes:
[0013] Display the processed image on a target interface; the target interface is used for a user to preview the image processed by the image acquisition device based on the target processing strategy.
[0014] Optionally, when the first range corresponding to the first processing strategy matches the image parameters of the image to be processed, the target processing strategy is the first processing strategy;
[0015] When the second range corresponding to the second processing strategy matches the image parameters of the image to be processed, the target processing strategy is the second processing strategy;
[0016] The first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
[0017] Optionally, if the image parameters of the first processing result match the second range, the target processing strategy is the second processing strategy, and the first processing result is the processing result obtained by processing the image to be processed according to the first processing strategy;
[0018] If the image parameters of the first processing result match the first range, the target processing strategy is the first processing strategy, and the first processing result is used as the processed image;
[0019] Or,
[0020] If the image parameters of the second processing result match the first range, the target processing strategy is the first processing strategy, and the second processing result is the processing result obtained by processing the image to be processed according to the second processing strategy;
[0021] If the image parameters of the second processing result match the second range, the target processing strategy is the second processing strategy, and the second processing result is used as the processed image;
[0022] Wherein, the first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
[0023] Optionally, the first processing strategy includes calling a first processing model to process the image to be processed, and the second processing strategy includes calling a second processing model to process the image to be processed;
[0024] Or, the first processing strategy includes calling the target processing model with a first parameter, and the second processing strategy includes calling the target processing model with a second parameter.
[0025] Optionally, the model parameters of the first processing model are determined according to multiple groups of sample images and the target image parameters corresponding to each group of the sample images;
[0026] Each group of the sample images corresponds to a kind of scene information, and the scene information corresponding to different groups of sample images is different. The target image parameters are determined according to the adjustment instructions for adjusting the image parameters of the corresponding sample images.
[0027] Optionally, the target image parameters corresponding to a group of the sample images are obtained by fusing the initial image parameters and parameter weights of each image included in the group of sample images. The initial image parameter of each image is specified by an adjustment instruction for adjusting the image, and the parameter weight of each image is determined based on the initial image parameter of the image.
[0028] Optionally, if the target processing strategy is the first processing strategy, adjusting the value of the image parameter of the image to be processed according to the target processing strategy to obtain a processed image includes:
[0029] Inputting the image to be processed into the target processing model with the first parameter to obtain the processed image;
[0030] If the target processing strategy is the second processing strategy, adjusting the value of the image parameter of the image to be processed according to the target processing strategy to obtain a processed image includes:
[0031] Inputting the image to be processed into the target processing model with the second parameter to obtain the processed image.
[0032] Optionally, the image parameter includes at least one of a color temperature parameter and a hue parameter.
[0033] A second aspect of the present application provides an electronic device, including:
[0034] A memory for storing a computer program;
[0035] A processor for executing the computer program to perform the following image processing method:
[0036] In response to obtaining an image to be processed, determining a target processing strategy from a first processing strategy and a second processing strategy;
[0037] Adjusting the value of the image parameter of the image to be processed according to the target processing strategy to obtain a processed image;
[0038] Wherein, the values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different, and the first processing strategy and the second processing strategy are used to adjust the same type of image parameter. Description of the Drawings
[0039] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.
[0040] Figure 1 It is a flowchart of an image processing method provided by an embodiment of the present application;
[0041] Figure 2 It is a flowchart of a method for determining a target processing strategy provided by an embodiment of the present application;
[0042] Figure 3 It is a flowchart of a method for generating a first processing strategy provided by an embodiment of the present application;
[0043] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0044] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0045] This embodiment provides an image processing method. Please refer to Figure 1 and the method may include the following steps.
[0046] S101, in response to obtaining an image to be processed, determine a target processing strategy between a first processing strategy and a second processing strategy, where the first processing strategy and the second processing strategy are used to adjust the same image parameter.
[0047] The image to be processed can be obtained in various ways. For example, the electronic device executing the method of this embodiment may have an image acquisition device (such as a camera), and the image to be processed may include one or more images acquired by the electronic device through the image acquisition device; or, the image to be processed may include one or more images downloaded by the electronic device through the network; or, the image to be processed may include one or more images obtained by the electronic device from other electronic devices after communication connection with other electronic devices via a data cable or Bluetooth or other connection methods; or, the image to be processed may include one or more images generated by the electronic device in response to a user's image editing or drawing operation.
[0048] The first processing strategy and the second processing strategy are two processing strategies pre-configured in the electronic device for adjusting the same image parameter.
[0049] The type of the image parameter adjusted by the first processing strategy and the second processing strategy is not limited.
[0050] For example, both processing strategies can be used to adjust the color temperature parameter of the image; both processing strategies can be used to adjust the hue parameter of the image; both processing strategies can be used to adjust the filter parameter of the image, and different values of the filter parameter correspond to different image filters; both processing strategies can be used to adjust the parameters related to image beautification, such as any one of the contrast parameter, saturation parameter, and brightness parameter; for a portrait image, both processing strategies can also be used to adjust the parameters related to portrait beautification, such as the face slimming parameter, whitening parameter, skin smoothing parameter, etc., without limitation.
[0051] In step S101, the electronic device can determine the target processing strategy based on the user's operation instruction, or can determine the target processing strategy based on the image to be processed. The way of determining the target processing strategy is not limited.
[0052] S102, adjust the value of the image parameter of the image to be processed according to the target processing strategy to obtain the processed image. The values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different.
[0053] In step S102, according to the difference of the determined target processing strategy, the image parameters of the obtained processed image can be different.
[0054] As an example, both the first processing strategy and the second processing strategy are used to adjust the color temperature parameter of the image. If the first processing strategy is selected as the target processing strategy, the value of the color temperature parameter of the obtained processed image may be 5000K, that is, the color temperature of the processed image is 5000K. If the second processing strategy is selected as the target processing strategy, the value of the color temperature parameter of the obtained processed image may be 4000K.
[0055] Both the first processing strategy and the second processing strategy are used to adjust the hue parameter of the image. If the first processing strategy is selected as the target processing strategy, the value of the hue parameter of the obtained processed image may be 100°, that is, the hue of the processed image is 100°. If the second processing strategy is selected as the target processing strategy, the value of the hue parameter of the obtained processed image may be 70°.
[0056] The beneficial effect of this embodiment is that:
[0057] When adjusting specific image parameters of an image to be processed, the method of this embodiment can select an appropriate processing strategy from a first processing strategy and a second processing strategy to adjust the image, so as to adjust the image parameters of the image to be processed to different values to meet different adjustment requirements of users.
[0058] In some embodiments, the second processing strategy can be a processing strategy pre-configured by relevant manufacturers when the electronic device leaves the factory. When adjusting the value of the image parameters of the image to be processed based on the second processing strategy, the value of the image parameters of the processed image can generally be a fixed value, or can be within a fixed value range. In other words, for the processed image obtained by adjusting based on the second processing strategy, the value of its image parameters cannot be controlled by the user.
[0059] In contrast, the first processing strategy can be a processing strategy generated by the electronic device based on the user's operations during the period when the electronic device is used by the user. When adjusting the value of the image parameters of the image to be processed based on the first processing strategy, the value of the image parameters of the processed image can generally be a floating value, or can be within a floating value range. Therefore, for the processed image obtained by adjusting based on the first processing strategy, the value of its image parameters is related to the user's previous operations and can be controlled by the user.
[0060] That is to say, the first processing strategy can be regarded as a personalized processing strategy configured on the electronic device based on the user's operations, and the second processing strategy can be regarded as a default processing strategy preset on the electronic device.
[0061] Based on the method of this embodiment, the user can choose to use the default second processing strategy to adjust the image to be processed, enabling the user to conveniently adjust the parameters of the image, or can also choose to use the personalized first processing strategy to adjust the image to be processed, so as to meet the personalized preferences of different users.
[0062] The method provided in this embodiment can be executed in real time during the period when the electronic device acquires an image. That is to say, in response to obtaining an image to be processed, it can include:
[0063] In response to obtaining the image to be processed acquired by the image acquisition device;
[0064] Correspondingly, each frame of the processed image obtained by executing the above method in real time can be displayed in real time through the following steps:
[0065] Display the processed image to the target interface; the target interface is used for the user to preview the image obtained by the image acquisition device based on the target processing strategy.
[0066] After being activated, the image acquisition device of the electronic device can collect multiple consecutive frames of images in real time at a certain period. In this embodiment, each frame of image collected by the image acquisition device can be used as an image to be processed.
[0067] Exemplarily, if the electronic device is a mobile phone, when the mobile phone responds to a user operation to start the camera application and places the camera application in the photo-taking mode or the video-recording mode, the image acquisition device, that is, the camera of the mobile phone, is activated to collect images in real time.
[0068] In the related art, after the image acquisition device is activated, the electronic device can display a preview interface, and the preview interface can display each frame of image collected by the image acquisition device in real time.
[0069] In this embodiment, the electronic device can use the above preview interface as the target interface and display each frame of processed image in the target interface in real time.
[0070] Optionally, the target interface can only display the processed image so that the user can fully observe the processed image.
[0071] Or, the target interface can display the processed image and the corresponding image to be processed at the same time. That is to say, when a frame of image to be processed 1 is obtained, the processed image 1 is obtained based on the target processing strategy adjustment, and then the image to be processed 1 and the processed image 1 can be displayed in the target interface at the same time, and relevant prompt information can be further displayed to enable the user to distinguish the processed image from the image to be processed. In this way, it is convenient for the user to intuitively evaluate the adjustment effect of the target processing strategy by comparing the two images, and the electronic device can also change the target processing strategy based on the user's operation during the display, for example, changing the target processing strategy from the second processing strategy to the first processing strategy, or vice versa.
[0072] In some embodiments, the electronic device can also only display the image to be processed collected by the image acquisition device in the above target interface without displaying the processed image. At the same time, it can also not process each frame of image to be processed in real time according to the above method. Only after obtaining a specific trigger instruction, it starts to process the image to be processed obtained by the image acquisition device and stores the processed image as a corresponding file in the memory.
[0073] As some examples, when the electronic device starts the camera application and the camera application is in the photo-taking mode, it can display each frame of image collected by the image acquisition device in the target interface in real time. At this time, the collected images can be not processed. When a photo-taking instruction is obtained at a certain moment, the electronic device can use the image corresponding to this moment collected by the image acquisition device as the image to be processed, adjust the image to be processed according to the above method to obtain the processed image, and then store the processed image as an image file in the memory.
[0074] Among them, the photographing instruction can be a click instruction for clicking a virtual shutter button displayed on the screen of the electronic device, or a key instruction generated when the user presses a specific physical button of the electronic device (such as the power button or volume button of a mobile phone, the shutter button of a camera).
[0075] As some examples, when the electronic device starts the camera application and the camera application is in the video recording mode, each frame of the image collected by the image acquisition device can be displayed in real time on the target interface. At this time, the collected images can be not processed. When a start video recording instruction is obtained at a certain moment, the electronic device can use each frame of the image collected by the image acquisition device as an image to be processed, adjust each frame of the image to be processed according to the above method to obtain a processed image, and then display each frame of the processed image on the target interface, and at the same time write each frame of the processed image as a video frame into a video file until a stop video recording instruction is obtained. After obtaining the stop video recording instruction, the electronic device can store the above video file in the memory.
[0076] In some alternative embodiments, the electronic device can determine a target processing strategy based on a user's selection instruction.
[0077] Before obtaining the image to be processed, the electronic device can output relevant prompt information to prompt the user to select between a first processing strategy and a second processing strategy, and use the processing strategy selected by the selection instruction as the target processing strategy after obtaining the selection instruction.
[0078] Exemplarily, when the electronic device starts the camera application, it first displays a selection interface for selecting a first processing strategy and a second processing strategy, and prompts the user to make a selection. After the user selects the first processing strategy, the electronic device determines the first processing strategy as the target processing strategy.
[0079] After obtaining the image to be processed and before starting to adjust the image to be processed, the electronic device can also output relevant prompt information to prompt the user to select between a first processing strategy and a second processing strategy.
[0080] For example, after obtaining the photographing instruction, the electronic device can save the image to be processed collected by the image acquisition device, then output relevant prompt information, and after the user performs a corresponding selection operation, adjust the image to be processed according to the determined target processing strategy.
[0081] In some alternative embodiments, the electronic device can also automatically determine the target processing strategy according to the image to be processed.
[0082] One way to automatically determine the target processing strategy according to the image to be processed is:
[0083] Determine the target processing strategy according to the value of the image parameters of the image to be processed, and the image parameter ranges corresponding to the first processing strategy and the second processing strategy.
[0084] Among them, when the first range corresponding to the first processing strategy matches the image parameters of the image to be processed, the target processing strategy is the first processing strategy;
[0085] When the second range corresponding to the second processing strategy matches the image parameters of the image to be processed, the target processing strategy is the second processing strategy;
[0086] The first range represents the image parameter range of the image obtained according to the first processing strategy, and the second range represents the image parameter range of the image obtained according to the second processing strategy.
[0087] The first range can be understood as the expected value range of the image parameters of the image obtained according to the first processing strategy, and the second range can be understood as the expected value range of the image parameters of the image obtained according to the second processing strategy.
[0088] Taking the adjustment of the color temperature parameter as an example, if the image obtained after adjustment according to the first processing strategy has all its color temperature parameters between 3000K and 4000K, then the first range is 3000K to 4000K. If the image obtained after adjustment according to the second processing strategy has all its color temperature parameters between 5000K and 5500K, then the second range is 5000K to 5500K.
[0089] The matching between the first range and the image parameters of the image to be processed may include: the value of the image parameters of the image to be processed is within the first range; the matching between the second range and the image parameters of the image to be processed may include: the value of the image parameters of the image to be processed is within the second range.
[0090] Combined with the foregoing example, if the color temperature parameter of the image to be processed is 3600K, then the color temperature parameter of the image to be processed matches the first range. If the color temperature parameter of the image to be processed is 5200K, then the color temperature parameter of the image to be processed matches the second range.
[0091] If the second processing strategy is a processing strategy pre-configured by the relevant manufacturer, its corresponding second range can also be set by the relevant manufacturer when configuring the second processing strategy.
[0092] If the first processing strategy is a processing strategy generated by the electronic device based on the user's operation, the electronic device can determine the first range according to the data used to generate the first processing strategy when generating the first processing strategy.
[0093] The advantage of determining the target processing strategy according to the above method is that by selecting a processing strategy whose selection range matches the image parameters of the image to be processed for adjustment, the difference between the image to be processed and the processed image obtained by adjusting the target processing strategy can be reduced, and the distortion of the processed image caused by too large a numerical difference between the image parameters of the image to be processed and the image parameters of the processed image can be avoided.
[0094] Another way to automatically determine the target processing strategy according to the image to be processed can be:
[0095] First, use any one of the two processing strategies to process the image to be processed to obtain the corresponding processing result, match the image parameters of the processing result with the ranges corresponding to different processing strategies, and determine the processing strategy that matches as the target processing strategy.
[0096] Please refer to Figure 2 , which is a flowchart of a method for determining the target processing strategy based on the above method.
[0097] S201, Process the image to be processed with the first processing strategy to obtain the first processing result.
[0098] S202, Determine whether the image parameters of the first processing result match the first range.
[0099] If they match, execute step S202; if they do not match, execute step S203.
[0100] S203, Determine the first processing strategy as the target processing strategy and output the first processing result as the processed image.
[0101] S204, Determine the second processing strategy as the target processing strategy to obtain the processed image based on the second processing strategy.
[0102] In step S201, the numerical value of the image parameters of the image to be processed can be adjusted according to the first processing strategy, and the adjusted image obtained is used as the first processing result.
[0103] In S202, it can be determined whether the numerical value of the adjusted image parameters in the first processing result is within the first range. If it is within the first range, it is determined that the image parameters of the first processing result match the first range, and step S203 is executed; if it is not within the first range, it is determined that the image parameters of the first processing result do not match the first range, and step S204 is executed.
[0104] Combined with the foregoing example, after adjusting the value of the color temperature parameter of the image to be processed according to the first processing strategy and obtaining the first processing result, if the value of the color temperature parameter of the first processing result is 3600K, which is within the first range of 3000K to 4000K, it indicates that the image parameters of the first processing result match the first range. At this time, the first processing strategy can be determined as the target processing strategy, and the first processing result is the processed image obtained by adjusting according to the target processing strategy.
[0105] If the value of the color temperature parameter of the first processing result is 4200K and it is not within the first range of 3000K to 4000K, it indicates that the image parameters of the first processing result do not match the first range. At this time, the second processing strategy can be determined as the target processing strategy, and then the value of the image parameters of the image to be processed is adjusted according to the second processing strategy to obtain the processed image.
[0106] Optionally, if the image parameters of the first processing result match the second range, the target processing strategy is the second processing strategy, and the first processing result is the processing result obtained by processing the image to be processed according to the first processing strategy;
[0107] If the image parameters of the first processing result match the first range, the target processing strategy is the first processing strategy, and the first processing result is used as the processed image;
[0108] In some embodiments, the image to be processed can also be adjusted first using the second processing strategy to obtain a second processing result, and then the target processing strategy is determined according to the matching situation between the image parameters of the second processing result and the first range and the second range. The relevant method flow can be referred to Figure 2 the method shown, which will not be elaborated.
[0109] In the case where the target processing strategy is determined according to the above method, if the image parameters of the second processing result match the first range, the target processing strategy is the first processing strategy, and the second processing result is the processing result obtained by processing the image to be processed according to the second processing strategy;
[0110] If the image parameters of the second processing result match the second range, the target processing strategy is the second processing strategy, and the second processing result is used as the processed image.
[0111] If the image parameters of the processing result corresponding to a processing strategy do not match the range of image parameters expected by this processing strategy, it indicates that this processing strategy may not be suitable for processing the current image. If the image parameters of the processing result corresponding to a processing strategy match the range of image parameters expected by this processing strategy, it indicates that this processing strategy may be more suitable for processing the current image compared to another processing strategy.
[0112] Based on the above principle, determining the target processing strategy in the latter manner is conducive to selecting, from the first processing strategy and the second processing strategy, a processing strategy that is more suitable for adjusting the image to be processed as the target processing strategy for the current image to be processed, so as to obtain a processed image of higher quality.
[0113] In some alternative embodiments, the first processing strategy and the second processing strategy may correspond to two different processing models, that is, the first processing strategy corresponds to the first processing model, and the second processing strategy corresponds to the second processing model. Correspondingly, the first processing strategy may include invoking the first processing model to process the image to be processed, and the second processing strategy may include invoking the second processing model to process the image to be processed.
[0114] If the target processing strategy is the first processing strategy, then S102 is equivalent to invoking the first processing model, inputting the image to be processed into the first processing model, and obtaining the image output by the first processing model as the processed image; if the target processing strategy is the second processing strategy, then S102 is equivalent to invoking the second processing model, inputting the image to be processed into the second processing model, and obtaining the image output by the second processing model as the processed image.
[0115] The first processing model and the second processing model may be two different processing models implemented based on deep learning technology. For example, the second processing model may be a default processing model pre-configured by the relevant manufacturer on the electronic device when the electronic device leaves the factory, and the first processing model may be a processing model constructed by the electronic device according to the user's operations during the user's use of the electronic device.
[0116] In some alternative embodiments, the first processing strategy and the second processing strategy may correspond to the same processing model, that is, the target processing model, and the first processing strategy and the second processing strategy may correspond to two parameters for invoking the target processing model, that is, the first processing strategy corresponds to the first parameter, and the second processing strategy corresponds to the second parameter.
[0117] In this case, the first processing strategy may include invoking the target processing model with the first parameter, and the second processing strategy may include invoking the target processing model with the second parameter.
[0118] If the target processing strategy is the first processing strategy, then S102 is equivalent to invoking the target processing model to process the image to be processed with the first parameter, and obtaining the image output by the target processing model as the processed image; if the target processing strategy is the second processing strategy, then S102 is equivalent to invoking the target processing model to process the image to be processed with the second parameter, and obtaining the image output by the target processing model as the processed image.
[0119] The target processing model can be a processing model implemented based on deep learning technology. The target processing model can be pre-configured in the electronic device by relevant manufacturers when the electronic device leaves the factory. The second parameter can be the default parameter configured into the electronic device together with the target processing model. Further, during the user's use of the electronic device, the electronic device can generate a first parameter different from the second parameter according to the user's operation, so as to process the image to be processed based on the first processing strategy.
[0120] The advantage of implementing the first processing strategy and the second processing strategy in the above manner is that a processing model needs to occupy a certain amount of storage space of the electronic device to store model parameters. Therefore, by only configuring one target processing model and implementing different processing strategies by changing the parameters when calling the model, the number of processing models that the electronic device needs to store can be reduced, saving the storage space of the electronic device.
[0121] The way to call the target processing model with the first parameter or the second parameter can be to input the image to be processed into the target processing model with the first parameter or the second parameter, and obtain the image output by the target processing model as the processed image.
[0122] That is to say, if the target processing strategy is the first processing strategy, then the way to adjust the image parameters of the image to be processed according to the target processing strategy in S102 can be:
[0123] Input the image to be processed into the target processing model with the first parameter to obtain the processed image;
[0124] Correspondingly, if the target processing strategy is the second processing strategy, then the way to adjust the image parameters of the image to be processed according to the target processing strategy in S102 can be:
[0125] Input the image to be processed into the target processing model with the second parameter to obtain the processed image.
[0126] In the above embodiments, inputting the image to be processed into the target processing model with the first parameter can be equivalent to inputting the first parameter and the image to be processed into the target processing model together, so that the target processing model processes the image to be processed according to the indication of the first parameter to obtain the processed image; inputting the image to be processed into the target processing model with the second parameter can be equivalent to inputting the second parameter and the image to be processed into the target processing model together, so that the target processing model processes the image to be processed according to the indication of the second parameter to obtain the processed image.
[0127] The first parameter and the second parameter can be numerical type parameters. For example, both the first parameter and the second parameter can include the numerical value or numerical range of the image parameters to be adjusted, and their numerical values or numerical ranges are different.
[0128] After the target processing model is input, the target processing model can use the numerical value or numerical range contained in the first parameter or the second parameter as an adjustment target to adjust the image parameters of the image to be processed and obtain a processed image.
[0129] As an example, the first parameter can include the numerical range of the color temperature parameter from 3000K to 3500K. After the target processing model obtains the first parameter, it takes adjusting the color temperature to between 3000K and 3500K as the target to process the image to be processed and obtains a processed image processed based on the first processing strategy. The second parameter can include the numerical value of the color temperature parameter of 5000K. After the target processing model obtains the second parameter, it takes adjusting the color temperature to 5000K as the target to process the image to be processed and obtains a processed image processed based on the first processing strategy.
[0130] The advantage of processing the image to be processed according to the above method is that there is no need to adjust the original target processing model. Only by providing the first parameter or the second parameter corresponding to the target processing strategy to the target processing model as a reference, the corresponding processed image can be obtained based on the target processing strategy, which has a high processing efficiency.
[0131] The way to call the target processing model with the first parameter or the second parameter can be as follows: First, based on the first parameter or the second parameter, update some model parameters of the target processing model, and then input the image to be processed into the updated target processing model, and the obtained result is used as the processed image.
[0132] As some examples, the model parameters contained in the target processing model can correspond to multiple network layers in the target processing model. The first parameter can indicate to update the model parameters corresponding to a specific one or several of these network layers, and can indicate the direction (increase or decrease) and amplitude of the update. The second parameter can indicate to update the model parameters corresponding to another one or several network layers, and can indicate the direction and amplitude of the update.
[0133] Alternatively, the second parameter can indicate not to update the target processing model, and only the first parameter indicates to update the target processing model. That is to say, if it is called with the second parameter, the image to be processed is directly input into the target processing model for processing, and only when it is called with the first parameter, the update is performed first.
[0134] If the target processing model is called according to the above method, if the target processing model is updated, it can be restored to the state before the update after the call ends, so that it can be updated again based on the first parameter or the second parameter during the next call.
[0135] The advantage of processing the image to be processed according to the above method is that when only the first parameter or the second parameter is input, since the model parameters of the target processing model are the same, the ability of the target processing model to adjust the image to be processed is limited, and the image parameters of the processed image output may not fully meet the user's needs. By updating the model parameters of the target processing model, the ability of the target processing model to adjust the image to be processed according to the corresponding processing strategy can be enhanced, which is beneficial to obtaining a processed image with image parameters more in line with the user's needs.
[0136] In some alternative embodiments, before adjusting the image to be processed according to the target processing strategy, the scene information of the image to be processed can be recognized first, so as to jointly adjust the image to be processed according to the target processing strategy and the scene information to obtain a processed image.
[0137] If the target processing strategy includes invoking a first processing model to adjust the image to be processed, the image to be processed and the scene information can be input into the first processing model together, and the output image is used as the processed image; if the target processing strategy includes invoking a second processing model to adjust the image to be processed, the image to be processed and the scene information can be input into the second processing model together, and the output image is used as the processed image.
[0138] If the target processing strategy includes invoking the target processing model with a first parameter, when invoking the target processing model with the first parameter, the image to be processed and the scene information are input into the target processing model together, and the output image is used as the processed image; if the target processing strategy includes invoking the target processing model with a second parameter, when invoking the target processing model with the second parameter, the image to be processed and the scene information can be input into the target processing model together, and the output image is used as the processed image.
[0139] The scene information of the image to be processed can be related to the content of the image to be processed. For example, the scene information of the image to be processed can be any one of a landscape scene, a food scene, and a portrait scene.
[0140] When adjusting the image to be processed according to the scene information, the type of image parameters to adjust the image to be processed can be determined according to the difference of the scene information.
[0141] Exemplarily, if the scene information is a landscape scene, the white balance parameter, exposure parameter, or filter parameter of the image to be processed can be adjusted based on the target processing strategy; if the scene information is a food scene, the saturation parameter or contrast parameter of the image to be processed can be adjusted based on the target processing strategy; if the scene information is a portrait scene, the face slimming parameter, whitening parameter, or skin smoothing parameter of the image to be processed can be adjusted based on the target processing strategy.
[0142] When adjusting the image to be processed according to the scene information, the numerical values of the image parameters of the processed image obtained can be different according to different scene information. For example, when adjusting the numerical value of the color temperature parameter of the image to be processed based on the target processing strategy, for a landscape scene, the color temperature value of the processed image obtained can be relatively low; for a food scene, the color temperature value of the processed image obtained can be relatively high; for a portrait scene, the color temperature value of the processed image obtained can be between that of the food scene and the landscape scene.
[0143] Further optionally, for specific scene information, the image to be processed can be cropped in advance to obtain a cropped image, and then the image parameters of the cropped image are adjusted according to the target processing strategy and the scene information to obtain the processed image.
[0144] For example, if the scene information of the image to be processed is a food scene, the area where the food is located can be cropped from the image to be processed as the cropped image, and the area other than the food area is retained as the background. The cropped image is adjusted according to the target processing strategy and the scene information, and then the output result is spliced with the background to form the processed image.
[0145] If the scene information of the image to be processed is a portrait scene, the area where the portrait is located can be cropped from the image to be processed as the cropped image, and the area other than the portrait area is retained as the background. The cropped image is adjusted according to the target processing strategy and the scene information, and then the output result is spliced with the background to form the processed image.
[0146] The advantage of adjusting the image to be processed in the above manner is that only the area where the main object (such as food, portrait, etc.) in the image to be processed is adjusted, which can reduce the computational amount in the adjustment process, achieve the effect of reducing resource overhead and improving processing efficiency. On the other hand, for images with main objects such as food scenes and portrait scenes, general users focus on the area where the main object is located and ignore the background. Therefore, only adjusting the image parameters of the area where the main object is located will not affect the visual effect of the processed image.
[0147] In the image processing method provided in this embodiment, the electronic device can generate the first processing strategy based on multiple methods. As an example, the electronic device can generate the first processing strategy according to the method Figure 3 shown.
[0148] S301, in response to the interaction instruction indicating the generation of the first processing strategy, obtain the first set of sample images corresponding to the first scene information and the second set of sample images corresponding to the second scene information.
[0149] The first set of sample images and the second set of sample images in this embodiment are only examples. In other optional embodiments, three or more sets of sample images can be used to generate the first processing strategy, not limited to two sets of sample images.
[0150] When the electronic device starts and launches an application related to image editing or image acquisition, such as an image beautification application or a camera application, an interaction control for generating a first processing strategy, such as an interaction button, can be displayed in the interface of the application. When the user triggers the interaction control, the electronic device obtains an interaction instruction indicating the generation of the first processing strategy, and then executes S101.
[0151] In S101, the electronic device can automatically select several images with the same scene information from multiple images already stored in the current memory as the first group of sample images, and select several images with another scene information as the second group of sample images.
[0152] Alternatively, the electronic device can also output a prompt message to prompt the user to manually select the first group of sample images and the second group of sample images.
[0153] That is to say, each group of sample images corresponds to a kind of scene information, and the scene information corresponding to different groups of sample images is different.
[0154] S302. Determine a first processing strategy based on the first group of sample images and the second group of sample images.
[0155] Among them, according to the difference of the first processing strategy, the method for determining the first processing strategy can be different.
[0156] For example, in the case where the first processing strategy includes calling a first processing model to process the image to be processed, step S302 may include:
[0157] S3021. Adjust an initial processing model based on the first group of sample images and the second group of sample images to obtain a first processing model.
[0158] When the first processing strategy includes processing an image by calling a target processing model with a first parameter, step S302 may include:
[0159] S3022. Adjust an initial parameter based on the first group of sample images and the second group of sample images to obtain a first parameter.
[0160] In step S2022, the model parameters of the first processing model can be determined according to multiple groups of sample images and the target image parameters corresponding to each group of sample images; the target image parameters can be determined according to an adjustment instruction for adjusting the image parameters of the corresponding sample images.
[0161] Optionally, after obtaining the first group and the second group of sample images, the target image parameters corresponding to these two groups of sample images can be determined first.
[0162] The method for determining the target image parameters can be:
[0163] For the first group of sample images, prompt the user to manually adjust the image parameters of this group of sample images, and then based on the adjustment instructions generated by the user's manual adjustment, determine the target image parameters of the first group of sample images. Similarly, the target image parameters of the second group of sample images can be determined.
[0164] Taking the image parameter as the color temperature parameter as an example, after the prompt, the electronic device can obtain an adjustment instruction to adjust the color temperature parameter of the first group of sample images to 5000K. Thus, it can be determined that the image parameter of the first group of sample images is 5000K. Similarly, the electronic device can obtain an adjustment instruction to adjust the color temperature parameter of the second group of sample images to 4000K. Thus, it can be determined that the image parameter of the first group of sample images is 4000K.
[0165] After obtaining the target image parameters, the way to adjust the initial processing model can be:
[0166] Use the initial processing model to adjust the numerical value of the image parameter of each image in the first group of sample images to obtain the first group of sample output images;
[0167] Compare the target image parameters with the image parameters of each image in the first group of sample output images, and fuse the differences corresponding to each image to determine the first group of sample losses. For example, sum or take the average of the differences between the image parameter of each image and the target image parameter to obtain the first group of sample losses. The greater the difference between the target image parameters and the image parameters of each image in the first group of sample output images, the greater the first group of sample losses; the smaller the difference, the smaller the first group of sample losses.
[0168] Adjust the second group of sample images with the initial processing model in the same way, and obtain the second group of sample losses based on the second group of sample images and the corresponding target image parameters;
[0169] Fuse the first group of sample losses and the second group of sample losses to obtain the total model loss. For example, the two can be summed, or the average of the two can be taken as the total model loss;
[0170] If the total model loss does not meet the convergence condition, update the model parameters of the initial processing model according to the total model loss. After the update, repeat the above process;
[0171] If the total model loss meets the convergence condition, the initial processing model at this time can be determined as the first processing model;
[0172] Among them, the convergence condition can be that the total model loss is less than or equal to a preset threshold. The method of updating the model parameters can refer to the related technology and will not be elaborated.
[0173] The initial processing model can be the default processing model pre-configured by the relevant manufacturer when the electronic device leaves the factory, or a model with the same model structure as the default processing model and whose model parameters are generated by random filling.
[0174] In some alternative embodiments, the target image parameters corresponding to a set of sample images are obtained by fusing the initial image parameters and parameter weights of each image included in the set of sample images. The initial image parameter of each image is specified by an adjustment instruction for adjusting the image, and the parameter weight of each image is determined based on the initial image parameter of the image.
[0175] When determining the target image parameters in the manner of the above embodiments, for the first set of sample images, the electronic device can obtain the adjustment instructions for each image in the first set to determine the corresponding initial image parameters according to the adjustment instructions for each image. Each adjustment instruction is used to adjust the image parameters of the corresponding image. For example, the adjustment instruction corresponding to image 1 in the first set of sample images can be used to adjust the color temperature of image 1 to 4000K, so the corresponding initial color temperature parameter of image 1 is 4000K. The adjustment instruction corresponding to image 2 can be used to adjust the color temperature of image 2 to 4500K, and the corresponding initial color temperature parameter of image 2 is 4500K.
[0176] Then, the corresponding parameter weights can be set according to the initial image parameters of each image. A higher parameter weight can be configured for a larger value of the initial image parameter, and a lower parameter weight can be configured for a smaller value of the initial image parameter. For example, in the above example, the parameter weight corresponding to image 2 can be 2 / 3, and the parameter weight corresponding to image 1 can be 1 / 3.
[0177] Finally, the initial image parameters of all images in the first set of sample images can be weighted and summed according to the parameter weights, and the result obtained is used as the target image parameter. Combining the above example, the target image parameter of the first set of sample images can be equal to 2 / 3 * 4500K + 1 / 3 * 4000K, approximately 43300K.
[0178] In step S3022, the target image parameters of the first set of sample images can be obtained according to the method of S3021. Then, the initial parameters can be adjusted in the following manner to obtain the first parameter:
[0179] Call the target processing model with the initial parameters to adjust the numerical values of the image parameters of each image in the first set of sample images to obtain the first set of output images;
[0180] Compare the parameters of the target image with the image parameters of each image in the first set of sample output images, and fuse the differences corresponding to each image to determine the first set of sample losses. For example, sum or take the average of the differences between the image parameters of each image and the target image parameters to obtain the first set of sample losses. The greater the difference between the target image parameters and the image parameters of each image in the first set of sample output images, the greater the first set of sample losses; the smaller the difference, the smaller the first set of sample losses.
[0181] Call the target processing model with the initial parameters in the same way to adjust the second set of sample images, and obtain the second set of sample losses based on the second set of sample images and the corresponding target image parameters.
[0182] Fuse the first set of sample losses and the second set of sample losses to obtain the total parameter loss. For example, the two can be summed, or the average of the two can be taken as the total parameter loss.
[0183] If the total parameter loss does not meet the convergence condition, update the initial parameters according to the total parameter loss, and repeat the above process after the update.
[0184] If the total parameter loss meets the convergence condition, the initial parameters at this time can be determined as the first parameters.
[0185] Among them, the convergence condition can be that the total parameter loss is less than or equal to a preset threshold.
[0186] The method of updating the initial parameters can be:
[0187] If the total parameter loss is greater than 0, it means that the image parameters of the sample output images are generally smaller than the target image parameters. At this time, the initial parameters can be appropriately increased, and the increase amplitude is positively correlated with the absolute value of the total parameter loss.
[0188] If the total parameter loss is less than 0, it means that the image parameters of the sample output images are generally greater than the target image parameters. At this time, the initial parameters can be appropriately decreased, and the decrease amplitude is positively correlated with the absolute value of the total parameter loss.
[0189] Among them, the initial parameters can be the aforementioned pre-configured default parameters or randomly generated random parameters.
[0190] In the case of generating the first processing strategy according to the above method, the first range corresponding to the first processing strategy can be determined according to the multiple sets of sample images used.
[0191] Exemplarily, it is assumed that 4 sets of sample images are used to generate the first processing strategy. Each set of sample images contains N images, totaling 4N images. Each image corresponds to an initial image parameter. After generating the first processing strategy, the maximum value among the 4N initial image parameters can be used as the upper limit of the first range, and the minimum value among the 4N initial image parameters can be used as the lower limit of the first range.
[0192] The advantage of generating the first processing strategy according to the above method is that:
[0193] According to the above method, the image parameters of the processed image obtained based on the first processing strategy can approach the target image parameters determined according to the user's adjustment instruction. Obviously, the target image parameters determined according to the user's adjustment instruction can represent the specific preferences of the user. For example, it can represent the color temperature or hue preferred by the user. Thus, generating the first processing strategy according to the above method can make the image parameters of the processed image obtained based on the first processing strategy more in line with the user's preferences, thereby meeting the personalized needs of specific users.
[0194] This embodiment also provides an electronic device. Please refer to Figure 4 and this electronic device may include:
[0195] A memory 401 for storing computer programs;
[0196] A processor 402 for executing the computer program to perform the following image processing method:
[0197] In response to obtaining an image to be processed, determine a target processing strategy between the first processing strategy and the second processing strategy;
[0198] Adjust the value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image;
[0199] Among them, the values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different, and the first processing strategy and the second processing strategy are used to adjust the same kind of image parameters.
[0200] Optionally, the processor 402 in response to obtaining an image to be processed includes:
[0201] In response to obtaining the image to be processed collected by the image acquisition device;
[0202] The processor 402 can also be used for:
[0203] Display the processed image to the target interface; the target interface is used for the user to preview the image processed by the image acquisition device based on the target processing strategy.
[0204] Optionally, when the first range corresponding to the first processing strategy matches the image parameters of the image to be processed, the target processing strategy is the first processing strategy;
[0205] When the second range corresponding to the second processing strategy matches the image parameters of the image to be processed, the target processing strategy is the second processing strategy;
[0206] The first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
[0207] Optionally, if the image parameters of the first processing result match the second range, the target processing strategy is the second processing strategy, and the first processing result is the processing result obtained by processing the image to be processed according to the first processing strategy;
[0208] If the image parameters of the first processing result match the first range, the target processing strategy is the first processing strategy, and the first processing result is used as the processed image;
[0209] Or,
[0210] If the image parameters of the second processing result match the first range, the target processing strategy is the first processing strategy, and the second processing result is the processing result obtained by processing the image to be processed according to the second processing strategy;
[0211] If the image parameters of the second processing result match the second range, the target processing strategy is the second processing strategy, and the second processing result is used as the processed image;
[0212] Wherein, the first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
[0213] Optionally, the first processing strategy includes calling a first processing model to process the image to be processed, and the second processing strategy includes calling a second processing model to process the image to be processed;
[0214] Or, the first processing strategy includes calling the target processing model with the first parameter, and the second processing strategy includes calling the target processing model with the second parameter.
[0215] Optionally, the model parameters of the first processing model are determined according to multiple groups of sample images and the target image parameters corresponding to each group of sample images;
[0216] Each group of sample images corresponds to a type of scene information, and the scene information corresponding to different groups of sample images is different. The target image parameters are determined according to the adjustment instructions for adjusting the image parameters of the corresponding sample images.
[0217] Optionally, the target image parameters corresponding to a set of sample images are obtained by fusing the initial image parameters of each image included in the set of sample images and the parameter weights. The initial image parameter of each image is specified by an adjustment instruction for adjusting the image, and the parameter weight of each image is determined based on the initial image parameter of the image.
[0218] Optionally, if the target processing strategy is the first processing strategy, when the processor 402 processes the image to be processed according to the target processing strategy to obtain the processed image, it can be used for:
[0219] Inputting the image to be processed into the target processing model with a first parameter to obtain the processed image;
[0220] If the target processing strategy is the second processing strategy, when the processor 402 processes the image to be processed according to the target processing strategy to obtain the processed image, it can be used for:
[0221] Inputting the image to be processed into the target processing model with a second parameter to obtain the processed image.
[0222] Optionally, the image parameters include at least one of a color temperature parameter and a hue parameter.
[0223] For the working principle of the above electronic device, reference can be made to the relevant steps in the image processing method and the method for generating a processing strategy provided in the foregoing embodiments, which will not be elaborated herein.
[0224] It should be noted that the various embodiments in this specification are all described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other.
[0225] For the convenience of description, when describing the above system or device, it is divided into various modules or units according to functions for description. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0226] From the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present application.
[0227] Finally, it should also be noted that in this text, relational terms such as first, second, third, and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0228] The above are only the preferred embodiments of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. An image processing method, comprising: Determining a target processing strategy between a first processing strategy and a second processing strategy in response to obtaining an image to be processed; Adjusting the numerical value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image; Wherein, the numerical values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different, and the first processing strategy and the second processing strategy are used to adjust the same kind of image parameters.
2. The method according to claim 1, wherein the step of responding to obtaining an image to be processed includes: Responding to obtaining the image to be processed collected by an image acquisition device; It further includes: Displaying the processed image on a target interface; The target interface is used for a user to preview the image obtained by processing the image acquisition device based on the target processing strategy.
3. The method according to claim 1, when the first range corresponding to the first processing strategy matches the image parameters of the image to be processed, the target processing strategy is the first processing strategy; When the second range corresponding to the second processing strategy matches the image parameters of the image to be processed, the target processing strategy is the second processing strategy; The first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
4. The method according to claim 1, if the image parameters of the first processing result match the second range, the target processing strategy is the second processing strategy, and the first processing result is the processing result obtained by processing the image to be processed according to the first processing strategy; If the image parameters of the first processing result match the first range, the target processing strategy is the first processing strategy, and the first processing result is used as the processed image; Or, If the image parameters of the second processing result match the first range, the target processing strategy is the first processing strategy, and the second processing result is the processing result obtained by processing the image to be processed according to the second processing strategy; If the image parameters of the second processing result match the second range, the target processing strategy is the second processing strategy, and the second processing result is used as the processed image; Wherein, the first range represents the range of image parameters of the image obtained according to the first processing strategy, and the second range represents the range of image parameters of the image obtained according to the second processing strategy.
5. The method according to claim 1, the first processing strategy includes calling a first processing model to process the image to be processed, and the second processing strategy includes calling a second processing model to process the image to be processed; Or, the first processing strategy includes calling a target processing model with a first parameter, and the second processing strategy includes calling the target processing model with a second parameter.
6. The method according to claim 5, the model parameters of the first processing model are determined according to multiple groups of sample images and the target image parameters corresponding to each group of the sample images; Each group of the sample images corresponds to a kind of scene information, and the scene information corresponding to different groups of sample images is different. The target image parameters are determined according to the adjustment instructions for adjusting the image parameters of the corresponding sample images.
7. The method according to claim 6, wherein the target image parameters corresponding to a group of the sample images are obtained by fusing the initial image parameters and parameter weights of each image included in the group of sample images. The initial image parameter of each image is specified by the adjustment instruction for adjusting the image, and the parameter weight of each image is determined based on the initial image parameter of the image.
8. The method according to claim 5, if the target processing strategy is the first processing strategy, the adjusting the numerical value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image includes: Inputting the image to be processed into the target processing model with the first parameter to obtain the processed image; If the target processing strategy is the second processing strategy, the adjusting the numerical value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image includes: Inputting the image to be processed into the target processing model with the second parameter to obtain the processed image.
9. The method according to claim 1, wherein the image parameters include at least one of a color temperature parameter and a hue parameter.
10. An electronic device, comprising: a memory for storing a computer program; a processor for executing the computer program to perform the following image processing method: Determining a target processing strategy between a first processing strategy and a second processing strategy in response to obtaining an image to be processed; Adjusting the numerical value of the image parameters of the image to be processed according to the target processing strategy to obtain a processed image; wherein the numerical values of the image parameters of the image obtained according to the first processing strategy and the image obtained according to the second processing strategy are different, and the first processing strategy and the second processing strategy are used to adjust the same kind of image parameters.