Focusing method and device, electronic equipment, storage medium and computer program product
By downsampling and dividing the image into regions, the exposure type of the image to be processed is determined to achieve the focus position, solving the problems of focus stability and low efficiency in overexposed scenes and improving the user experience.
Patent Information
- Application Number
- CN202410316108.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2025-09-19
AI Technical Summary
The existing autofocus method in overexposure scenarios has problems such as high defocus rate, insufficient focus stability and low focus efficiency, which affects the user experience.
By downsampling the image to be processed, multiple sampling images are obtained, and the target sampling image is divided into regions. The exposure type of the image to be processed is determined based on the exposure information of each first detection area, and finally the target focus position is determined.
It achieves improved focus stability and focus efficiency in overexposed scenes, improving the user experience.
Smart Images

Figure CN120676255A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular to a focusing method, device, electronic device, storage medium, and computer program product. Background Art
[0002] In recent years, with the continuous development of image processing technology and the rapid iteration of camera equipment, the use of camera devices such as cameras and mobile phones has become increasingly widespread. Autofocus technology, as one of the key technologies for the operation of camera devices, enables cameras to automatically focus using different focusing methods to ensure the imaging quality of the camera device.
[0003] However, when using the focusing method of related technologies for autofocus, interference from strong light sources in overexposed scenes results in a high defocus rate and insufficient focusing stability. There are problems such as large focusing accuracy error and low focusing efficiency, resulting in a poor user experience. Summary of the Invention
[0004] To overcome the problems existing in the related art, the present disclosure provides a focusing method, device, electronic device, storage medium and computer program product.
[0005] According to a first aspect of an embodiment of the present disclosure, a focusing method is provided, the focusing method comprising:
[0006] Downsampling the image to be processed to obtain multiple sampled images;
[0007] Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions;
[0008] determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area;
[0009] Based on the exposure type, a target focus position is determined.
[0010] In some embodiments of the present disclosure, downsampling the image to be processed to obtain multiple sampled images includes:
[0011] The image to be processed is subjected to a two-fold downsampling process in the row direction and the column direction to obtain four sampled images.
[0012] In some embodiments of the present disclosure, dividing the target sample image among the multiple sample images into regions to obtain multiple first detection regions includes:
[0013] Determining a preset number of pixel rows and a preset number of pixel columns in the first detection area;
[0014] Based on the preset number of pixel rows and the preset number of pixel columns, pixels in the target sample image are divided into a plurality of first detection areas.
[0015] In some embodiments of the present disclosure, before downsampling the image to be processed, the focusing method further includes:
[0016] Get the original image;
[0017] The original image is converted into a grayscale image, and the grayscale image is used as the image to be processed.
[0018] In some embodiments of the present disclosure, determining the exposure type of the image to be processed based on the exposure information of each first detection area includes:
[0019] determining, based on pixel intensities of pixels within each of the first detection areas, an area type of each of the first detection areas, and using the area type as the exposure information, the area type including an overexposure detection area and a non-overexposure detection area;
[0020] An exposure type of the image to be processed is determined based on the area type of each of the first detection areas.
[0021] In some embodiments of the present disclosure, determining the area type of each first detection area based on the pixel intensity of each pixel in each first detection area includes:
[0022] determining, based on the pixel intensity of each pixel in each of the first detection areas and an overexposed pixel intensity threshold, a ratio of overexposed pixels in each of the first detection areas;
[0023] Based on the overexposed pixel ratio and the ratio threshold of each first detection area, it is determined that the area type of each first detection area is an overexposed detection area or a non-overexposed detection area.
[0024] In some embodiments of the present disclosure, determining the exposure type of the image to be processed based on the area type of each first detection area includes:
[0025] performing clustering processing on each of the first detection areas whose area type is an overexposure detection area to obtain cluster set quantity information, where the cluster set quantity information is used to represent the number of cluster sets in the target sample image;
[0026] In response to the number of the cluster sets being zero, determining that the exposure type is a first exposure type;
[0027] In response to the number of the cluster sets being greater than zero and less than a number threshold, determining that the exposure type is a second exposure type;
[0028] In response to the number of the cluster sets being greater than or equal to the number threshold, the exposure type is determined to be a third exposure type.
[0029] In some embodiments of the present disclosure, after clustering the first detection areas whose area types are overexposure detection areas, the focusing method further includes:
[0030] The area type of the first detection area, which is an overexposure detection area and does not belong to any of the cluster sets, is changed to a non-overexposure detection area.
[0031] In some embodiments of the present disclosure, determining a target focus position based on the exposure type includes:
[0032] In response to the exposure type being the first exposure type, determining a current focus position as the target focus position;
[0033] In response to the exposure type being the second exposure type, determining the target focus position based on the area type of each of the first detection areas and other sampling images in the plurality of sampling images except the target sampling image;
[0034] In response to the exposure type being the third exposure type, a preset hyperfocal distance position is determined as the target focus position.
[0035] In some embodiments of the present disclosure, determining the target focus position based on the area type of each first detection area and other sample images in the plurality of sample images except the target sample image includes:
[0036] determining, based on the area type of each of the first detection areas, the area type of an area corresponding to each of the first detection areas in other sampled images;
[0037] Restoring the multiple sampled images into a restored image, wherein each of the first detection areas is spliced with pixel points at corresponding positions of other sampled images to form a second detection area;
[0038] The target focus position is determined based on the area type of each second detection area of the restored image.
[0039] In some embodiments of the present disclosure, determining the target focus position based on the area type of each second detection area of the restored image includes:
[0040] determining a phase defocus value and a reliability of each second detection area whose area type is a non-overexposure detection area in the restored image;
[0041] The target focus position is determined based on the phase defocus value and the reliability.
[0042] In some embodiments of the present disclosure, determining the target focus position based on the phase defocus value and the credibility includes:
[0043] Taking the center point of the restored image as the center of the search area, searching the search area, and gradually expanding the search range of the search area;
[0044] In response to any of the second detection areas whose credibility is greater than the credibility threshold being located within the search area, the search is stopped, and the target focus position is determined based on the phase defocus values of each of the second detection areas whose area type is a non-overexposure detection area within the current search area.
[0045] In some embodiments of the present disclosure, determining the target focus position based on the phase defocus value and the credibility also includes: in response to the search area exceeding the restored image, using each second detection area of the restored image whose area type is a non-overexposure detection area as a focus area to determine the target focus position.
[0046] According to a second aspect of an embodiment of the present disclosure, a focusing device is provided, comprising:
[0047] A downsampling module, configured to perform downsampling processing on the image to be processed to obtain a plurality of sampled images;
[0048] A region division module, configured to divide a target sample image among the plurality of sample images into regions to obtain a plurality of first detection regions;
[0049] a first determining module, configured to determine an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area;
[0050] A second determining module is configured to determine a target focus position based on the exposure type.
[0051] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, the electronic device including:
[0052] processor;
[0053] a memory for storing processor-executable instructions;
[0054] Wherein, the processor is configured to:
[0055] Downsampling the image to be processed to obtain multiple sampled images;
[0056] Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions;
[0057] determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area;
[0058] Based on the exposure type, a target focus position is determined.
[0059] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a focusing method, the focusing method comprising:
[0060] Downsampling the image to be processed to obtain multiple sampled images;
[0061] Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions;
[0062] determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area;
[0063] Based on the exposure type, a target focus position is determined.
[0064] According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer program product, including a computer program, which, when executed by a processor, implements:
[0065] Downsampling the image to be processed to obtain multiple sampled images;
[0066] Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions;
[0067] determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area;
[0068] Based on the exposure type, a target focus position is determined.
[0069] The technical solutions provided by the embodiments of the present disclosure can achieve the following beneficial effects: by downsampling the image to be processed to obtain a sampled image and dividing the target sampled image into regions, the exposure type of the image to be processed can be determined based on the exposure information of multiple first detection regions, and the target focus position can be determined based on the exposure type, thus achieving autofocus. By performing downsampling and region division, the exposure level of each first detection region can reflect the exposure level of each position in the image to be processed, and the target focus position can be determined without processing the entire image to be processed, thus ensuring focus stability and efficiency in overexposure scenarios and improving the user experience.
[0070] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0072] Figure 1 is a flowchart of a focusing method according to an exemplary embodiment.
[0073] Figure 2 is a schematic diagram of an image to be processed according to an exemplary embodiment.
[0074] Figure 3 is a schematic diagram of a sampling image according to an exemplary embodiment.
[0075] Figure 4 The present invention is a flowchart of dividing a target sample image among multiple sample images into regions to obtain multiple first detection regions according to an exemplary embodiment.
[0076] Figure 5 FIG. 4 is a schematic diagram of a first detection area of a target sampling image according to an exemplary embodiment.
[0077] Figure 6 is a flowchart of a focusing method according to another exemplary embodiment.
[0078] Figure 7 The flowchart of determining the exposure type of an image to be processed based on exposure information of each first detection area is shown according to an exemplary embodiment.
[0079] Figure 8 FIG. 4 is a schematic diagram showing the area types of first detection areas of a target sampling image according to an exemplary embodiment.
[0080] Figure 9The flowchart of determining the area type of each first detection area based on the pixel intensity of each pixel in each first detection area according to an exemplary embodiment is shown.
[0081] Figure 10 The flowchart of determining the exposure type of an image to be processed based on the area type of each first detection area according to an exemplary embodiment is shown.
[0082] Figure 11 The flowchart of determining a target focus position based on an exposure type according to an exemplary embodiment is shown.
[0083] Figure 12 The present invention is a flowchart of determining a target focus position based on the area type of each first detection area and other sampling images except the target sampling image in a plurality of sampling images according to an exemplary embodiment.
[0084] Figure 13 is a schematic diagram showing a restored image according to an exemplary embodiment.
[0085] Figure 14 The flowchart of determining a target focus position based on the area type of each second detection area of a restored image according to an exemplary embodiment is shown.
[0086] Figure 15 The present invention is a flowchart showing how to determine a target focus position based on a phase defocus value and a reliability according to an exemplary embodiment.
[0087] Figure 16 is a flowchart of a focusing method according to another exemplary embodiment.
[0088] Figure 17 is a block diagram of a focusing device according to an exemplary embodiment.
[0089] Figure 18 is a block diagram of an electronic device according to an exemplary embodiment.
[0090] In the picture:
[0091] 10-first detection area; 20-second detection area; 30-downsampling module; 40-area division module; 50-first determination module; 60-second determination module; 101-processing component; 102-memory; 103-power component; 104-multimedia component; 105-audio component; 106-input / output interface; 107-sensor component; 108-communication component; 109-processor. DETAILED DESCRIPTION
[0092] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, like numbers in different figures represent like or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present invention, as detailed in the appended claims.
[0093] In recent years, with the continuous development of image processing technology and the rapid iteration of camera devices, cameras, mobile phones, and other camera devices have become widely used in people's daily lives and work. Autofocus technology is one of the key technologies for the operation of camera devices. Camera devices can automatically focus through focusing methods such as Phase Detection Auto Focus (PDAF), contrast focusing, and Time of Flight (TOF) to ensure the imaging effect of the camera device.
[0094] In overexposed scenes, such as those at night due to streetlights, sunlight, and fill light, the pixels in the overexposed areas are close to saturated pixels. Phase detection focusing makes it difficult to calculate the phase difference, resulting in a high rate of defocus. Time-of-flight focusing can be unstable due to interference from strong light sources, and contrast focusing can be inefficient. To address these issues, the lens is typically moved to the area with the smallest regional brightness variance as the focal point, or saturated pixels in the image are removed.
[0095] However, when using the focusing method of related technologies for autofocus, there is still a large error in focusing on overexposed scenes, and it is difficult to maintain a high focusing efficiency, which affects the response time and film quality of the camera device and poor user experience.
[0096] Based on this, exemplary embodiments of the present disclosure provide a focusing method that downsamples an image to be processed to obtain a sampled image and then divides the target sampled image into regions. The method then determines the exposure type of the image to be processed based on the exposure information obtained from multiple first detection regions, and then determines the target focus position based on the exposure type, thereby achieving autofocus. Through downsampling and region division, the exposure level of each first detection region reflects the exposure level of each position in the image to be processed, allowing the target focus position to be determined without processing the entire image to be processed. This ensures focus stability and efficiency in overexposure scenarios, improving the user experience.
[0097] In an exemplary embodiment, a focusing method is provided. The focusing method can be applied to photographing devices such as mobile phones and cameras. Figure 1 As shown, the focusing methods include:
[0098] S100 , downsampling the image to be processed to obtain multiple sampled images.
[0099] In step S100, the image to be processed is downsampled. The downsampling process is used to reduce the image size of the image to be processed, thereby reducing the image data volume and computational complexity of the image to be processed while retaining important information, thereby obtaining multiple sampled images. Each sampled image may, for example, have the same number of pixel rows and pixel columns, and the number of pixel rows and pixel columns of each sampled image is smaller than the number of pixel rows and pixel columns of the image to be processed. The number of sampled images is determined by the downsampling factor. When the image to be processed is downsampled by a factor of two, the number of sampled images is four.
[0100] Exemplarily, the image to be processed can be a grayscale image, for example. The number of pixel rows and pixel columns of the image to be processed is the same as the original image acquired by the photographic device. Each pixel in the image to be processed has a corresponding pixel intensity. When the image to be processed is a grayscale image, the pixel intensity corresponding to each pixel is a grayscale value.
[0101] S200 , dividing a target sample image among a plurality of sample images into regions to obtain a plurality of first detection regions.
[0102] In step S200, one of the multiple sample images is arbitrarily selected as a target sample image, and the target sample image is region-divided to divide the pixels in the target sample image into different regions. The multiple pixels divided into a region constitute a first detection region 10. After the target sample image is region-divided, the number of pixels in the first detection region 10 is further reduced, that is, the number of pixels of the image to be processed is greater than the number of pixels of the target sample image, and the number of pixels of the target sample image is greater than the number of pixels of the first detection region 10. For example, each first detection region 10 may have the same number of pixel rows and pixel columns, so that the number of pixels in each first detection region 10 is the same.
[0103] S300: Determine an exposure type of the image to be processed based on exposure information of each first detection area, where the exposure information is used to represent an exposure degree of the first detection area.
[0104] In step S300, each first detection area 10 obtained after dividing the target sample image into regions has corresponding exposure information. The exposure information is used to characterize the exposure level of each first detection area 10. The exposure information may be, for example, the region type of each first detection area 10. The exposure type of the image to be processed can be determined based on the exposure information of each first detection area 10. Exemplarily, the exposure types of the image to be processed may include non-overexposed scenes, partially overexposed scenes, and fully overexposed scenes. Images to be processed with different exposure types have different overexposure levels.
[0105] S400: Determine a target focus position based on the exposure type.
[0106] In step S400, since the images to be processed of different exposure types have different degrees of overexposure, and images with different degrees of overexposure require different methods to determine the target focus position in order to ensure the accuracy of the target focus position, it is necessary to determine the final target focus position in a corresponding manner according to the exposure type of the image to be processed to realize the autofocus process.
[0107] It can be understood that since the number of pixels in the first detection area 10 is much smaller than the number of pixels in the image to be processed, the amount of calculation and calculation time required to obtain the exposure information of the first detection area 10 and determine the exposure type and final target focus position of the image to be processed are greatly reduced, thereby improving the focusing efficiency of the photographic device.
[0108] In this embodiment, by downsampling the image to be processed to obtain a sampled image and then dividing the target sampled image into regions, the exposure type of the image to be processed can be determined based on the exposure information obtained from the multiple first detection regions 10, and the target focus position can be determined based on the exposure type, thus achieving autofocus. By performing downsampling and region division, the exposure level of each first detection region 10 can reflect the exposure level of each position in the image to be processed, and the target focus position can be determined without processing the entire image to be processed. This ensures focus stability and efficiency in overexposure scenarios, improving the user experience.
[0109] In some embodiments, downsampling the image to be processed to obtain multiple sampled images includes: downsampling the image to be processed by a factor of two in the row direction and the column direction to obtain four sampled images.
[0110] The downsampling processing performed on the image to be processed can be a double downsampling processing in the row direction and the column direction. For example, pixels that are simultaneously located in odd rows and odd columns, odd rows and even columns, even rows and odd columns, and even rows and even columns in the image to be processed can be extracted respectively, and four sampling images are formed according to the relative position relationship of each pixel in the image to be processed, so that the number of pixel rows and pixel columns of the four sampling images are both 1 / 2 of the image to be processed, and the number of pixels of the four sampling images are both 1 / 4 of the image to be processed.
[0111] For example, refer to Figure 2 As shown, the number of pixel rows and pixel columns of the image to be processed is 16, and the number of pixels of the image to be processed is 256. The pixels located in the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, and 15th rows and in the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, and 15th columns of the image to be processed can be extracted, and the relative position relationship of each pixel in the image to be processed is formed as follows Figure 3 As shown in the sampled image, the number of pixel rows and pixel columns of the sampled image is 8, and the number of pixels of the sampled image is 64.
[0112] A downsampling processing method of two times downsampling is adopted, so that the pixels at corresponding positions in each sampled image are adjacent to each other in the image to be processed. Each pixel in the sampled image can, to a certain extent, represent multiple pixels within a certain neighborhood range in the image to be processed. Therefore, the exposure level of the four sampled images can all reflect the exposure level of the image to be processed. Any one of the four sampled images is selected as the target sampled image for subsequent processing, which improves the focusing efficiency while ensuring the focusing accuracy.
[0113] In this embodiment, by downsampling the image to be processed by a double downsampling process in the row and column directions, four sampling images are obtained, so that the four sampling images can represent the entire image to be processed to a certain extent, providing a basis for subsequent area division, and reducing the number of pixels that need to be calculated subsequently to 1 / 4, thereby improving the focusing efficiency while ensuring the focusing accuracy.
[0114] In some embodiments, reference Figure 4 As shown, the target sample image in the multiple sample images is divided into regions to obtain multiple first detection regions 10, including:
[0115] S210 , determining a preset number of pixel rows and a preset number of pixel columns in a first detection area.
[0116] In step S210, the preset number of pixel rows and the preset number of pixel columns of the first detection area 10 are first determined to determine the size of each first detection area 10. The preset number of pixel rows and the preset number of pixel columns can be empirical values and can be adjusted according to actual needs. When it is necessary to improve focusing accuracy, the preset number of pixel rows and the preset number of pixel columns can be reduced accordingly. When it is necessary to improve focusing efficiency, the preset number of pixel rows and the preset number of pixel columns can be increased accordingly. For example, the preset number of pixel rows and the preset number of pixel columns can be set to 2*2, 3*3, 4*4, etc.
[0117] S220 : Divide the pixels in the target sample image into a plurality of first detection areas based on a preset number of pixel rows and a preset number of pixel columns.
[0118] In step S220, each pixel in the target sample image is divided into a plurality of first detection areas 10 according to the area range size defined by the preset number of pixel rows and the preset number of pixel columns, thereby realizing the area division of the target sample image. Figure 3The sampled image shown is used as the target sampled image. After determining that the preset number of pixel rows is 2 and the preset number of pixel columns is 2, the target sampled image can be divided into the following Figure 5 In the multiple first detection areas 10 shown, each pixel in the target sampling image is divided into a first detection area 10 , and the number of pixels in each first detection area 10 is 4.
[0119] In this embodiment, by setting a preset number of pixel rows and columns, and dividing the pixels in the target sampled image into a plurality of first detection areas 10 based on the preset number of pixel rows and columns, regional division of the target sampled image is achieved, providing a basis for subsequently determining the exposure type of the image to be processed. The exposure level of each first detection area 10 can reflect the exposure level of each position in the image to be processed, and the target focus position can be determined without processing all pixels in the image to be processed. This ensures focus stability and efficiency in overexposure scenarios, and improves the user experience.
[0120] In some embodiments, reference Figure 6 As shown, before downsampling the image to be processed, the focusing method further includes:
[0121] S510: Acquire an original image.
[0122] In step S510, for example, the current frame image can be obtained through the camera module of the photographing device, and the unprocessed current frame image is used as the original image. As mentioned above, the number of pixel rows and pixel columns of the original image are the same as those of the image to be processed, that is, the number of pixels of the original image is the same as that of the image to be processed.
[0123] S520: Convert the original image into a grayscale image, and use the grayscale image as the image to be processed.
[0124] In step S520, each pixel of the original image can be represented by the channel values of the three color channels of red (R), green (G), and blue (B), and the original image is subjected to grayscale conversion processing to convert the original image into a single-channel grayscale image, and the grayscale image is used as the image to be processed. Each pixel of the grayscale image can represent the pixel intensity of each pixel by the grayscale value. After the image to be processed is downsampled and divided into regions, the first detection area 10 is also a grayscale image, which is convenient for subsequent determination of the exposure type.
[0125] In this embodiment, by converting the original image obtained by the photographing device into a grayscale image, the grayscale image can be used as the image to be processed, which provides a basis for downsampling processing, so that each pixel in the first detection area 10 can represent the corresponding pixel intensity through the grayscale value, which facilitates the subsequent determination of the area type of the first detection area 10 and the exposure type of the image to be processed, ensuring focus stability and focus efficiency, and improving user experience.
[0126] In some embodiments, reference Figure 7 As shown, based on the exposure information of each first detection area 10, the exposure type of the image to be processed is determined, including:
[0127] S310 , determining the region type of each first detection region based on the pixel intensity of each pixel in each first detection region, and using the region type as exposure information, where the region type includes an overexposure detection region and a non-overexposure detection region.
[0128] In step S310, as mentioned above, when the image to be processed is a grayscale image, the pixel intensity of each pixel in the first detection area 10 can be the grayscale value corresponding to the pixel, and the area type of each first detection area 10 can be determined as the corresponding exposure information based on the grayscale value of each pixel in the first detection area 10.
[0129] The area types of the first detection area 10 include an overexposure detection area and a non-overexposure detection area. For example, Figure 8 As shown, when the area type of the first detection area 10 is an overexposure detection area, it means that the overexposure degree of the first detection area 10 is relatively high, and the first detection area 10 can be marked as "1". When the area type of the first detection area 10 is a non-overexposure detection area, it means that the overexposure degree of the first detection area 10 is relatively low, and the first detection area 10 can be marked as "0" to realize the division and marking of the area types of each first detection area 10.
[0130] S320: Determine the exposure type of the image to be processed based on the area type of each first detection area.
[0131] In step S320, the area type of each first detection area 10 represents the degree of overexposure of each first detection area 10. The exposure type of the target sampling image can be determined by the area type of each first detection area 10, and the exposure type of each sampling image can represent the exposure type of the image to be processed. Therefore, the exposure type of the image to be processed can be determined according to the area type of each first detection area 10, providing a basis for determining the target focus position.
[0132] In this embodiment, the area type of each first detection area 10 is determined based on the pixel intensity of each pixel within each first detection area 10, and the exposure type of the image to be processed is determined based on the area type of each first detection area 10. This allows the exposure type of the image to be processed to be determined, providing a basis for determining the target focus position. By determining the exposure type of the image to be processed based on the pixel intensity of each pixel within each first detection area 10, the target focus position can be determined without processing all pixels in the image to be processed. This ensures focus stability and efficiency in overexposure scenarios, improving the user experience.
[0133] In some embodiments, reference Figure 9 As shown, based on the pixel intensity of each pixel in each first detection area 10, the area type of each first detection area 10 is determined, including:
[0134] S311 : Determine the overexposed pixel ratio of each first detection area based on the pixel intensity of each pixel in each first detection area and the overexposed pixel intensity threshold.
[0135] In step S311, when the pixel intensity of a pixel is higher than the overexposed pixel intensity threshold, it indicates that the pixel is an overexposed saturated pixel. Based on the pixel intensity of each pixel in each first detection area 10 and the overexposed pixel intensity threshold, the ratio of overexposed saturated pixels in each first detection area 10 to all pixels in the first detection area 10, i.e., the overexposed pixel ratio, can be determined. For example, if a first detection area 10 includes four pixels, and the grayscale value of one pixel is greater than the overexposed pixel intensity threshold, the overexposed pixel ratio of the first detection area 10 can be determined to be 0.75.
[0136] S312 : Based on the overexposure pixel ratio and the ratio threshold of each first detection area, determine whether the area type of each first detection area is an overexposure detection area or a non-overexposure detection area.
[0137] In step S312, the area type of each first detection area 10 can be determined based on the overexposed pixel ratio and the ratio threshold of each first detection area 10. When the overexposed pixel ratio of a first detection area 10 is higher than the ratio threshold, it indicates that the first detection area 10 is highly overexposed, and the area type of the first detection area 10 can be determined as an overexposed detection area. When the overexposed pixel ratio of a first detection area 10 is lower than or equal to the ratio threshold, it indicates that the first detection area 10 is less overexposed, and the first detection area 10 can be determined as a non-overexposed detection area.
[0138] In this embodiment, by comparing the pixel intensity of each pixel within each first detection area 10 with the overexposed pixel intensity threshold, the overexposed pixel ratio of each first detection area 10 can be determined. By comparing the overexposed pixel ratio of each first detection area 10 with the ratio threshold, the area type of each first detection area 10 can be determined, thereby achieving classification between overexposed detection areas and non-overexposed detection areas, providing a basis for determining the exposure type of the image to be processed. The overexposed pixel intensity threshold and the ratio threshold can respectively filter out overexposed saturated pixels and first detection areas 10 with high levels of overexposure, ensuring the accuracy of determining the area type of the first detection area 10, thereby maintaining focus stability in overexposed scenes and improving the user experience.
[0139] In some embodiments, reference Figure 10 As shown, based on the area type of each first detection area 10, the exposure type of the image to be processed is determined, including:
[0140] S321 , performing clustering processing on the first detection area of each area type being the overexposure detection area to obtain cluster set quantity information, where the cluster set quantity information is used to represent the number of cluster sets in the target sampling image.
[0141] In step S321, clustering is performed on each first detection area 10 whose area type is an overexposure detection area. This allows any number of first detection areas 10 whose area type is an overexposure detection area to be clustered into a cluster set. Discrete first detection areas 10 whose area type is an overexposure detection area are filtered out to prevent these discrete first detection areas 10 from interfering with the determination of the exposure type of the image to be processed. Information about the number of cluster sets is obtained, which represents the number of cluster sets in the target sample image.
[0142] For example, a density-based clustering algorithm (Density Based Spatial Clustering of Applications with Noise, DBSCAN) can be used to cluster the first detection areas 10 in the target sampling image whose area type is overexposure detection areas, i.e., marked as "1". The density of the sample distribution is characterized according to the neighborhood and parameters, so that the first detection areas 10 whose area type is overexposure detection areas are clustered in different cluster sets or defined as discrete data, thereby filtering out the discrete first detection areas 10 whose area type is overexposure detection areas, and obtaining cluster set quantity information for characterizing the number of cluster sets.
[0143] S322: In response to the number of cluster sets being zero, determine that the exposure type is the first exposure type.
[0144] In step S322, when the cluster set quantity information represents that the number of cluster sets is zero, it means that there is no concentrated distribution area type in the target sampling image, which is the first detection area 10 of the overexposure detection area. The overexposure degree of the target sampling image and the image to be processed is low, and the exposure type of the image to be processed can be determined as the first exposure type. The first exposure type can be, for example, a non-overexposure scene.
[0145] S323: In response to the number of cluster sets being greater than zero and less than a quantity threshold, determine that the exposure type is the second exposure type.
[0146] In step S323, when the cluster set quantity information represents that the number of cluster sets is greater than zero and less than the quantity threshold, it represents that there are a certain number of concentrated distribution areas in the target sampling image, which are the first detection area 10 of the overexposure detection area, and the target sampling image and the local part of the image to be processed have a high degree of overexposure. The exposure type of the image to be processed can be determined as the second exposure type, and the second exposure type can be, for example, a local overexposure scene.
[0147] S324: In response to the number of cluster sets being greater than or equal to the number threshold, determine that the exposure type is a third exposure type.
[0148] In step S323, when the cluster set quantity information represents that the number of cluster sets is greater than or equal to the quantity threshold, it represents that there are too many concentrated distribution areas in the target sample, and the type of area is the first detection area 10 of the overexposure detection area. The target sampling image and the image to be processed as a whole have a high degree of overexposure. The exposure type of the image to be processed can be determined as the third exposure type, and the third exposure type can be, for example, a full overexposure scene.
[0149] The quantity threshold can be determined, for example, based on the number of first detection areas 10 in the target sampling image and the preset threshold ratio. For example, when the preset threshold ratio is 0.95 and the number of first detection areas 10 in the target sampling image is N, the quantity threshold can be, for example, N*0.95.
[0150] In this embodiment, by clustering the first detection areas 10 whose area types are overexposure detection areas, cluster set quantity information can be obtained. The different exposure types of the image to be processed can be determined based on the number of cluster sets represented by the cluster set quantity information, providing a basis for the subsequent determination of the target focus position. The clustering process can cluster any number of first detection areas 10 whose area types are overexposure detection areas into cluster sets, and filter out discrete first detection areas 10 whose area types are overexposure detection areas, so as to avoid the discrete first detection areas 10 whose area types are overexposure detection areas interfering with the determination of the exposure type of the image to be processed.
[0151] In some embodiments, after clustering the first detection areas 10 whose area types are overexposure detection areas, the focusing method further includes: changing the area type of the first detection areas 10 whose area types are overexposure detection areas and do not belong to any cluster set to non-overexposure detection areas.
[0152] As mentioned above, after clustering the first detection areas 10 whose area types are overexposure detection areas, one or more cluster sets may be obtained. At the same time, due to factors such as image noise, there may be some discrete first detection areas 10 whose area types are overexposure detection areas that do not belong to any cluster set. It is necessary to change the area types of these first detection areas 10 whose area types are overexposure detection areas and do not belong to any cluster set to non-overexposure detection areas.
[0153] For example, after clustering the first detection areas 10 whose area types are overexposure detection areas, the marks of the discrete first detection areas 10 marked as “1” may be changed to “0”.
[0154] In this embodiment, by changing the area type of the first detection area 10 whose area type is an overexposure detection area and does not belong to any cluster set to a non-overexposure detection area, it can be ensured that the first detection area 10 whose area type is an overexposure detection area has a concentrated distribution property in the subsequent processing process, avoiding interference of factors such as image noise on the area type of the first detection area 10, making the area type of the first detection area 10 more in line with the actual situation, and improving the focusing accuracy.
[0155] In some embodiments, reference Figure 11 As shown, based on the exposure type, the target focus position is determined, including:
[0156] S410: In response to the exposure type being the first exposure type, determining the current focus position as the target focus position.
[0157] In step S410, when the exposure type of the image to be processed is the first exposure type, it means that the overexposure degree of the image to be processed is low, and it is a non-overexposure scene. There is no need to consider the impact of the overexposure factor on the focus position. The current focus position of the camera device can be determined as the target focus position to maintain the current focus position.
[0158] S420: In response to the exposure type being the second exposure type, determine a target focus position based on the area type of each first detection area and other sampling images except the target sampling image in the plurality of sampling images.
[0159] In step S420, when the exposure type of the image to be processed is the second exposure type, it means that a part of the image to be processed has a high degree of overexposure, which is a local overexposure scene. It is necessary to consider the impact of the overexposed local position on the focus position. The final target focus position can be determined based on the area type of each first detection area 10 and other sampling images in the multiple sampling images except the target sampling image.
[0160] S430: In response to the exposure type being the third exposure type, determining a preset hyperfocal distance position as a target focus position.
[0161] In step S430, when the exposure type of the image to be processed is the third exposure type, it means that the overall image to be processed has a high degree of overexposure, which is a fully overexposed scene. The preset hyperfocal distance position can be determined as the target focus position to obtain a larger depth of field, so as to capture the details of the background while ensuring the foreground is clear, thereby minimizing the impact of the high degree of overexposure on the imaging effect.
[0162] In this embodiment, when the exposure type is the first exposure type, the current focus position is determined as the target focus position, and the current focus position can be maintained without considering the impact of overexposure on the focus position. When the exposure type is the second exposure type, the target focus position is determined based on the area type of each first detection area 10 and the other sampled images in the multiple sampled images other than the target sampled image, and the impact of the overexposed local position on the focus position can be considered to ensure the accuracy of focus. When the exposure type is the third exposure type, the preset hyperfocal distance position is determined as the target focus position, which can minimize the impact of a higher degree of overexposure on the performance effect, thereby achieving adaptive adjustment of the target focus position when the images to be processed have different exposure types, and ensuring the stability and accuracy of focus in different overexposure scenarios.
[0163] In some embodiments, reference Figure 12 As shown, based on the area type of each first detection area 10 and other sampling images in the plurality of sampling images except the target sampling image, determining the target focus position includes:
[0164] S421 : Based on the region type of each first detection region, determine the region type of the region corresponding to each first detection region in other sampled images.
[0165] In step S421, the area type of the area corresponding to each first detection area 10 in other sampling images can be determined based on the area type of each first detection area 10 in the target sampling image. Since the number of pixel rows and pixel columns of the other sampling images are the same as those of the target sampling image, the area type of each first detection area 10 can be assigned to the area corresponding to each first detection area 10 in other sampling images, so that the area type of the area corresponding to each first detection area 10 in other sampling images is the same as that of each first detection area 10.
[0166] For example, the mark "1" or "0" of each first detection area 10 in the target sample image can be assigned to the area of the other sample images corresponding to each first detection area 10, so that the corresponding positions of the other sample images and the target sample image have the same mark. If the area type of the first detection area 10 is an overexposure detection area, the area type of the area corresponding to the first detection area 10 in the other sample images is also an overexposure detection area. If the area type of the first detection area 10 is a non-overexposure detection area, the area type of the area corresponding to the first detection area 10 in the other sample images is also a non-overexposure detection area.
[0167] S422: Restoring the multiple sampled images into a restored image, and splicing each first detection area with the pixel points at the corresponding position of other sampled images to form a second detection area.
[0168] In step S422, image restoration processing is performed on the target sampled image and the other sampled images to obtain restored images. This image restoration process can be performed according to the pixel decimation method used for each sampled image during the downsampling process, so that each pixel in each sampled image is restored to its original position in the image to be processed. The pixels in each first detection area 10 and the corresponding positions in the other sampled images are concatenated to form a second detection area 20. The ratio of the number of pixel rows and pixel columns in the second detection area 20 to the number of pixel columns in the first detection area 10 is the downsampling factor in the row and column directions during the downsampling process.
[0169] For example, Figure 8 The target sample image and other sample images shown are restored as follows Figure 13 In the restored image shown, each pixel point in each sampled image is restored to its initial position in the image to be processed, the number of pixel rows and pixel columns of each first detection area 10 is 2, and each first detection area 10 is spliced with the pixel points at the corresponding position of other sampled images to form a second detection area 20 with a number of pixel rows and pixel columns of 4. The mark of the second detection area 20, that is, the area type, is the same as the first detection area 10 it includes.
[0170] S423 : Determine a target focus position based on the area type of each second detection area of the restored image.
[0171] In step S423, since each first detection area 10 has the same area type as the area corresponding to other sampling images, each second detection area 20 also has an area type of overexposure detection area or non-overexposure detection area. The target focus position can be determined according to the area type of each second detection area 20 of the restored image, so that when the exposure type is the second exposure type, the target focus position can be determined according to the area type of each first detection area 10 and other sampling images.
[0172] In this embodiment, the area types of the areas corresponding to the first detection areas 10 in other sampled images are determined based on the area types of the first detection areas 10, and the multiple sampled images are restored into a restored image. The target focus position can then be determined based on the area types of the second detection areas 20 in the restored image, thereby achieving determination of the target focus position when the exposure type is the second exposure type. When the impact of overexposed local areas on the focus position needs to be considered, the area types of the second detection areas 20 in the restored image are used as the basis for determining the overexposed local areas, ensuring focus accuracy in partially overexposed scenarios.
[0173] In some embodiments, reference Figure 14 As shown, determining the target focus position based on the area type of each second detection area 20 of the restored image includes:
[0174] S423-1. Determine the phase defocus value and reliability of each second detection area whose area type is a non-overexposure detection area in the restored image.
[0175] In step S423-1, as mentioned above, the restored image includes multiple second detection areas 20, and the second detection areas 20 have area types of overexposure detection areas or non-overexposure detection areas. The phase defocus value (defocus) and confidence (Confidence) of each second detection area 20 whose area type is a non-overexposure detection area in the restored image can be determined. The phase defocus value can characterize the distance between the imaging plane and the focus plane, that is, the distance the lens needs to move, and is used to determine the displacement between the target focus position and the current focus position. The confidence is used to determine whether the area type of the second detection area 20 as a non-overexposure detection area is credible. The determination of the phase defocus value and confidence can be achieved, for example, by executing a phase detection auto focus (PDAF) algorithm.
[0176] S423-2. Determine the target focus position based on the phase defocus value and the reliability.
[0177] In step S423-2, a target focus position can be determined based on the phase defocus values and the reliability of each second detection area 20 whose area type is a non-overexposure detection area, so as to achieve determination of the target focus position when the exposure type is the second exposure type. For example, based on the reliability, a search can be performed for second detection areas 20 whose area type is a reliable non-overexposure detection area, and the final target focus position can be determined by calculating the phase defocus values of each second detection area 20 when the requirements are met.
[0178] In this embodiment, by determining the phase defocus value and reliability of each second detection area 20 in the restored image whose area type is a non-overexposure detection area, the target focus position can be determined based on the phase defocus value and reliability, thereby achieving the target focus position determination when the exposure type is the second exposure type. The phase defocus value and target reliability can be used to determine the displacement between the target focus position and the current focus position and whether the area type of the second detection area 20 is a non-overexposure detection area is reliable, providing a basis for determining the target focus position and ensuring focus accuracy in partial overexposure scenarios.
[0179] In some embodiments, reference Figure 15 As shown, based on the phase defocus value and the reliability, the target focus position is determined, including:
[0180] S423-2-1, taking the center point of the restored image as the center of the search area, searching the search area, and gradually expanding the search range of the search area.
[0181] In step S423-2-1, the center of the restored image is used as the center of the search area, the search area is searched and the search range of the search area is gradually expanded. Figure 12 As shown, the shape of the search area can be, for example, a circle. The center of the restored image is used as the center of the search area. The second detection area 20 that meets the requirements in the search area is searched, and the search radius of the search area is gradually expanded.
[0182] S423-2-2, in response to any second detection area with a credibility greater than the credibility threshold being within the search area, stop searching, and determine the target focus position based on the phase defocus values of each second detection area whose area type is a non-overexposure detection area within the current search area.
[0183] In step S423-2-2, when the credibility of each second detection area 20 whose area type is non-overexposure detection area is greater than the credibility threshold, the area type of the second detection area 20 can be considered to be a credible overexposure detection area. When any second detection area 20 whose credibility is greater than the credibility threshold exists in the search area, the search is stopped and the search range of the search area is no longer expanded. The target focus position can be determined based on the phase defocus values of each second detection area 20 whose area type is non-overexposure detection area in the current search area. For example, the phase defocus values of each second detection area 20 whose area type is non-overexposure detection area and is located within the circular search area and intersecting with the circular search area when the search is stopped can be averaged to obtain a phase defocus target value, and the final target focus position is determined based on the phase defocus target value and the current focus position.
[0184] In this embodiment, by searching the search area and stopping the search when any second detection area 20 with a credibility greater than a credibility threshold is located in the search area, the target focus position can be determined based on the phase defocus value of each second detection area 20 whose area type is a non-overexposure detection area in the current search area, thereby achieving the determination of the target focus position when the search is successful, that is, when there is a credible second detection area 20 whose area type is a non-overexposure detection area.
[0185] In some embodiments, determining the target focus position based on the phase defocus value and the credibility also includes: in response to the search area exceeding the restored image, using each second detection area 20 of the restored image whose area type is a non-overexposure detection area as the focus area to determine the target focus position.
[0186] When the search range is gradually expanded so that the search area exceeds the restored image, and there is no second detection area 20 with a credibility greater than the credibility threshold in the search area, that is, the search fails, the target focus position can no longer be determined based on the phase defocus values of the second detection areas 20 whose area types are non-overexposure detection areas in the current search area when the search is stopped. At this time, it is necessary to use the second detection areas 20 whose area types are non-overexposure detection areas of the entire restored image as the focus areas to determine the target focus position.
[0187] For example, when the circular search area is inscribed in or circumscribed in the boundary of the restored image, each second detection area 20 in the restored image whose area type is a non-overexposure detection area can be used as the entire focus area, and a contrast auto focus (CAF) algorithm is performed on the entire focus area to determine the target focus position.
[0188] In this embodiment, when the search area exceeds the restored image, each second detection area 20 of the restored image whose area type is a non-overexposure detection area is used as the focus area to determine the target focus position, thereby realizing the determination of the target focus position when the search fails, that is, when there is no credible second detection area 20 whose area type is a non-overexposure detection area.
[0189] In an exemplary embodiment, a focusing method is provided, referring to Figure 16 As shown, the focusing methods include:
[0190] S1, obtain the original image;
[0191] S2, converting the original image into a grayscale image, and using the grayscale image as the image to be processed;
[0192] S3, performing a two-fold downsampling process on the image to be processed in the row direction and the column direction to obtain four sampled images;
[0193] S4, determining a preset number of pixel rows and a preset number of pixel columns in the first detection area;
[0194] S5. Dividing pixels in the target sample image in the four sample images into a plurality of first detection areas based on a preset number of pixel rows and a preset number of pixel columns;
[0195] S6. Determine the overexposed pixel ratio of each first detection area based on the pixel intensity of each pixel in each first detection area and the overexposed pixel intensity threshold;
[0196] S7. Determine, based on the overexposed pixel ratio and the ratio threshold of each first detection area, whether the area type of each first detection area is an overexposed detection area or a non-overexposed detection area;
[0197] S8. Perform clustering processing on the first detection area of each area type being the overexposure detection area to obtain cluster set quantity information, where the cluster set quantity information is used to represent the number of cluster sets in the target sampling image;
[0198] S9, changing the area type of the first detection area that is an overexposure detection area and does not belong to any cluster set to a non-overexposure detection area;
[0199] S10. In response to the number of cluster sets being zero, determining that the exposure type is a first exposure type;
[0200] S11. In response to the number of cluster sets being greater than zero and less than a number threshold, determining that the exposure type is a second exposure type;
[0201] S12. In response to the number of cluster sets being greater than or equal to a number threshold, determining that the exposure type is a third exposure type;
[0202] S13, in response to the exposure type being the first exposure type, determining the current focus position as the target focus position;
[0203] S14, in response to the exposure type being the third exposure type, determining a preset hyperfocal distance position as a target focus position;
[0204] S5. In response to the exposure type being the second exposure type, determining, based on the region type of each first detection region, the region type of the region corresponding to each first detection region in other sampled images;
[0205] S16, restoring the multiple sampled images into a restored image, and splicing each first detection area with the pixel points at the corresponding position of the other sampled images to form a second detection area;
[0206] S17, determining a phase defocus value and a reliability of each second detection area whose area type is a non-overexposure detection area in the restored image;
[0207] S18, searching the search area with the center point of the restored image as the center of the search area, and gradually expanding the search range of the search area;
[0208] S19, in response to any second detection area having a credibility greater than a credibility threshold being within the search area, stopping the search, and determining a target focus position based on the phase defocus values of each second detection area whose area type is a non-overexposure detection area within the current search area;
[0209] S20 , in response to the search area exceeding the restored image, using each second detection area of the restored image whose area type is a non-overexposure detection area as a focus area to determine a target focus position.
[0210] In this embodiment, by downsampling the image to be processed to obtain a sampled image and then dividing the target sampled image into regions, the exposure type of the image to be processed can be determined based on the exposure information obtained from the multiple first detection regions 10, and the target focus position can be determined based on the exposure type, thus achieving autofocus. By performing downsampling and region division, the exposure level of each first detection region 10 can reflect the exposure level of each position in the image to be processed, and the target focus position can be determined without processing the entire image to be processed. This ensures focus stability and efficiency in overexposure scenarios, improving the user experience.
[0211] In an exemplary embodiment, a focusing device is provided, referring to Figure 17As shown, the focusing device includes: a downsampling module 30, a region division module 40, a first determination module 50, and a second determination module 60. The downsampling module 30 is configured to downsample the image to be processed to obtain multiple sample images. The region division module 40 is configured to region-divide a target sample image among the multiple sample images to obtain multiple first detection regions 10. The first determination module 50 is configured to determine the exposure type of the image to be processed based on exposure information of each first detection region 10, where the exposure information is used to represent the exposure level of the first detection region 10. The second determination module 60 is configured to determine the target focus position based on the exposure type.
[0212] In this embodiment, the downsampling module 30 downsamples the image to be processed to obtain a sampled image, and the region division module 40 divides the target sampled image into regions. The first determination module 50 determines the exposure type of the image to be processed based on the exposure information obtained for the multiple first detection regions 10, and the second determination module 60 determines the target focus position based on the exposure type, thereby achieving autofocus. Through downsampling and region division, the exposure level of each first detection region 10 reflects the exposure level of each position in the image to be processed. The target focus position can be determined without processing the entire image to be processed, ensuring focus stability and efficiency in overexposure scenarios and improving the user experience.
[0213] In one embodiment, the downsampling module 30 is further configured to perform a two-fold downsampling process on the image to be processed in the row direction and the column direction to obtain four sampled images.
[0214] In one embodiment, the region division module 40 is further used to: determine a preset number of pixel rows and a preset number of pixel columns of the first detection area 10; and divide the pixels in the target sampling image into multiple first detection areas 10 based on the preset number of pixel rows and the preset number of pixel columns.
[0215] In one embodiment, the focusing device further includes a conversion module, which is configured to: acquire an original image; convert the original image into a grayscale image, and use the grayscale image as the image to be processed.
[0216] In one embodiment, the first determination module 50 is further used to: determine the area type of each first detection area 10 based on the pixel intensity of each pixel in each first detection area 10, and use the area type as exposure information, where the area type includes an overexposure detection area and a non-overexposure detection area; and determine the exposure type of the image to be processed based on the area type of each first detection area 10.
[0217] In one embodiment, the first determination module 50 is further used to: determine the overexposed pixel ratio of each first detection area 10 based on the pixel intensity of each pixel in each first detection area 10 and the overexposed pixel intensity threshold; and determine the area type of each first detection area 10 as an overexposed detection area or a non-overexposed detection area based on the overexposed pixel ratio and the ratio threshold of each first detection area 10.
[0218] In one embodiment, the first determination module 50 is further used to: perform clustering processing on the first detection area 10 of each area type being an overexposure detection area to obtain cluster set quantity information, where the cluster set quantity information is used to characterize the number of cluster sets in the target sampling image; in response to the number of cluster sets being zero, determine the exposure type as the first exposure type; in response to the number of cluster sets being greater than zero and less than a quantity threshold, determine the exposure type as the second exposure type; and in response to the number of cluster sets being greater than or equal to the quantity threshold, determine the exposure type as the third exposure type.
[0219] In one embodiment, the first determining module 50 is further configured to change the area type of the first detection area 10 , which is an overexposure detection area and does not belong to any cluster set, to a non-overexposure detection area.
[0220] In one embodiment, the second determination module 60 is further used to: in response to the exposure type being the first exposure type, determine the current focus position as the target focus position; in response to the exposure type being the second exposure type, determine the target focus position based on the area type of each first detection area 10 and other sampling images in the multiple sampling images except the target sampling image; in response to the exposure type being the third exposure type, determine the preset hyperfocal position as the target focus position.
[0221] In one embodiment, the second determination module 60 is further used to: determine the area type of the area corresponding to each first detection area 10 in other sampling images based on the area type of each first detection area 10; restore multiple sampling images into a restored image, and each first detection area 10 is spliced with the pixel points at the corresponding position of other sampling images to form a second detection area 20; determine the target focus position based on the area type of each second detection area 20 in the restored image.
[0222] In one embodiment, the second determination module 60 is further used to: determine the phase defocus value and credibility of each second detection area 20 whose area type is a non-overexposure detection area in the restored image; and determine the target focus position based on the phase defocus value and credibility.
[0223] In one embodiment, the second determination module 60 is further used to: search the search area with the center point of the restored image as the center of the search area, and gradually expand the search range of the search area; in response to any second detection area 20 whose credibility is greater than the credibility threshold being located in the search area, stop searching, and determine the target focus position based on the phase defocus value of each second detection area 20 of each area type in the current search area that is a non-overexposure detection area.
[0224] In one embodiment, the second determining module 60 is further configured to: in response to the search area exceeding the restored image, use each second detection area 20 of the restored image whose area type is a non-overexposure detection area as a focus area to determine the target focus position.
[0225] In an exemplary embodiment, an electronic device is provided. The electronic device may be, for example, a photographing device such as a mobile phone, a tablet computer, or a digital camera, or a device communicatively connected to a photographing device.
[0226] refer to Figure 18 As shown, the electronic device may include one or more of the following components: a processing component 101 , a memory 102 , a power component 103 , a multimedia component 104 , an audio component 105 , an input / output (I / O) interface 106 , a sensor component 107 , and a communication component 108 .
[0227] The processing component 101 generally controls the overall operation of the electronic device, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 101 may include one or more processors 109 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 101 may include one or more modules to facilitate interaction between the processing component 101 and other components. For example, the processing component 101 may include a multimedia module to facilitate interaction between the multimedia component 104 and the processing component 101.
[0228] The memory 102 is configured to store various types of data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc. The memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0229] The power component 103 provides power to various components of the electronic device. The power component 103 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0230] The multimedia component 104 includes a screen that provides an output interface between the electronic device and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 104 includes a front camera and / or a rear camera. When the electronic device is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.
[0231] The audio component 105 is configured to output and / or input audio signals. For example, the audio component 105 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 102 or transmitted via the communication component 108. In some embodiments, the audio component 105 also includes a speaker for outputting audio signals.
[0232] I / O interface 106 provides an interface between processing component 101 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, volume buttons, a start button, and a lock button.
[0233] The sensor assembly 107 includes one or more sensors for providing various aspects of status assessment for the electronic device. For example, the sensor assembly 107 can detect the open / closed state of the electronic device, the relative positioning of components, such as the display and keypad of the electronic device. The sensor assembly 107 can also detect changes in the position of the electronic device or a component of the electronic device, the presence or absence of user contact with the electronic device, the orientation or acceleration / deceleration of the electronic device, and the temperature change of the electronic device. The sensor assembly 107 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 107 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 107 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0234] The communication component 108 is configured to facilitate wired or wireless communication between the electronic device and other devices. The device can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 108 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 108 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0235] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the above-mentioned focusing method applied to the electronic device.
[0236] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 102 including instructions. The instructions can be executed by the processor 109 of the electronic device to perform the above-mentioned focusing method applied to the electronic device. For example, the non-transitory computer-readable storage medium can be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device. When the instructions in the storage medium are executed by the processor 109 of the electronic device, the electronic device is enabled to perform the focusing method shown in the above-mentioned embodiment.
[0237] In an exemplary embodiment, a computer program product is further provided, including a computer program, which implements the above-mentioned focusing method when executed by the processor 109 .
[0238] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.
[0239] It should be understood that the present invention is not limited to the exact construction described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A focusing method, characterized in that: The focusing method comprises: Downsampling the image to be processed to obtain multiple sampled images; Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions; determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area; Based on the exposure type, a target focus position is determined.
2. The focusing method according to claim 1, wherein: The downsampling process is performed on the image to be processed to obtain multiple sampled images, including: The image to be processed is subjected to a two-fold downsampling process in the row direction and the column direction to obtain four sampled images.
3. The focusing method according to claim 1, wherein: The step of dividing the target sample image among the plurality of sample images into regions to obtain a plurality of first detection regions includes: Determining a preset number of pixel rows and a preset number of pixel columns in the first detection area; Based on the preset number of pixel rows and the preset number of pixel columns, pixels in the target sample image are divided into a plurality of first detection areas.
4. The focusing method according to claim 1, wherein: Before downsampling the image to be processed, the focusing method further includes: Get the original image; The original image is converted into a grayscale image, and the grayscale image is used as the image to be processed.
5. The focusing method according to claim 1, wherein: The determining the exposure type of the image to be processed based on the exposure information of each of the first detection areas includes: determining, based on pixel intensities of pixels within each of the first detection areas, an area type of each of the first detection areas, and using the area type as the exposure information, the area type including an overexposure detection area and a non-overexposure detection area; An exposure type of the image to be processed is determined based on the area type of each of the first detection areas.
6. The focusing method according to claim 5, wherein: The determining the area type of each first detection area based on the pixel intensity of each pixel within each first detection area includes: determining, based on the pixel intensity of each pixel in each of the first detection areas and an overexposed pixel intensity threshold, a ratio of overexposed pixels in each of the first detection areas; Based on the overexposed pixel ratio and the ratio threshold of each first detection area, it is determined that the area type of each first detection area is an overexposed detection area or a non-overexposed detection area.
7. The focusing method according to claim 5, wherein: The determining the exposure type of the image to be processed based on the area type of each of the first detection areas includes: performing clustering processing on each of the first detection areas whose area type is an overexposure detection area to obtain cluster set quantity information, where the cluster set quantity information is used to represent the number of cluster sets in the target sample image; In response to the number of the cluster sets being zero, determining that the exposure type is a first exposure type; In response to the number of the cluster sets being greater than zero and less than a number threshold, determining that the exposure type is a second exposure type; In response to the number of the cluster sets being greater than or equal to the number threshold, the exposure type is determined to be a third exposure type.
8. The focusing method according to claim 7, wherein: After clustering the first detection areas whose area types are overexposure detection areas, the focusing method further includes: The area type of the first detection area, which is an overexposure detection area and does not belong to any of the cluster sets, is changed to a non-overexposure detection area.
9. The focusing method according to claim 7 or 8, characterized in that: The determining of a target focus position based on the exposure type includes: In response to the exposure type being the first exposure type, determining a current focus position as the target focus position; In response to the exposure type being the second exposure type, determining the target focus position based on the area type of each of the first detection areas and other sampling images in the plurality of sampling images except the target sampling image; In response to the exposure type being the third exposure type, a preset hyperfocal distance position is determined as the target focus position.
10. The focusing method according to claim 9, wherein: The determining the target focus position based on the area type of each of the first detection areas and other sampling images in the plurality of sampling images except the target sampling image includes: determining, based on the area type of each of the first detection areas, the area type of an area corresponding to each of the first detection areas in other sampled images; Restoring the multiple sampled images into a restored image, wherein each of the first detection areas is spliced with pixel points at corresponding positions of other sampled images to form a second detection area; The target focus position is determined based on the area type of each second detection area of the restored image.
11. The focusing method according to claim 10, wherein: The determining the target focus position based on the area type of each second detection area of the restored image includes: determining a phase defocus value and a reliability of each second detection area whose area type is a non-overexposure detection area in the restored image; The target focus position is determined based on the phase defocus value and the reliability.
12. The focusing method according to claim 11, wherein: The determining the target focus position based on the phase defocus value and the credibility includes: Taking the center point of the restored image as the center of the search area, searching the search area, and gradually expanding the search range of the search area; In response to any of the second detection areas whose credibility is greater than the credibility threshold being located within the search area, the search is stopped, and the target focus position is determined based on the phase defocus values of each of the second detection areas whose area type is a non-overexposure detection area within the current search area.
13. The focusing method according to claim 12, wherein: Determining the target focus position based on the phase defocus value and the credibility also includes: in response to the search area exceeding the restored image, using each second detection area of the restored image whose area type is a non-overexposure detection area as a focus area to determine the target focus position.
14. A focusing device, characterized in that: The focusing device comprises: A downsampling module, configured to perform downsampling processing on the image to be processed to obtain a plurality of sampled images; A region division module, configured to divide a target sample image among the plurality of sample images into regions to obtain a plurality of first detection regions; a first determining module, configured to determine an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area; A second determining module is configured to determine a target focus position based on the exposure type.
15. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: Downsampling the image to be processed to obtain multiple sampled images; Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions; determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area; Based on the exposure type, a target focus position is determined.
16. A non-transitory computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a focusing method, the focusing method comprising: Downsampling the image to be processed to obtain multiple sampled images; Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions; determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area; Based on the exposure type, a target focus position is determined.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it realizes: Downsampling the image to be processed to obtain multiple sampled images; Dividing a target sample image among the multiple sample images into regions to obtain multiple first detection regions; determining an exposure type of the image to be processed based on exposure information of each of the first detection areas, wherein the exposure information is used to represent an exposure degree of the first detection area; Based on the exposure type, a target focus position is determined.