Image processing method and related device

By reducing the reliability of weak texture sub-regions to prevent them from affecting focus accuracy during focusing, image processing methods and devices are used to solve the focus problem when shooting with electronic devices, thus improving the user experience.

CN119277202AActive Publication Date: 2025-01-07HONOR DEVICE CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410176103.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-07
Publication Date
2025-01-07
Estimated Expiration
2044-02-07

AI Technical Summary

Technical Problem

When shooting with electronic devices, focus pull often occurs, causing images or videos to be out of focus and affecting the user experience.

Method used

By reducing the confidence level of weak texture sub-regions, electronic devices are prevented from using their phase differences for focusing, thereby improving focusing accuracy. Image processing methods and devices, including a focusing algorithm module, are used to filter out sub-regions with high confidence level for focusing.

Benefits of technology

It improves the focusing accuracy of electronic devices, increases the likelihood of users obtaining in-focus images, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119277202A_ABST
    Figure CN119277202A_ABST
Patent Text Reader

Abstract

The invention provides an image processing method and a related device, and relates to the technical field of terminals. The method comprises the following steps: acquiring a first image frame; when it is judged that the weak texture sub-region exists in the focusing region of the first image frame, the credibility of the weak texture sub-region is reduced; based on the phase difference of the focusing area, the motor is driven to adjust the position of the lens of the electronic equipment, the phase difference is obtained based on respective target phase differences of part or all of the sub-areas in the focusing area, and the credibility values of the respective target phase differences of all or part of the sub-areas are greater than or equal to a preset threshold value; part or all of the sub-regions do not comprise weak texture sub-regions. Therefore, the focusing accuracy of the electronic equipment is improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to an image processing method and related devices. Background Art

[0002] In people's daily lives, it has become a common phenomenon to use the shooting functions of electronic devices such as mobile phones and smart watches to record life anytime and anywhere. The shooting function of electronic devices has added a lot of fun to people's lives.

[0003] However, at present, when people use the shooting function of electronic devices, a focus pulling phenomenon may occur, that is, the image or video taken may not be in focus, which seriously affects the user experience. Summary of the invention

[0004] The embodiments of the present application provide an image processing method and related devices, which are helpful for avoiding electronic devices from focusing through phase differences in weak texture sub-regions, improving the focusing accuracy of electronic devices, and helping users obtain in-focus images, thereby improving user experience.

[0005] In a first aspect, an embodiment of the present application proposes an image processing method, which is applied to an electronic device, and the method includes: acquiring a first image frame; when it is determined that a weak texture sub-region exists in a focus area of ​​the first image frame, reducing the credibility of the weak texture sub-region; based on the phase difference of the focus area, driving a motor to adjust the position of the electronic device lens, the phase difference is obtained based on the target phase difference of each of some or all of the sub-regions in the focus area, the credibility values ​​of the target phase differences of all or some of the sub-regions are greater than or equal to a preset threshold, and the some or all of the sub-regions do not include the weak texture sub-region.

[0006] It should be understood that the credibility of the weak texture sub-region refers to the credibility of the target phase difference of the weak texture sub-region. The focus area of ​​the first image frame includes multiple sub-regions, and the phase difference of the focus area can be the smallest target phase difference among one or more target phase differences corresponding to one or more sub-regions whose credibility value of the target phase difference is greater than or equal to a preset threshold.

[0007] Optionally, the preset threshold may be 500 or any other value, the size of the focus area may be 0.4*0.4 or 0.3*0.3, the focus area may be the center area of ​​the image, and the focus area may include 9 sub-areas, but this application is not limited to this.

[0008] In an embodiment of the present application, when it is determined that a weak texture sub-region exists in the focus area of ​​the first image frame, the credibility of the weak texture sub-region is reduced. This is beneficial to avoid the electronic device focusing through the phase difference of the weak texture sub-region, which is beneficial to improving the focusing accuracy of the electronic device, and is beneficial for the user to obtain an in-focus image, thereby improving the user experience.

[0009] In combination with the first aspect, in certain implementations of the first aspect, the texture sub-region satisfies one or more of the following: the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold; or, the minimum value of the sum of the absolute values ​​of the differences SAD corresponding to the weak texture sub-region is greater than a second threshold, and the weak texture sub-region includes multiple SAD values, and the multiple SAD values ​​are obtained based on a left image in the weak texture sub-region and a right image in the weak texture sub-region.

[0010] Optionally, the first threshold may be 1, and the second threshold may be 1000, but this application is not limited to this.

[0011] It should be understood that the weak texture sub-region does not have sufficient texture features to support the target phase difference and SAD calculation, and there may be a situation where the target phase difference value is too high and / or the minimum SAD value is too high. Therefore, in the embodiment of the present application, the sub-region whose absolute value of the target phase difference is greater than the first threshold, and / or the minimum value of the sum of the absolute values ​​of the difference SAD is greater than the second threshold is determined to be a weak texture sub-region. In this way, the weak texture sub-region can be processed to reduce its credibility. Furthermore, after reducing the credibility of the weak texture sub-region, the possibility of using the target phase difference of the weak texture sub-region as the phase difference used for focusing can be reduced, which is beneficial to improving focusing accuracy and improving user experience.

[0012] In combination with the first aspect, in some implementations of the first aspect, the method further includes: selecting a first left image that matches a preset window size from the left image in the weak texture sub-area, and selecting a first right image that matches the preset window size from the right image in the weak texture sub-area, adding the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the first right image to obtain a first SAD value, wherein the multiple SAD values ​​of the weak texture sub-area include the first SAD value, the first left image and the first right image are respectively collected through the left pixel and the right pixel of the same pixel area of ​​the electronic device, and the first phase difference between the first left image and the first right image is zero; offsetting the preset window to the left by N pixels from the position of the first right image to obtain a second right image, and adding the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the second right image, A second SAD value is obtained, wherein the multiple SAD values ​​of the weak texture sub-region include the second SAD value, and the second phase difference between the first left image and the second right image is negative N; the preset window is offset M pixels to the right from the position of the first right image to obtain a third right image, and the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the third right image is added to obtain a third SAD value, wherein the multiple SAD values ​​of the weak texture sub-region include the third SAD value, and the third phase difference between the first left image and the third right image is M; based on the first SAD value and the first phase difference corresponding to the first SAD value, the second SAD value and the second phase difference corresponding to the second SAD value, and the third SAD value and the third phase difference corresponding to the third SAD value, a SAD curve with phase difference as the independent variable and SAD value as the dependent variable is obtained.

[0013] Optionally, M and N may be any value greater than zero, which is not limited in this application.

[0014] In one possible implementation, before the left image in the weak texture sub-region and the right image in the weak texture sub-region are converted into the SAD curve, the left image array and the right image array may be preprocessed, and the preprocessing method may be mean-std normalization, but this application is not limited to this.

[0015] In combination with the first aspect, in some implementations of the first aspect, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region is greater than a second threshold, based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, a second coefficient, and a third coefficient to obtain the credibility of the weak texture sub-region; wherein the first coefficient is a preset constant, the second coefficient is related to the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value, and the third coefficient is related to the target phase difference of the weak texture sub-region.

[0016] In combination with the first aspect, in some implementations of the first aspect, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, the second coefficient, and the third coefficient are obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, the second coefficient, and the third coefficient. Obtaining the credibility of the weak texture sub-region includes: The minimum value c0, the SAD value a1 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value a2 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, the second coefficient e2, and the third coefficient e3. When a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0017]

[0018] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0019]

[0020] Among them, the second coefficient e2 is the reciprocal of the minimum value of the sum of the absolute values ​​of the differences SAD value corresponding to the weak texture sub-region, and the third coefficient e3 is the reciprocal of the integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

[0021] It should be understood that the second coefficient and the third coefficient are both values ​​greater than 0 and less than 1.

[0022] In an embodiment of the present application, when calculating the credibility of the target phase difference of a weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying the second coefficient and the third coefficient. In this way, when the sub-regions in the focus area are subsequently screened based on the sub-region credibility values, the probability of the weak texture sub-region being selected can be reduced, which is beneficial to avoiding the target phase difference of the weak texture sub-region from being used as the phase difference used when focusing the electronic device, and is beneficial to improving the focusing accuracy and stability.

[0023] In combination with the first aspect, in certain implementations of the first aspect, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD value) is less than or equal to a second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, and a third coefficient; wherein the first coefficient is a preset constant, and the third coefficient is related to the target phase difference of the weak texture sub-region.

[0024] In combination with the first aspect, in some implementations of the first aspect, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the third coefficient, including: based on the SAD value The minimum value c0 of the SAD value curve, the SAD value a1 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value a2 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the third coefficient e3. When a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0025]

[0026] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0027]

[0028] The third coefficient e3 is the reciprocal of the integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

[0029] In an embodiment of the present application, when the absolute value of the target phase difference of the weak texture sub-region is greater than the first threshold, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD) is less than or equal to the second threshold, when calculating the credibility of the target phase difference of the weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying it by the third coefficient without multiplying it by the second coefficient. This is beneficial to reducing the calculation complexity of the electronic device, and is also beneficial to reducing the probability of the weak texture sub-region being selected when subsequently screening each sub-region in the focus area based on the sub-region credibility value. It is beneficial to avoid the target phase difference of the weak texture sub-region as the phase difference used when the electronic device focuses, and is beneficial to improving the focusing accuracy and stability.

[0030] In combination with the first aspect, in certain implementations of the first aspect, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD) is greater than a second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, and a second coefficient; wherein the first coefficient is a preset constant, and the second coefficient is related to the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD).

[0031] In combination with the first aspect, in some implementations of the first aspect, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the second coefficient, including: based on the SAD value The minimum value c0 of the SAD value curve, the SAD value a1 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value a2 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the second coefficient e2. When a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0032]

[0033] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0034]

[0035] The second coefficient e2 is the reciprocal of the minimum value of the sum of the absolute values ​​of the differences SAD corresponding to the weak texture sub-region.

[0036] In an embodiment of the present application, when the absolute value of the target phase difference of the weak texture sub-region is greater than the first threshold, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD) is greater than the second threshold, when calculating the credibility of the target phase difference of the weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying it by the second coefficient without multiplying it by the third coefficient. This is beneficial to reducing the calculation complexity of the electronic device, and is also beneficial to reducing the probability of the weak texture sub-region being selected when subsequently screening each sub-region in the focus area based on the sub-region credibility value. It is beneficial to avoid the target phase difference of the weak texture sub-region as the phase difference used when the electronic device focuses, and is beneficial to improving the focusing accuracy and stability.

[0037] In a second aspect, an embodiment of the present application provides an image processing device, which may be an electronic device, or a chip or chip system in an electronic device. The image processing device may include a processing unit. When the image processing device is an electronic device, the processing unit may be a processor. The image processing unit executes the instructions stored in the storage unit so that the electronic device implements an image processing method described in the first aspect or any possible implementation of the first aspect. When the image processing device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements an image processing method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit in the chip (e.g., a register, a cache, etc.), or a storage unit in the electronic device located outside the chip (e.g., a read-only memory, a random access memory, etc.).

[0038] In a third aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and a memory, wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes the method described in the first aspect or any possible implementation of the first aspect.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.

[0040] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code runs on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.

[0041] In a sixth aspect, the present application provides a chip or a chip system, which includes one or more processors and a communication interface, wherein the communication interface and the one or more processors are interconnected by lines, and the one or more processors are used to run computer programs or instructions to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.

[0042] In a possible implementation, the chip or chip system described above in the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).

[0043] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A schematic diagram of an interface of an electronic device provided in an embodiment of the present application;

[0045] Figure 2 A schematic diagram of a focus area provided in an embodiment of the present application;

[0046] Figure 3 A hardware structure block diagram of an electronic device provided in an embodiment of the present application;

[0047] Figure 4 A software structure block diagram of an electronic device provided in an embodiment of the present application;

[0048] Figure 5 A schematic flow chart of an image processing method provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of pixel arrangement of an electronic device provided in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of a SAD calculation process provided in an embodiment of the present application;

[0051] Figure 8A schematic diagram of a SAD curve provided in an embodiment of the present application;

[0052] Fig. 9 A schematic flow chart of another image processing method provided in an embodiment of the present application;

[0053] Fig.10 A schematic diagram of a chip structure provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:

[0055] 1. Other terms

[0056] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0057] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0058] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.

[0059] 2. Electronic equipment

[0060] The electronic device of the embodiment of the present application may include a handheld device with a shooting function, a vehicle-mounted device, etc. For example, some electronic devices are: mobile phones, tablet computers, PDAs, laptop computers, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, electronic devices in 5G networks or future evolved public land mobile communication networks (public landmobile networks). The electronic devices in the network (PLMN) and the like are not limited to this in the embodiments of the present application.

[0061] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

[0062] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.

[0063] The electronic device in the embodiments of the present application may also be referred to as: electronic device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.

[0064] In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0065] In people's daily lives, it has become a common phenomenon to use the shooting functions of electronic devices such as mobile phones and smart watches to record life anytime and anywhere. The shooting function of electronic devices has added a lot of fun to people's lives.

[0066] For example, Figure 1 This is an applicable scenario of the embodiment of the present application. In some implementations, the user can enter the camera application on the electronic device by clicking on the camera application on the electronic device. Figure 1 The interface 101 shown is used to capture images through the camera of the electronic device. The target object can be displayed in the interface 101, and the user can obtain the image of the target object by clicking the photo control 102. It should be understood that when the electronic device is shooting the target object, the electronic device will focus based on the captured image frame so that the user can preview or obtain a clear picture by clicking the photo control.

[0067] In some possible implementations, the electronic device uses a center focus method to focus. Figure 2The focus area of ​​the camera application is shown as an example. Figure 2 As shown, the central area 201 of the camera application preview frame may be the focus area during the camera application shooting process. The central area 201 may be divided into several sub-windows, for example Figure 2 In some implementations, the electronic device obtains the phase detection (PD) value of each sub-window and the confidence (Conf) value for judging whether the phase difference is credible, excludes the sub-windows with Conf values ​​lower than a certain threshold, selects the sub-window with the smallest PD value from the remaining sub-windows, and focuses based on the PD value corresponding to the sub-window. However, in some weak texture, low contrast or dark light scenes, the electronic device cannot capture images with sufficient texture features, but the weak texture sub-window in the central area of ​​the camera application may still show a high degree of credibility. If the sub-window is mistakenly used by the electronic device for focusing, it may cause focus pulling, making it difficult for users to get clear pictures, seriously affecting the user experience.

[0068] In view of this, the present application provides an image processing method and related devices, which, by reducing the credibility of weak texture sub-regions, are helpful in avoiding electronic devices from focusing through phase differences in weak texture sub-regions, are helpful in improving the focusing accuracy of electronic devices, are helpful for users to obtain in-focus images, and enhance user experience.

[0069] In order to better understand the embodiments of the present application, the electronic device involved in the embodiments of the present application is introduced below. Figure 3 This is a schematic diagram of the structure of the electronic device 300 provided in the embodiment of the present application. It should be understood that Figure 3 The structure shown is only exemplary and does not constitute a specific limitation on the structure of the electronic device.

[0070] The electronic device 300 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, an earphone interface 170D, a sensor module 180, a button 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, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light 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.

[0071] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0072] In the embodiment of the present application, the electronic device 300 can realize the shooting function through the camera 193 and display it through the display screen 194.

[0073] In some possible implementations, the camera 193 includes a lens, a motor, an image sensor, an image processor, and the like. Furthermore, the image sensor may also include a microlens array, a filter, a pixel array, an optoelectronic signal converter, and other structures.

[0074] When a user takes a picture through the camera application, light is transmitted to the image sensor through the lens, and the light signal is converted into an electrical signal. The image sensor transmits the electrical signal to the image processor for processing. The image processor converts the electrical signal into a digital image signal and transmits it to the display screen 194 for image display.

[0075] Optionally, the image sensor may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor, which is not specifically limited in the present application.

[0076] Figure 4 A software structure block diagram of the electronic device 300 provided in an embodiment of the present application.

[0077] The software system of the electronic device 300 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a microservice architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 300. The layered architecture divides the software into several layers, each of which has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system can be divided into five layers, which are, from top to bottom, the application layer (applications), the application framework layer (application framework), the hardware abstraction layer (hardwareabstraction layer, HAL), the kernel layer (kernel) and the hardware layer.

[0078] The application layer may include a series of application packages, and the application layer runs the application by calling the application programming interface (API) provided by the application framework layer. In the embodiment of the present application, the application layer may include at least applications such as a camera and a gallery. The electronic device 300 may respond to the user's operation of the camera application to implement functions such as taking pictures and recording videos, and the pictures and videos taken by the user may be viewed through the gallery.

[0079] Understandably, Figure 4 What is shown in the figure are some applications. In fact, the application layer can also include other applications, which is not limited in this application. For example, the application layer also includes information, alarm, weather, stopwatch, compass, timer, flashlight, calendar and other applications, which is not limited in this application.

[0080] The application framework layer provides an API and a programming framework for the application of the application layer. The application framework layer includes some predefined functions. In an embodiment of the present application, the application framework layer may include a camera access interface. Among them, the camera access interface can be used to provide an application programming interface and a programming framework for the camera application.

[0081] The HAL layer may include at least a camera hardware abstraction layer and a camera algorithm library. The camera hardware abstraction layer may provide virtual hardware for the camera device; the camera algorithm library may include operating codes and data for implementing the phase detection and credibility calculation provided by the embodiment of the present application, such as a focus algorithm module.

[0082] In an embodiment of the present application, after the focusing algorithm module obtains the lens defocus amount corresponding to the motor (which can be understood as the distance that the objective lens assembly of the camera needs to move), the distance that the motor needs to move can be sent to the motor driver so that the motor driver drives the motor to reach the quasi-focus position.

[0083] The kernel layer is a layer between hardware and software. In the embodiment of the present application, the kernel layer may include at least a camera device driver and a motor driver, etc. The camera device driver is used for the sensor to collect images. The motor driver is used to drive the motor to move the lens assembly of the camera.

[0084] The hardware layer may include: sensors, such as image acquisition sensors, which can also be understood as cameras, image signal processors (ISP), and motors such as voice coil motors (VCM).

[0085] It should be understood that in some embodiments, the layers implementing the same function may be called by other names, or the layers that can implement the functions of multiple layers may be regarded as one layer, or the layers that can implement the functions of multiple layers may be divided into multiple layers. The embodiments of the present application are not limited to this.

[0086] Next, combine Figure 4 The software architecture shown in Figure 5 An image processing method 500 provided by an embodiment of the present application is shown from the perspective of interaction between various modules. The method 300 can be applied to Figure 3 The software structure of the electronic device 300 shown in FIG. Figure 4 As shown, the specific forms and usage scenarios of the electronic devices shown in the embodiments shown in this application are only examples and should not constitute any limitation on the implementation of the methods provided in this application.

[0087] It should be noted that the "focusing" involved in the subsequent description of the embodiments of the present application refers to adjusting the distance between the lens (convex lens or convex lens group) in the camera of the electronic device and the image sensor so that the image sensor continues to remain on the focal plane formed after the reflected light of the moving object is focused by the lens, which is conducive to making the image of the moving object seen by the user on the display screen of the electronic device a clear image.

[0088] It should also be understood that a possible scenario used in the embodiments of the present application is that when a user takes a photo of a target object using an electronic device, the photographed target object and the electronic device are in a relatively static state, but the present application does not impose any limitation on the usage scenario.

[0089] The method 500 comprises the following steps:

[0090] In response to the user's operation of opening the camera application, the electronic device executes S501 and subsequent steps.

[0091] S501: A camera application transmits a start instruction to an image sensor, where the instruction is used to instruct the image sensor to capture an image.

[0092] In a possible implementation, the camera application calls a camera access interface of the application framework layer, and calls a camera device driver of the camera hardware abstraction layer at the kernel layer through the camera access interface, so as to start the image sensor through the camera device driver.

[0093] Optionally, the user's operation of opening the camera application may be, for example, an operation of clicking a camera application icon, or an operation of waking up an intelligent voice assistant and opening the camera application using a voice command, which is not limited in this application.

[0094] It should be understood that the camera access interface can convert instructions from the application layer into instructions that can be recognized by the hardware abstraction layer, and the camera application can send the instruction to start the camera to the camera device driver of the kernel layer by calling the camera hardware abstraction layer. The camera device driver can drive the corresponding camera sensor to collect images.

[0095] S502: The image sensor collects images and generates RAW images.

[0096] It should be understood that the process of image sensor capturing images can be understood as the process of exposing the pixel array of the image sensor. After the pixel array of the image sensor is exposed, the sensor generates a frame of image. The image captured by the sensor and not processed by the image signal processor can be called a RAW image.

[0097] S503: The sensor transmits the RAW image to the focus algorithm module.

[0098] S504, the focus algorithm module obtains a left image array and a right image array of each sub-window in the focus area based on the RAW image data, and preprocesses the left image array and the right image array to obtain a preprocessed left image array and a preprocessed right image array.

[0099] In some implementations, a pixel array of an image sensor of an electronic device includes a phase detection pixel (PD pixel), Figure 6The arrangement of phase detection pixels is shown as an example. Figure 6 As shown, every two rows and four columns form a PD point, which includes 8 pixel blocks. For each pixel block, it can be divided into a left pixel and a right pixel, that is, the photosensitive area (i.e., the photodiode) at the bottom of the same pixel is divided into two, and the phase information can be captured in the same pixel. Optionally, the phase information acquisition method of the present application can be called dual PD or 2PD, or Sparse PD, which is not limited in the present application. For example Figure 6 The pixel block R0 shown in the figure can be divided into a left pixel R_L and a right pixel R_R. During the exposure process of the image sensor pixel array, the pixel block R0 can obtain a left pixel value R_L0 and a right pixel value R_R0. The same is true for other pixel blocks, which will not be repeated. In this way, a PD point can obtain a left pixel value Y_L and a right pixel value Y_R. Taking the left pixel value Y_L as an example, its calculation formula can be: Y_L=a*((R_L0+R_L1) / 2)+b*((Gr_L0+Gr_L1+Gb_L0+Gb_L1) / 4)+c*((B_L0+B_L1) / 2), where a, b, and c are fixed coefficients, and R_L0, R_L1, Gr_L0, Gr_L1, Gb_L0, Gb_L1, B_L0, and B_L1 are the left pixel values ​​corresponding to the 8 pixel blocks in the figure. It should be understood that Y_R can also be calculated using a similar formula, which will not be described in detail.

[0100] It should be understood that the RAW image data may include Y_L data and Y_R data corresponding to each PD point. For each target area (focus area or a subwindow in the focus area), the array composed of Y_L data can be called the left image array, and the array composed of Y_R data can be called the right image array.

[0101] In one possible implementation, the focus algorithm module may preprocess the left image array and the right image array by mean-std normalization, but the present application does not limit this. Preprocessing the left image array and the right image array may remove noise in the array and improve the accuracy of the phase difference calculation result.

[0102] The pixel values ​​described in the embodiments of the present application may be understood as grayscale values.

[0103] Optionally, when transmitting Y_L (Y_R), Y_L (Y_R) may include 10 bits, and the bit data transmission range is 0-1023. In a possible implementation, Y_L (Y_R) may have an offset value of 64, so its range may also be 64-1023, but this application does not make specific limitations on this.

[0104] S505, the focus algorithm module processes the preprocessed left image array and the preprocessed right image array of each sub-window in the focus area based on the stereo matching (sum of absolute differences, SAD) algorithm to obtain a SAD curve corresponding to each sub-window.

[0105] For example, Figure 2 Taking the left image data and the right image data corresponding to the sub-window 1 shown in the figure as an example, the method for obtaining the SAD curve corresponding to the sub-window 1 is described in detail.

[0106] It should be understood that the left image array and the right image array of the sub-window 1 can be intercepted from the entire RAW image frame. In some implementations, a portion of the right image array can be intercepted (search range). Figure 7 The left image array and the right image array of sub-window 1 are shown as examples. Figure 7 As shown, the left image array selected by window 701 and the right image array selected by window 702 are the left pixel value array and the right pixel value array corresponding to the same part of the PD points in subwindow 1. The sum of the absolute values ​​after the corresponding subtraction of the data in window 701 and the data in window 702 is taken as the SAD value 80 when the PD value is 0. Further, window 702 is shifted left by one pixel to the position of window 703 within the search range, and then the sum of the absolute values ​​after the corresponding subtraction of the data in window 701 and the data in window 703 is taken as the SAD value 100 when the PD value is -1. Similarly, by shifting window 702 left or right, the SAD value corresponding to each whole point in the PD value range [-6, 6] can be obtained, and the SAD curve is obtained by drawing with the PD value as the horizontal coordinate and the SAD value as the vertical coordinate, as shown Figure 8 shown.

[0107] S506. The focusing algorithm module calculates the PD value of each sub-window based on the minimum value of the SAD curve in each sub-window, the PD value corresponding to the minimum value of the SAD curve, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, and the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1.

[0108] by Figure 8 Taking the SAD curve shown as an example, in a possible implementation, the PD value of sub-window 1 can be calculated according to the minimum value c0 of the SAD curve in sub-window 1, the PD value x corresponding to the minimum value of the SAD curve, the SAD value a1 corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, and the SAD value a2 corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, according to the following sub-pixel calculation formula (1): sub .

[0109]

[0110] S507, the focus algorithm module determines whether the absolute value of the sub-window PD value is greater than 1 and whether the minimum value in the SAD curve is greater than 1000. If the absolute value of the sub-window PD value is less than or equal to 1 and the minimum value in the SAD curve is less than or equal to 1000, execute S508; if the absolute value of the sub-window PD value is less than or equal to 1 and the minimum value in the SAD curve is greater than 1000, execute S509; if the absolute value of the sub-window PD value is greater than 1 and the minimum value in the SAD curve is less than or equal to 1000, execute S510; if the absolute value of the sub-window PD value is greater than 1 and the minimum value in the SAD curve is greater than 1000, execute S511.

[0111] S508. The focusing algorithm module calculates the Conf value of the PD value of each sub-window based on the minimum value of the SAD curve in each sub-window, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the two endpoint values ​​of the SAD curve, the area of ​​each sub-window, and the first coefficient.

[0112] Still taking subwindow 1 as the corresponding Figure 8 Taking the SAD curve shown as an example, in a possible implementation, the PD Conf value of subwindow 1 can be calculated according to the minimum value c0 of the SAD curve in subwindow 1, the SAD value a1 corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value a2 corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the left endpoint value c2 and the right endpoint value c1 of the SAD curve, the area area of ​​subwindow 1, and the first coefficient coefficient, to calculate the Conf value of the PD value of each subwindow. The first coefficient is a preset fixed coefficient.

[0113] When a1 is greater than or equal to a2, When a1 is less than a2,

[0114] S509. The focusing algorithm module calculates the Conf value of the PD value of each sub-window based on the minimum value of the SAD curve in each sub-window, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the two endpoint values ​​of the SAD curve, the area of ​​each sub-window, and the first coefficient and the second coefficient.

[0115] In a possible implementation, in this case, the PD Conf value of subwindow 1 can be calculated based on the minimum value c0 of the SAD curve in subwindow 1, the SAD value a1 corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value a2 corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the left endpoint value c2 and the right endpoint value c1 of the SAD curve, the area area of ​​subwindow 1, and the first coefficient coefficient and the second coefficient min_coefficient, to calculate the Conf value of the PD value of each subwindow. Among them, the first coefficient is a preset fixed coefficient, and the second coefficient min_coefficient is 1 / (c0 / 1000).

[0116] When a1 is greater than or equal to a2, When a1 is less than a2,

[0117] S510, the focusing algorithm module calculates the Conf value of the PD value of each sub-window based on the minimum value of the SAD curve in each sub-window, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the two endpoint values ​​of the SAD curve, the area of ​​each sub-window, and the first coefficient and the third coefficient.

[0118] In a possible implementation, in this case, the PD Conf value of subwindow 1 can be calculated based on the minimum value c0 of the SAD curve in subwindow 1, the SAD value a1 corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value a2 corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the left endpoint value c2 and the right endpoint value c1 of the SAD curve, the area area of ​​subwindow 1, and the first coefficient coefficient and the third coefficient pd_value_coefficient, to calculate the Conf value of the PD value of each subwindow. Among them, the first coefficient is a preset fixed coefficient, and the third coefficient pd_value_coefficient is the reciprocal of the absolute value of the PD value of subwindow 1 rounded up.

[0119] When a1 is greater than or equal to a2, When a1 is less than a2,

[0120] S511. The focusing algorithm module calculates the Conf value of the PD value of each sub-window based on the minimum value of the SAD curve in each sub-window, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the two endpoint values ​​of the SAD curve, the area of ​​each sub-window, and the first coefficient, the second coefficient and the third coefficient.

[0121] In a possible implementation, in this case, the PD Conf value of subwindow 1 can be calculated based on the minimum value c0 of the SAD curve in subwindow 1, the SAD value a1 corresponding to the PD value corresponding to the minimum value of the SAD curve minus 1, the SAD value a2 corresponding to the PD value corresponding to the minimum value of the SAD curve plus 1, the left endpoint value c2 and the right endpoint value c1 of the SAD curve, the area area of ​​subwindow 1, and the first coefficient coefficient, the second coefficient min_coefficient, and the third coefficient pd_value_coefficient. The Conf value of the PD value of each subwindow is calculated. Among them, the first coefficient is a preset fixed coefficient, the second coefficient min_coefficient is 1 / (c0 / 1000), and the third coefficient pd_value_coefficient is the reciprocal of the absolute value of the PD value of subwindow 1 rounded up.

[0122] When a1 is greater than or equal to a2,

[0123]

[0124] When a1 is less than a2,

[0125]

[0126] S512, the focusing algorithm module selects sub-windows whose Conf values ​​of the PD values ​​are greater than a preset threshold value from among all sub-windows, and uses the minimum PD value in these sub-windows as the first PD value used when focusing on the frame image captured by the image sensor.

[0127] Optionally, the preset threshold may be 500, but this application does not make any specific limitation to this.

[0128] It should be understood that the PD value used when focusing is the minimum PD value in the sub-window whose Conf value of the PD value in all sub-windows is greater than the preset threshold, which utilizes the near view priority principle.

[0129] S513: The focusing algorithm module determines the lens defocus amount according to the relationship between the first PD value and the lens defocus amount and a defocus conversion coefficient (DDC).

[0130] In a possible implementation, the lens defocus amount=phase difference*DDC, where DDC represents a coefficient of a linear relationship between a driving current of a motor controlling the lens and a moving position of the lens.

[0131] S514: The focus algorithm module transmits the lens defocus amount to the motor driver. Correspondingly, the motor driver receives the lens defocus amount.

[0132] S515: The motor driver transmits the lens defocus amount to the motor. Correspondingly, the motor receives the lens defocus amount.

[0133] S516: The motor moves the lens defocus amount to reach the lens in-focus position.

[0134] In some implementations, the lens defocus amount is indicated by a positive or negative sign to move in a direction, where a negative sign indicates that the lens needs to be closer to the target object, and a positive sign indicates that the lens needs to be farther away from the target object, but this application does not limit this.

[0135] In an embodiment of the present application, since the absolute value of the PD value of the weak texture sub-window is greater than 1 and / or the minimum value in the SAD curve is more likely to be greater than 1000, when calculating the Conf value of the PD value of each sub-window, the absolute value of the PD value of each sub-window and the minimum value in the SAD curve corresponding to each sub-window are judged, and when the absolute value of the PD value of the sub-window is greater than 1 and / or the minimum value in the SAD curve is greater than 1000, different coefficients are respectively corresponding, which is beneficial to reducing the Conf value of the weak texture sub-window, reducing the possibility of the PD value of the weak texture sub-window being the final PD value, avoiding the influence of the weak texture sub-window on the focus of the electronic device, and facilitating rapid focusing and improving user experience.

[0136] Fig. 9 1 is a schematic flow chart of an image processing method 900 provided in an embodiment of the present application. The method 900 can be executed by an electronic device, and its hardware structure can be as follows Figure 3 As shown, the software structure can be as follows Figure 4 As shown, this application does not make any specific limitation to this.

[0137] The method 900 comprises the following steps:

[0138] S901, collecting a first image frame;

[0139] S902, when it is determined that there is a weak texture sub-region in the focus area of ​​the first image frame, reducing the credibility of the weak texture sub-region;

[0140] S903. Based on the phase difference in the focus area, drive the motor to adjust the position of the electronic device lens, where the phase difference is obtained based on the target phase difference of each of some or all sub-areas in the focus area, and the credibility values ​​of the target phase differences of all or some of the sub-areas are greater than or equal to a preset threshold, and some or all of the sub-areas do not include weak texture sub-areas.

[0141] It should be understood that the credibility of the weak texture sub-region refers to the credibility of the target phase difference of the weak texture sub-region. The focus area of ​​the first image frame includes multiple sub-regions, and the phase difference of the focus area can be the smallest target phase difference among one or more target phase differences corresponding to one or more sub-regions whose credibility value of the target phase difference is greater than or equal to a preset threshold.

[0142] Optionally, the preset threshold may be 500 or any other value, the size of the focus area may be 0.4*0.4 or 0.3*0.3, the focus area may be the center area of ​​the image, and the focus area may include 9 sub-areas, but this application is not limited to this.

[0143] In an embodiment of the present application, when it is determined that a weak texture sub-region exists in the focus area of ​​the first image frame, the credibility of the weak texture sub-region is reduced. This is beneficial to avoid the electronic device focusing through the phase difference of the weak texture sub-region, which is beneficial to improving the focusing accuracy of the electronic device, and is beneficial for the user to obtain an in-focus image, thereby improving the user experience.

[0144] As an optional embodiment, the texture sub-region satisfies one or more of the following: the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold; or, the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD is greater than a second threshold, and the weak texture sub-region includes multiple SAD values, and the multiple SAD values ​​are obtained based on the left image in the weak texture sub-region and the right image in the weak texture sub-region.

[0145] Optionally, the first threshold may be 1, and the second threshold may be 1000, but this application is not limited to this.

[0146] It should be understood that the weak texture sub-region does not have sufficient texture features to support the target phase difference and SAD calculation, and there may be a situation where the target phase difference value is too high and / or the minimum SAD value is too high. Therefore, in the embodiment of the present application, the sub-region whose absolute value of the target phase difference is greater than the first threshold, and / or the minimum value of the sum of the absolute values ​​of the difference SAD is greater than the second threshold is determined to be a weak texture sub-region. In this way, the weak texture sub-region can be processed to reduce its credibility. Furthermore, after reducing the credibility of the weak texture sub-region, the possibility of using the target phase difference of the weak texture sub-region as the phase difference used for focusing can be reduced, which is beneficial to improving focusing accuracy and improving user experience.

[0147] As an optional embodiment, the method also includes: selecting a first left image that matches a preset window size from the left image in the weak texture sub-area, selecting a first right image that matches a preset window size from the right image in the weak texture sub-area, adding the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the first right image to obtain a first SAD value, the multiple SAD values ​​of the weak texture sub-area include the first SAD value, the first left image and the first right image are respectively collected by the left pixel and the right pixel of the same pixel area of ​​the electronic device, and the first phase difference between the first left image and the first right image is zero; offsetting the preset window N pixels to the left from the position of the first right image to obtain a second right image, adding the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the second right image to obtain the first SAD value. Two SAD values, the multiple SAD values ​​of the weak texture sub-region include the second SAD value, and the second phase difference between the first left image and the second right image is negative N; the preset window is offset M pixels to the right from the position of the first right image to obtain the third right image, and the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the third right image is added to obtain the third SAD value, the multiple SAD values ​​of the weak texture sub-region include the third SAD value, and the third phase difference between the first left image and the third right image is M; based on the first SAD value and the first phase difference corresponding to the first SAD value, the second SAD value and the second phase difference corresponding to the second SAD value, and the third SAD value and the third phase difference corresponding to the third SAD value, a SAD curve with phase difference as the independent variable and SAD value as the dependent variable is obtained.

[0148] Optionally, M and N may be any value greater than zero, which is not limited in this application.

[0149] It should be understood that the preset window can be moved left or right from the position of the first right image multiple times, the SAD value of the right image and the first left image obtained after each movement is calculated, and the phase difference between the right image and the first left image is recorded as the horizontal and vertical coordinates of the SAD curve.

[0150] In one possible implementation, before the left image in the weak texture sub-region and the right image in the weak texture sub-region are converted into the SAD curve, the left image array and the right image array may be preprocessed, and the preprocessing method may be mean-std normalization, but this application is not limited to this.

[0151] The arrangement of the pixel array of the electronic device in the embodiment of the present application can be as follows: Figure 6 As shown in , the determination of the left image array and the right image array can refer to the description of S504 above, and the specific steps of obtaining the SAD curve can refer to the above description of Figure 7 The description is not repeated here.

[0152] As an optional embodiment, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region is greater than a second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, a second coefficient, and a third coefficient; wherein the first coefficient is a preset constant, the second coefficient is related to the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value, and the third coefficient is related to the target phase difference of the weak texture sub-region.

[0153] In a possible implementation, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, the second coefficient, and the third coefficient, including: based on the minimum value of the SAD value c0, the SAD value a1 corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value a2 corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, the second coefficient e2, and the third coefficient e3, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0154]

[0155] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0156]

[0157] Among them, the second coefficient e2 is the reciprocal of the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value, and the third coefficient e3 is the reciprocal of the integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

[0158] It should be understood that the weak texture sub-region may correspond to the sub-window 1 of the above embodiment, the area A of the weak texture sub-region may be the area area of ​​the sub-window 1 described above, the first coefficient e1 may be the coefficient mentioned above, the second coefficient e2 may be the min_coefficient mentioned above, and the third coefficient e3 may be the pd_value_coefficient mentioned above.

[0159] It should also be understood that the second coefficient and the third coefficient are both values ​​greater than 0 and less than 1.

[0160] In one possible implementation, c2 can be the average of the left endpoint value in the SAD curve and P SAD values ​​close to the left endpoint value, c1 can be the average of the right endpoint value in the SAD curve and P SAD values ​​close to the right endpoint value, P can be 2 or 3, but this application is not limited to this.

[0161] In an embodiment of the present application, when calculating the credibility of the target phase difference of a weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying the second coefficient and the third coefficient. In this way, when the sub-regions in the focus area are subsequently screened based on the sub-region credibility values, the probability of the weak texture sub-region being selected can be reduced, which is beneficial to avoiding the target phase difference of the weak texture sub-region from being used as the phase difference used when focusing the electronic device, and is beneficial to improving the focusing accuracy and stability.

[0162] As an optional embodiment, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region is less than or equal to a second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, and a third coefficient; wherein the first coefficient is a preset constant and the third coefficient is related to the target phase difference of the weak texture sub-region.

[0163] In a possible implementation, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the third coefficient, including: based on the minimum value of the SAD value c0, the SAD value a1 corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value a2 corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the third coefficient e3, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0164]

[0165] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0166]

[0167] The third coefficient e3 is the reciprocal of an integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

[0168] In an embodiment of the present application, when the absolute value of the target phase difference of the weak texture sub-region is greater than the first threshold, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD) is less than or equal to the second threshold, when calculating the credibility of the target phase difference of the weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying it by the third coefficient without multiplying it by the second coefficient. This is beneficial to reducing the calculation complexity of the electronic device, and is also beneficial to reducing the probability of the weak texture region being selected when the sub-regions in the focus area are subsequently screened based on the sub-region credibility values. It is beneficial to avoid the target phase difference of the weak texture sub-region being used as the phase difference used when the electronic device focuses, and is beneficial to improving the focusing accuracy and stability.

[0169] As an optional embodiment, the credibility of the weak texture sub-region is reduced, including: when the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region is greater than a second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, a first coefficient, and a second coefficient; wherein the first coefficient is a preset constant, and the second coefficient is related to the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region.

[0170] In a possible implementation, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the second coefficient, including: based on the minimum value of the SAD value c0, the SAD value a1 corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value a2 corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the second coefficient e2, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0171]

[0172] When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula:

[0173]

[0174] The second coefficient e2 is the reciprocal of the minimum value of the sum of absolute differences SAD corresponding to the weak texture sub-region.

[0175] In an embodiment of the present application, when the absolute value of the target phase difference of the weak texture sub-region is greater than the first threshold, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region (SAD) is greater than the second threshold, when calculating the credibility of the target phase difference of the weak texture sub-region, the credibility value finally obtained by the weak texture sub-region can be reduced by multiplying it by the second coefficient without multiplying it by the third coefficient. This is beneficial to reducing the calculation complexity of the electronic device, and is also beneficial to reducing the probability of the weak texture region being selected when subsequently screening each sub-region in the focus area based on the sub-region credibility value. It is beneficial to avoid the target phase difference of the weak texture sub-region as the phase difference used when the electronic device focuses, and is beneficial to improving the focusing accuracy and stability.

[0176] The image processing method of the embodiment of the present application has been described above, and the device for executing the above method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the relevant device provided by the embodiment of the present application can execute the steps in the above list sorting method.

[0177] Fig.10 The schematic diagram of the structure of a chip provided by the embodiment is exemplarily shown. The chip 1000 includes one or more (including two) processors 1001 , a communication line 1002 , a communication interface 1003 and a memory 1004 .

[0178] In some implementations, the memory 1004 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.

[0179] The method described in the above embodiment of the present application can be applied to the processor 1001, or implemented by the processor 1001. The processor 1001 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware or software instructions in the processor 1001. The above processor 1001 can be a general processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 1001 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.

[0180] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 1004, and the processor 1001 reads the information in the memory 1004 and completes the steps of the above method in combination with its hardware.

[0181] The processor 1001 , the memory 1004 , and the communication interface 1003 may communicate with each other via the communication line 1002 .

[0182] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.

[0183] In the embodiment of the present application, the chip 1000 may also be a chip system, such as a system on chip (SOC), which is not limited in the present application.

[0184] The image processing method provided in the embodiment of the present application can be applied to electronic devices with communication functions. The electronic device includes an electronic device, and the specific device form of the electronic device can refer to the above related description, which will not be repeated here.

[0185] An embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory stores computer program code, and the computer program code includes computer instructions; the one or more processors call the computer instructions to enable the electronic device to execute the method in the above embodiment.

[0186] The embodiment of the present application provides a chip or a chip system. The chip or chip system is applied to an electronic device, and the chip or chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute the method in the above embodiment. Its implementation principle and technical effect are similar to those of the above-mentioned related embodiments, and will not be repeated here.

[0187] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium includes computer instructions. When the computer instructions are run on an electronic device, the electronic device executes the method in the above embodiment. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

[0188] In one possible implementation, a computer readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disk and optical disk as used herein include optical disk, laser disk, optical disk, digital versatile disk (DVD), floppy disk and Blu-ray disk, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer readable media.

[0189] An embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code runs on an electronic device, the electronic device executes the method in the above embodiment.

[0190] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0191] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.

Claims

1. An image processing method, characterized in that: Applied to electronic equipment, the method comprises: Acquiring a first image frame; When it is determined that there is a weak texture sub-region in the focus area of ​​the first image frame, reducing the credibility of the weak texture sub-region; Based on the phase difference of the focusing area, a driving motor adjusts the position of the electronic device lens, wherein the phase difference is obtained based on the target phase difference of each of some or all of the sub-areas in the focusing area, and the credibility values ​​of the target phase differences of all or some of the sub-areas are greater than or equal to a preset threshold, and the some or all of the sub-areas do not include the weak texture sub-area.

2. The method according to claim 1, characterized in that The texture sub-region satisfies one or more of the following: The absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold; or, The minimum value of the sum of the absolute values ​​of the differences SAD corresponding to the weak texture sub-region is greater than a second threshold, and the weak texture sub-region includes multiple SAD values, and the multiple SAD values ​​are obtained based on the left image in the weak texture sub-region and the right image in the weak texture sub-region.

3. The method according to claim 2, characterized in that The method further comprises: Selecting a first left image that matches a preset window size from the left image in the weak texture sub-region, and selecting a first right image that matches the preset window size from the right image in the weak texture sub-region, adding the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the first right image to obtain a first SAD value, wherein the first SAD value is included in the plurality of SAD values ​​of the weak texture sub-region, the first left image and the first right image are respectively collected through the left pixel and the right pixel of the same pixel region of the electronic device, and the first phase difference between the first left image and the first right image is zero; The preset window is shifted N pixels to the left from the position of the first right image to obtain a second right image, and the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the second right image is added to obtain a second SAD value, wherein the multiple SAD values ​​of the weak texture sub-region include the second SAD value, and the second phase difference between the first left image and the second right image is negative N; The preset window is shifted rightward by M pixels from the position of the first right image to obtain a third right image, and the absolute value of the difference between the grayscale values ​​corresponding to each pixel in the first left image and the third right image is added to obtain a third SAD value, wherein the plurality of SAD values ​​of the weak texture sub-region include the third SAD value, and the third phase difference between the first left image and the third right image is M; Based on the first SAD value and the first phase difference corresponding to the first SAD value, the second SAD value and the second phase difference corresponding to the second SAD value, the third SAD value and the third phase difference corresponding to the third SAD value, a SAD curve is obtained with phase difference as the independent variable and SAD value as the dependent variable.

4. The method according to claim 3, characterized in that The process of reducing the credibility of the weak texture sub-region includes: When the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold value, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value is greater than a second threshold value, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, the second coefficient, and the third coefficient; Among them, the first coefficient is a preset constant, the second coefficient is related to the minimum value of the sum of absolute values ​​of differences SAD corresponding to the weak texture sub-region, and the third coefficient is related to the target phase difference of the weak texture sub-region.

5. The method according to claim 4, characterized in that The method of obtaining the credibility of the weak texture sub-region based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, the second coefficient, and the third coefficient includes: Based on the minimum value c0 of the SAD value, the SAD value a1 corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value a2 corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, the second coefficient e2, and the third coefficient e3, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula: When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula: Among them, the second coefficient e2 is the reciprocal of the minimum value of the sum of the absolute values ​​of the differences SAD value corresponding to the weak texture sub-region, and the third coefficient e3 is the reciprocal of the integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

6. The method according to claim 3, characterized in that The process of reducing the credibility of the weak texture sub-region includes: When the absolute value of the target phase difference of the weak texture sub-region is greater than the first threshold, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value is less than or equal to the second threshold, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the third coefficient; The first coefficient is a preset constant, and the third coefficient is related to the target phase difference of the weak texture sub-region.

7. The method according to claim 6, characterized in that The method of obtaining the credibility of the weak texture sub-region based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the third coefficient includes: Based on the minimum value c0 of the SAD value, the SAD value a1 corresponding to the phase difference minus 1 corresponding to the minimum value of the SAD value in the SAD value curve, the SAD value a2 corresponding to the phase difference plus 1 corresponding to the minimum value of the SAD value in the SAD curve, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the third coefficient e3, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula: When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula: The third coefficient e3 is the reciprocal of the integer obtained by rounding up the absolute value of the target phase difference of the weak texture sub-region.

8. The method according to claim 3, characterized in that The process of reducing the credibility of the weak texture sub-region includes: When the absolute value of the target phase difference of the weak texture sub-region is greater than a first threshold value, and the minimum value of the sum of the absolute values ​​of the differences corresponding to the weak texture sub-region SAD value is greater than a second threshold value, the credibility of the weak texture sub-region is obtained based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, a first value related to the left endpoint value of the SAD curve, a second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the second coefficient; The first coefficient is a preset constant, and the second coefficient is related to the minimum value of the sum of absolute differences (SAD) corresponding to the weak texture sub-region.

9. The method according to claim 8, characterized in that The method of obtaining the credibility of the weak texture sub-region based on the minimum value of the SAD value, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value related to the left endpoint value of the SAD curve, the second value related to the right endpoint value of the SAD curve, the area of ​​the weak texture sub-region, the first coefficient, and the second coefficient includes: Based on the minimum value c0 of the SAD value, the SAD value a1 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD value curve minus 1, the SAD value a2 corresponding to the phase difference corresponding to the minimum value of the SAD value in the SAD curve plus 1, the first value c2 related to the left endpoint value of the SAD curve, the second value c1 related to the right endpoint value of the SAD curve, the area A of the weak texture sub-region, the first coefficient e1, and the second coefficient e2, when a1 is greater than or equal to a2, the credibility Conf of the weak texture sub-region satisfies the following formula: When a1 is less than a2, the credibility Conf of the weak texture sub-region satisfies the following formula: The second coefficient e2 is the reciprocal of the minimum value of the sum of the absolute values ​​of the differences SAD corresponding to the weak texture sub-region.

10. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as claimed in any one of claims 1 to 9.

11. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device is caused to perform the method as claimed in any one of claims 1 to 9.

13. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Focusing method and terminal

    CN106060407A

  • Phase focusing method and device thereof

    CN108337424A

  • Focus hunting prevention for phase detection auto focus (AF)

    CN108463993A

  • Phase difference acquisition method and device, electronic equipment and computer readable storage medium

    CN112866550A

  • Focusing method, terminal, electronic equipment and storage medium

    CN117156273A