Image processing method, apparatus, device, readable storage medium and program product

CN117764898BActive Publication Date: 2026-09-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211126114.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-15
Publication Date
2026-09-25
Estimated Expiration
2042-09-15

AI Technical Summary

Technical Problem

上述方法极度依赖评估者的主观意识,导致待检测图像的对焦效果评估结果的准确率和效率较低

Benefits of technology

[0019]本申请从待检测图像中确定前景对象对应的目标区域图像,并基于目标区域图像进行图像分块以及图像块筛选处理,得到M个前景图像块,这样可以避免对待检测图像中的非前景区域进行处理,降低了计算量,提高了对焦效果评估的效率。并且,在图像分块处理后,服务器可以从粗粒度的全局图像特征过渡到细粒度的局部图像特征进行待检测图像的对焦效果评估,充分利用待检测图像的特征信息,提高对焦效果评估的准确性。本申请基于清晰图像与模糊图像的清晰度差异较大,模糊图像与模糊图像的清晰度的差异较小的思想,通过各个前景图像块的清晰度以及各个前景图像块对应的模糊图像块的清晰度确定待检测图像的对焦评估结果,相比于人工检测图像对焦效果的方法,实现了自动化的对焦效果评估,并进一步提高了对焦效果评估的准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117764898B_ABST
    Figure CN117764898B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an image processing method, device, equipment, readable storage medium and program product, which can be applied to the fields or scenarios of cloud technology, wisdom platform, application software, vehicle-mounted, image quality evaluation, etc. The method comprises: determining a target region image from a to-be-detected image, the target region image comprising a foreground object; performing image block processing on the target region image to obtain a plurality of candidate image blocks; performing image block screening processing on the plurality of candidate image blocks to obtain M foreground image blocks, and determining the definition of each foreground image block; performing image blurring processing on each foreground image block to obtain M blurred image blocks, and determining the definition of each blurred image block; and determining a focus evaluation result for indicating the focusing effect of the foreground object in the to-be-detected image according to the definition of each foreground image block and the definition of each blurred image block. Through the embodiments of the present application, the accuracy and efficiency of the focus effect evaluation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to image processing methods, image processing apparatus, computer equipment, computer-readable storage media, and computer program products. Background Technology

[0002] With the continuous development of mobile terminals, their shooting functions have become increasingly powerful. During image capture, the mobile terminal needs to focus on the target before taking the picture. Inaccurate focusing can cause the target to appear blurry in the image, significantly affecting image quality. Currently, image focus evaluation relies on manual judgment of the foreground area's sharpness. This method is highly dependent on the evaluator's subjectivity, resulting in low accuracy and efficiency in evaluating the focus effect of the image. Therefore, improving the accuracy and efficiency of focus effect evaluation is a pressing issue. Summary of the Invention

[0003] This application provides an image processing method, apparatus, device, readable storage medium, and program product that can improve the accuracy and efficiency of focus effect evaluation.

[0004] In a first aspect, this application provides an image processing method, the method comprising:

[0005] A target region image is determined from the image to be detected, wherein the target region image includes a foreground object, which is the focus object when the image to be detected was captured;

[0006] The target region image is divided into multiple candidate image blocks.

[0007] Image block filtering is performed on the multiple candidate image blocks to obtain M foreground image blocks, and the sharpness of each foreground image block is determined, where M is a positive integer;

[0008] Each of the foreground image blocks is subjected to image blurring processing to obtain M blurred image blocks, and the sharpness of each of the blurred image blocks is determined;

[0009] Based on the sharpness of each of the foreground image blocks and the sharpness of each of the blurred image blocks, the focus evaluation result of the image to be detected is determined, and the focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

[0010] Secondly, this application provides an image processing apparatus, the apparatus comprising:

[0011] An acquisition module is used to determine a target region image from an image to be detected, wherein the target region image includes a foreground object, and the foreground object is the focus object when the image to be detected is captured;

[0012] The processing module is used to perform image block processing on the target region image to obtain multiple candidate image blocks;

[0013] The processing module is further configured to perform image block filtering processing on the plurality of candidate image blocks to obtain M foreground image blocks, and determine the sharpness of each foreground image block, where M is a positive integer;

[0014] The processing module is further configured to perform image blurring processing on each of the foreground image blocks to obtain M blurred image blocks, and determine the sharpness of each of the blurred image blocks;

[0015] An evaluation module is used to determine the focus evaluation result of the image to be detected based on the sharpness of each of the foreground image blocks and the sharpness of each of the blurred image blocks. The focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

[0016] Thirdly, this application provides a computer device, including: a processor, a storage device, and a communication interface, wherein the processor, the communication interface, and the storage device are interconnected, wherein the storage device stores executable program code, and the processor is used to call the executable program code to implement the image processing method described above.

[0017] Fourthly, this application provides a computer-readable storage medium storing a computer program, the computer program including program instructions that are executed by a processor to implement the image processing method described above.

[0018] Fifthly, this application provides a computer program product, which includes a computer program or computer instructions, which are executed by a processor to implement the image processing method described above.

[0019] This application determines the target region image corresponding to the foreground object from the image to be detected, and performs image block segmentation and image block filtering based on the target region image to obtain M foreground image blocks. This avoids processing non-foreground regions in the image to be detected, reduces computational load, and improves the efficiency of focus effect evaluation. Furthermore, after image block processing, the server can transition from coarse-grained global image features to fine-grained local image features for focus effect evaluation of the image to be detected, fully utilizing the feature information of the image to be detected and improving the accuracy of focus effect evaluation. Based on the idea that the difference in sharpness between sharp and blurred images is large, while the difference in sharpness between blurred images is small, this application determines the focus evaluation result of the image to be detected by the sharpness of each foreground image block and the sharpness of the corresponding blurred image blocks. Compared with manual methods for detecting image focus effect, this achieves automated focus effect evaluation and further improves the accuracy of focus effect evaluation. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0021] Figure 1 This is a schematic diagram of the architecture of an image processing system provided in an exemplary embodiment of this application;

[0022] Figure 2 This is a schematic flowchart of an image processing method provided in an exemplary embodiment of this application;

[0023] Figure 3 This is a schematic flowchart of another image processing method provided in an exemplary embodiment of this application;

[0024] Figure 4 This is a flowchart illustrating a focusing effect evaluation process provided in an exemplary embodiment of this application;

[0025] Figure 5 This is a schematic block diagram of an image processing apparatus provided in an exemplary embodiment of this application;

[0026] Figure 6 This is a schematic block diagram of a computer device provided in an exemplary embodiment of this application. Detailed Implementation

[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0028] It should be noted that the terms "first," "second," etc., used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature specified with "first" or "second" may explicitly or implicitly include at least one of those features.

[0029] The embodiments of this invention can be applied to various fields or scenarios such as cloud computing, cloud IoT, cloud gaming, artificial intelligence, vehicle scenarios, smart transportation, assisted driving, and image focusing effect evaluation. Several typical fields or scenarios will be introduced below.

[0030] Cloud computing refers to the delivery and usage model of IT infrastructure, meaning obtaining necessary resources in an on-demand and easily scalable manner through a network. In a broader sense, cloud computing also refers to the delivery and usage model of services, meaning obtaining necessary services in an on-demand and easily scalable manner through a network. These services can be IT and software related, internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. Driven by the development of the internet, real-time data streams, the diversification of connected devices, and the demands of search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Unlike previous parallel and distributed computing, the emergence of cloud computing will fundamentally revolutionize the entire internet model and enterprise management model. This application can store data such as the image to be detected and focus evaluation results on a cloud server. When these different data are needed, they can be directly retrieved from the cloud server, greatly improving the data acquisition speed.

[0031] Cloud IoT aims to connect the information sensed and commands received by traditional IoT devices to the Internet, truly achieving networking. It also enables massive data storage and computation through cloud computing technology. Due to the nature of IoT, which involves connecting things to each other and sensing the current operating status of each "object" in real time, a large amount of data information is generated in this process. How to aggregate this information and how to sift out useful information from the massive amount of data to support decision-making for future development have become key issues affecting the development of IoT. As a result, IoT cloud based on cloud computing and cloud storage technology has become a powerful support for IoT technology and applications.

[0032] Intelligent Traffic Systems (ITS), also known as Intelligent Transportation Systems, effectively integrate advanced science and technology (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) into transportation, service control, and vehicle manufacturing. This strengthens the connection between vehicles, roads, and users, thereby forming a comprehensive transportation system that ensures safety, improves efficiency, enhances the environment, and saves energy.

[0033] Intelligent Vehicle Infrastructure Cooperative Systems (IVICS), or simply vehicle-road cooperative systems, represent a development direction for Intelligent Transportation Systems (ITS). IVICS utilizes advanced wireless communication and next-generation Internet technologies to implement comprehensive, real-time dynamic information interaction between vehicles and infrastructure. Based on the collection and fusion of dynamic traffic information across all times and spaces, it conducts active vehicle safety control and cooperative road management, fully realizing effective collaboration between people, vehicles, and roads. This ensures traffic safety, improves traffic efficiency, and ultimately forms a safe, efficient, and environmentally friendly road traffic system. This application can be applied to the aforementioned fields. For example, after capturing images of vehicles violating traffic rules using cameras, the focus effect of the captured images can be evaluated, and images with poor focus can be removed, thereby improving the efficiency of law enforcement personnel in detecting violations.

[0034] Currently, image focus evaluation relies on manual judgment of the foreground region's sharpness. This method heavily depends on the evaluator's subjectivity, resulting in low accuracy and efficiency. Therefore, this application proposes combining deep learning object detection, Fourier transform, and Gaussian blur techniques to detect objects in images (e.g., close-up photographs). By comparing the sharpness (e.g., texture intensity) of the image before and after Gaussian blurring, the accuracy of object focus is determined. This method achieves accurate detection of out-of-focus objects in close-up photographs and is applicable to various object types. Furthermore, this application can be applied to close-up image blur detection in various ways, such as post-processing of photographic works and digitization of exhibits, demonstrating broad applicability.

[0035] It is understood that in the specific embodiments of this application, data such as the image to be detected are involved. When the above embodiments of this application are applied to specific products or technologies, the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0036] This application will be specifically illustrated through the following embodiments:

[0037] Please see Figure 1 This figure is a schematic diagram of the architecture of an image processing system provided in an exemplary embodiment of this application. The image processing system may specifically include a terminal device 101 and a server 102. The terminal device 101 and the server 102 are connected via a network, such as a local area network (LAN), a wide area network (WAN), or the mobile internet. The user operates on a browser or client application on the terminal device 101 to perform a focus effect evaluation operation on the image to be detected. The server 102 can respond to this operation by providing a focus effect evaluation service to the user.

[0038] In one embodiment, the terminal device 101 (e.g., a camera) can perform image acquisition on the subject (e.g., a flower) to obtain an image to be detected, and transmit the image to be detected to the server 102; the server 102 determines the target region image from the image to be detected, and performs image block processing and image block filtering processing on the target region image to obtain foreground image blocks; the server 102 then performs image blur processing on the foreground image blocks to obtain blurred image blocks; the server 102 then determines the evaluation result of the image to be detected based on the clarity of each foreground image block and the clarity of each blurred image block.

[0039] In one embodiment, terminal device 101 (e.g., a client for image analysis) can store the image to be detected (e.g., the image to be detected may be obtained from the Internet) and send the image to be detected to server 102; server 102 determines the target region image from the image to be detected, and performs image block processing and image block filtering processing on the target region image to obtain foreground image blocks; server 102 then performs image blur processing on the foreground image blocks to obtain blurred image blocks; server 102 then determines the evaluation result of the image to be detected based on the clarity of each foreground image block and the clarity of each blurred image block, and sends the evaluation result of the image to be detected to terminal device 101, and finally displays the relevant content of image analysis on terminal device 101.

[0040] Terminal equipment 101 is also referred to as terminal, user equipment (UE), access terminal, user unit, mobile device, user terminal, wireless communication equipment, user agent, or user device. Terminal equipment can be smart home appliances, handheld devices with wireless communication capabilities (such as smartphones and tablets), computing devices (such as personal computers (PCs), in-vehicle terminals, smart voice interaction devices, wearable devices, or other smart devices, but is not limited to these).

[0041] Server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0042] In one embodiment, the architecture of the image processing system proposed in this application may further include a database. The database stores data such as the image to be detected and focus evaluation results, as well as parameter data for image processing-related models. This data can be recorded in different database tables. For example, the database can be a database located on a server, i.e., a database built into or integrated with the server; the database can also be an external database connected to the server, such as a cloud database (i.e., a database deployed in the cloud). Specifically, it can be deployed based on any of the following: private cloud, public cloud, hybrid cloud, edge cloud, etc., thus allowing the cloud database to focus on different functions. For example, a database deployed in a private cloud uses basic cloud hardware that is the user's personal device, focusing more on serving a small group of users. A database deployed in a public cloud, on the other hand, is deployed based on a third-party cloud platform, allowing the data stored in the database to be shared. Any user's data can be stored in this database, and any user can also use the data in the database.

[0043] It is understood that the system architecture diagrams described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. For example, the image processing method provided in the embodiments of this application can be executed not only by server 102, but also by other servers or server clusters that are different from server 102 and can communicate with terminal device 101 and / or server 102. Those skilled in the art will understand that... Figure 1 The number of terminal devices and servers shown is merely illustrative. Any number of terminal devices and servers can be configured according to business needs. Furthermore, as system architecture evolves and new business scenarios emerge, the technical solutions provided in this application are also applicable to similar technical problems. In subsequent embodiments, "terminal device" will refer to the aforementioned terminal device 101, and "server" will refer to the aforementioned server 102; further details will not be repeated in subsequent embodiments.

[0044] Please see Figure 2 This figure is a schematic flowchart of an image processing method provided in an exemplary embodiment of this application, applied to a server (referring to...). Figure 1 Taking server 102 as an example, the method may include the following steps:

[0045] S201. Determine the target region image from the image to be detected. The target region image includes a foreground object, which is the object that was in focus when the image to be detected was captured.

[0046] In this embodiment, the image to be detected is the image for which focus effect evaluation is required; the focus object refers to the focus target of the image acquisition device during shooting (the focus target can be automatically determined according to focus rules, or determined based on the focus area selection operation input by the user); the foreground object refers to the image region corresponding to the focus object in the image to be detected (for example, if the focus object is a tree, the foreground object is the image region corresponding to the tree in the image to be detected, which is an irregularly shaped region that matches the outline of the tree); the target region image is the image region obtained by performing object detection processing on the foreground object in the image to be detected (for example, the target region image is a rectangular region including the focus object selected by a rectangular frame in the image to be detected). Since the target region image obtained by object detection processing does not perfectly match the shape of the focus object, non-foreground objects may also exist in the target region image. By obtaining the target region image including the foreground object from the image to be detected, and then performing focus effect evaluation processing on the foreground object based on the target region image, the server avoids processing non-foreground objects in the image to be detected, reduces the amount of computation, and improves the efficiency of focus effect evaluation.

[0047] In one embodiment, the image to be detected can be image data, a specific image frame in a video, or image data generated by computer technologies such as artificial intelligence (AI) algorithms, etc. This application does not limit it in this way.

[0048] In one embodiment, the server can identify the target region image from the image to be detected using an object detection algorithm. During the process of obtaining the target region image using the object detection algorithm, a physical recognition model (e.g., an object recognition network model based on YOLOv3) can be used to process the image to be detected, resulting in multiple predicted bounding boxes. Then, the predicted bounding box with the largest range and highest confidence is selected from these multiple predicted bounding boxes as the foreground object predicted bounding box. The image region corresponding to the foreground object predicted bounding box is the target region image.

[0049] S202. Perform image block processing on the target region image to obtain multiple candidate image blocks.

[0050] In this embodiment, the server can perform image block processing on the target region image, dividing the large image to be detected into multiple smaller image blocks (i.e., multiple candidate image blocks), each candidate image block being a portion of the image to be detected. By performing image block processing on the target region image to obtain multiple candidate image blocks, and then performing subsequent analysis based on the candidate image blocks, the server can transition from coarse-grained global image features to fine-grained local image features to evaluate the focus effect of the image to be detected. This allows the server to fully utilize the feature information of the image to be detected, improving the accuracy of the focus effect evaluation.

[0051] In one embodiment, the target region image is segmented into blocks. This can be done by dividing the target region image into several square regions of the same size (e.g., square regions with a side length of 256 pixels); or by dividing the target region image into several polygonal regions of the same size (e.g., octagonal regions with a side length of 256 pixels; or rectangular regions with a length of 256 pixels and a width of 128 pixels). Dividing the target region image into several candidate image blocks of the same size ensures that the server can extract image features from the same image-sized region based on each candidate image block. This ensures that the subsequent calculation of the sharpness of each candidate image block is based on an equal amount of feature information, thereby improving the accuracy of image focus effect evaluation.

[0052] In one embodiment, any two adjacent candidate image blocks in a plurality of candidate image blocks have a certain proportion of overlap (e.g., the overlap ratio between any two candidate image blocks is 1 / 2). Using the above method, more candidate image blocks can be obtained based on the image to be detected of the same size, thereby improving the utilization rate of image feature information. Furthermore, non-overlapping block segmentation easily leads to boundary gaps in the image, causing the loss of some image information. This application eliminates boundary gaps by using overlapping block segmentation, ensuring the data integrity of the image to be detected.

[0053] S203. Perform image block filtering processing on multiple candidate image blocks to obtain M foreground image blocks, and determine the sharpness of each foreground image block.

[0054] In this embodiment, multiple candidate image blocks are obtained by dividing the image to be detected into blocks using an image segmentation method. Since the target region image includes foreground objects and may also include non-foreground objects, any candidate image block can be either a portion of the image region corresponding to a foreground object or a portion of the image region corresponding to a non-foreground object. This application needs to evaluate the focusing effect of the image region corresponding to the foreground object in the image to be detected. Therefore, it is necessary to filter out the foreground image block corresponding to the foreground object from multiple candidate image blocks.

[0055] In one embodiment, since a color image (RGB image) is a multi-channel image, each pixel in a color image has three values ​​to represent its color, and the correlation between pixel values ​​corresponding to multiple channels is small, with each channel's pixel value representing different color components. In contrast, a grayscale image is a single-channel image, where each pixel corresponds to only one value representing its color. Therefore, before step S201, the original image can be preprocessed to obtain the image to be detected. Specifically, the server first acquires the original image; then, it performs grayscale processing on the original image to obtain the image to be detected.

[0056] At this point, the image to be detected is a grayscale image. The target region image, candidate image block, and blurred image block obtained from the image to be detected are all based on the grayscale image. This ensures that each pixel in the target region image, candidate image block, and blurred image block corresponds to only one pixel value. This allows for the calculation of sharpness based on the unique pixel value corresponding to each pixel, ensuring the feasibility of the method proposed in this application, while reducing the computational load and improving the efficiency of focusing effect evaluation. It should be noted that in the following embodiments, the image to be detected as a grayscale image will be used as an example for illustration, and subsequent embodiments will not be described in detail.

[0057] In one embodiment, the above-described image block filtering process for multiple candidate image blocks to obtain M foreground image blocks can be implemented according to the following steps.

[0058] (a1) For any candidate image block among multiple candidate image blocks, calculate the variance of the pixel values ​​of each pixel point included in the candidate image block to obtain the variance value of the candidate image block.

[0059] In this embodiment of the application, any candidate image block includes multiple pixels, each pixel corresponding to a pixel value. The server can perform variance calculation on the pixel values ​​of each pixel included in any candidate image block to obtain the variance value of any candidate image block.

[0060] The variance of any candidate image patch characterizes the dispersion of the data (i.e., its deviation from the mean). A larger deviation from the mean indicates a larger variance. A larger variance indicates that the candidate image patch contains more information and has greater energy. Therefore, by obtaining the variance of any candidate image patch, the server can effectively determine whether the candidate image patch corresponds to the image region of the foreground object.

[0061] In one embodiment, the variance value is obtained through variance calculation, and the variance value is used to measure the degree of deviation between the random variable and its mathematical expectation (i.e., mean). In addition to variance calculation, other calculation methods (such as standard deviation calculation to obtain the standard deviation value of any candidate image patch) may be used to achieve the above effect, and this embodiment does not limit them.

[0062] (a2) Based on the variance value of each candidate image block, perform image block filtering processing on multiple candidate image blocks to obtain M foreground image blocks; wherein, the foreground image block is a candidate image block whose variance value is greater than or equal to the first threshold among multiple candidate image blocks.

[0063] In this embodiment, the server selects candidate image blocks whose variance value is greater than or equal to a first threshold (variance threshold) from among multiple candidate image blocks as foreground image blocks. The foreground image blocks determined by the above method are highly likely to be the image regions corresponding to the foreground objects.

[0064] In one embodiment, the determination of the sharpness of each foreground image block can be achieved according to the following steps.

[0065] (b1) For any foreground image block among the M foreground image blocks, perform Fourier transform processing on any foreground image block to obtain the spectrum of any foreground image block.

[0066] The Fourier transform process is used to convert the image signal of the foreground image block into a frequency domain signal; while the inverse Fourier transform process is used to convert the frequency domain signal of the foreground image block into an image signal.

[0067] (b2) Perform high-pass filtering on the spectrogram of any foreground image block, and perform inverse Fourier transform on the spectrogram after high-pass filtering to obtain the reconstructed image block of any foreground image block.

[0068] In this embodiment, high-pass filtering removes low-frequency information from the spectrogram of the foreground image block while retaining high-frequency information (such as edge information, texture information, and other low-dimensional features of the foreground image block). Since this application evaluates focus performance based on low-dimensional image features, the above method ensures the accuracy of the focus performance evaluation. The server then performs an inverse Fourier transform on the spectrogram after high-pass filtering to obtain a reconstructed image block for any foreground image block. At this point, the reconstructed image block only includes low-dimensional features such as edge information and texture information.

[0069] High-pass filtering processes the spectrogram of the foreground image patch, outputting a spectrogram with low-frequency components suppressed. Specifically, for the input spectrogram of the foreground image patch, values ​​within a specific bandwidth range near the 0 frequency (i.e., the image center point) are set to 0. For example, if the input spectrogram is 256*256 pixels, the center point is (128, 128), and the bandwidth is 60, then the spectrogram values ​​within the horizontal and vertical coordinate ranges [68, 188] are set to 0.

[0070] In one embodiment, since the 0 frequency in the spectrum is generally located at the four corners of the spectrum, the server can move the 0 frequency of the foreground image block in the spectrum to the center point of the spectrum (i.e., perform a frequency shift operation) before high-pass filtering. This avoids the need to separately filter the frequencies in the spectrum. Figure 4 Instead of removing low-frequency information from the corners, the high-pass filtering process directly removes low-frequency information from the center of the spectrum by defining a circular area with a set radius, thus improving the efficiency of the high-pass filtering. After high-pass filtering, the server can move the 0 frequency in the spectrum back to one of the four corners (e.g., the top left corner) to restore the initial state of the frequency distribution in the spectrum.

[0071] (b3) Determine the sharpness of any foreground image block based on the reconstructed image blocks.

[0072] In this embodiment, the server can determine the sharpness of the foreground image block corresponding to the reconstructed image block based on the pixel values ​​of each pixel in the reconstructed image block. Generally, different images have different sharpness (e.g., texture information sharpness), making it difficult to directly determine whether the image's focus effect is blurry using sharpness alone. However, when a sharp image is blurred to obtain a blurred image, the difference between the sharpness of the sharp image (denoted as g0) and the sharpness of the blurred image (denoted as g1) is significant; simultaneously, the difference in sharpness (denoted as g2) between the blurred image and the blurred image obtained after further blurring is relatively small. Based on this, this application blurs each foreground image block to obtain a blurred image block, reducing the sharpness difference between the various image blocks. The image focus effect is evaluated by judging the sharpness of the foreground image block and the sharpness of the blurred image block, ensuring the accuracy of the evaluation.

[0073] In one embodiment, the above step (b3), which determines the sharpness of any foreground image block based on the reconstructed image block, can be implemented according to the following steps.

[0074] (b31) Process the pixel values ​​of each pixel in the reconstructed image block according to the set processing rules to obtain the processed pixel values ​​of each pixel.

[0075] In this embodiment, the server can preprocess (or standardize) each pixel in the reconstructed image block by setting processing rules to obtain the processed pixel value of each pixel. This method ensures that the feature components of different pixels have the same scale, balancing the contribution of each pixel value to sharpness, thereby guaranteeing the accuracy of sharpness calculation.

[0076] In one embodiment, step (b31) above processes the pixel values ​​of each pixel in the reconstructed image block according to the set processing rules to obtain the processed pixel values ​​of each pixel, which can be implemented according to the following steps.

[0077] (b311) For any pixel in the reconstructed image block, determine the absolute value of the pixel value of any pixel.

[0078] (b312) Perform logarithmic calculation on the absolute value and determine the calculated logarithmic value as the processed pixel value of any pixel.

[0079] By using the methods provided in the above steps (b311-b312), the processed pixel value of any pixel in the reconstructed image block can be obtained, so that the sharpness of the reconstructed image block can be directly calculated using the processed pixel value.

[0080] (b32) Calculate the mean value of each pixel after processing, and determine the sharpness of any foreground image block based on the calculated mean value.

[0081] In this embodiment of the application, the server can determine the sharpness of each foreground image block based on the average value of the processed pixel values ​​of each pixel in the foreground image block. The sharpness of the foreground image block can measure the clarity of the foreground image block, such as edges and textures.

[0082] S204. Perform image blurring on each foreground image block to obtain M blurred image blocks, and determine the sharpness of each blurred image block.

[0083] In this embodiment, the server can perform image blurring on any foreground image block to obtain a blurred image block corresponding to that foreground image block. Since the server performs the above operation on each of the M foreground image blocks, M blurred image blocks are generated.

[0084] In one embodiment, image blurring can be one or more of the following: Gaussian Blur, BoxBlur, Kawase Blur, Dual Blur, Bokeh Blur, Tilt Shift Blur, Iris Blur, Grainy Blur, Radial Blur, Directional Blur, and Motion Blur. When applying Gaussian Blur, the OpenCV GaussianBlur function can be used directly.

[0085] For details on the specific implementation of determining the sharpness of each blurred image block, please refer to the relevant descriptions of steps (b1-b3) in the foregoing embodiments, which will not be repeated here.

[0086] S205. Based on the sharpness of each foreground image block and the sharpness of each blurred image block, determine the focus evaluation result of the image to be detected. The focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

[0087] In this embodiment, since a clear image has higher sharpness and a blurred image has lower sharpness, a blurred image is obtained by blurring the clear image, making the difference in sharpness between the clear and blurred images significant. Conversely, if it is a blurred image, it is blurred again, making the difference in sharpness between the blurred image and the image after further blurring smaller. Applying this idea to focus effect detection, a foreground image block generated from the image to be detected is blurred to obtain a blurred image block. By comparing the sharpness difference between the foreground image block and the blurred image block, the focus effect of the foreground object in the image to be detected is determined. If the sharpness difference between the foreground image block and the blurred image block is large, it indicates that the foreground image block is clearer than the blurred image block, and thus the foreground image block reflects a good focus effect of the image to be detected. If the sharpness difference between the foreground image block and the blurred image block is small, it indicates that the sharpness of the foreground image block is not significant compared to the blurred image block, and thus the foreground image block reflects a poor focus effect of the image to be detected. Since each foreground image block is obtained based on the block division of the image to be detected, the focus effect of the image to be detected can be judged by the sharpness difference corresponding to each foreground image block, and thus the focus evaluation result of the image to be detected can be obtained.

[0088] Based on the above embodiments, the beneficial effects of this application are as follows: This application determines the target region image corresponding to the foreground object from the image to be detected, and performs image segmentation and image block filtering processing based on the target region image to obtain M foreground image blocks. This avoids processing non-foreground regions in the image to be detected, reduces the amount of computation, and improves the efficiency of focus effect evaluation. Furthermore, after image segmentation, the server can transition from coarse-grained global image features to fine-grained local image features for focus effect evaluation of the image to be detected, fully utilizing the feature information of the image to be detected and improving the accuracy of focus effect evaluation. Based on the idea that the difference in sharpness between clear and blurred images is large, while the difference in sharpness between blurred images is small, this application determines the focus evaluation result of the image to be detected by the sharpness of each foreground image block and the sharpness of the blurred image blocks corresponding to each foreground image block. Compared with manual detection of focus effect, this further improves the accuracy of focus effect evaluation.

[0089] This application also proposes dividing the target region image into several candidate image blocks of the same size, so that the server calculates the sharpness of each candidate image block based on an equal amount of feature information, ensuring the accuracy of image focus effect evaluation. This application further proposes overlapping block processing of the image to be detected, allowing the server to obtain more candidate image blocks based on the same size image to be detected, improving the utilization rate of image feature information. Furthermore, overlapping block processing can eliminate the boundary gap problem caused by non-overlapping block processing, ensuring the data integrity of the image to be detected. This application also proposes preprocessing each pixel in the reconstructed image block corresponding to the foreground image block by setting processing rules, obtaining the processed pixel values ​​of each pixel, so that the feature components of different pixels have the same scale, balancing the contribution of each pixel value to sharpness, thereby ensuring the accuracy of sharpness calculation.

[0090] Please see Figure 3 This figure is a schematic flowchart of an image processing method provided in an exemplary embodiment of this application, applied to a server (referring to...). Figure 1 Taking server 102 as an example, the method may include the following steps:

[0091] S301. Determine the target region image from the image to be detected. The target region image includes a foreground object, which is the object that was in focus when the image to be detected was captured.

[0092] S302. Perform image block processing on the target region image to obtain multiple candidate image blocks.

[0093] S303. Perform image block filtering processing on multiple candidate image blocks to obtain M foreground image blocks, and determine the sharpness of each foreground image block.

[0094] S304. Perform image blurring on each foreground image block to obtain M blurred image blocks, and determine the sharpness of each blurred image block.

[0095] The specific implementation methods of steps S301 to S304 are described in the relevant descriptions of steps S201 to S204 in the foregoing embodiments, and will not be repeated here.

[0096] S305. Determine the sharpness ratio between the sharpness of the target foreground image block and the sharpness of the target blurred image block. The target foreground image block is any one of the M foreground image blocks, and the target blurred image block is the blurred image block that matches the target foreground image block among the M blurred image blocks.

[0097] In this embodiment, the target blurred image block is the blurred image block that matches the target foreground image block among M blurred image blocks; that is, the blurred image block is obtained by blurring the target foreground image block. The server can determine the difference in sharpness between the target foreground image block and the target blurred image block through the sharpness ratio.

[0098] S306. Determine the number N of foreground image blocks whose sharpness ratio is less than the second threshold among the M foreground image blocks, where N is a natural number.

[0099] In this embodiment, the image to be detected includes multiple foreground image blocks, each foreground image block corresponding to a sharpness ratio (i.e., the sharpness ratio between the foreground image block and its matching blurred image block). If the sharpness difference is large (i.e., the sharpness ratio is greater than or equal to the second threshold), it indicates that the target foreground image block is a relatively sharp image region in the image to be detected; if the sharpness difference is small (i.e., the sharpness ratio is less than the second threshold), it indicates that the target foreground image block is a relatively blurry image region in the image to be detected. In step S306, the server first needs to determine the number N of relatively blurry image regions in the M foreground image blocks. The focus evaluation result is determined by the ratio of the number N of relatively blurry image regions in the image to be detected to the total number M of image regions. Here, the number M of foreground image blocks is a positive integer. Since there may be no foreground image blocks in the M foreground image blocks whose corresponding sharpness ratio is less than the second threshold, N is a natural number (i.e., N may be 0).

[0100] For example, the sharpness of the target foreground image block is f1, the sharpness of the target blurred image block is f2, and the second threshold is set to 10. The server first calculates the ratio r of the sharpness of the target foreground image block to the sharpness of the target blurred image block, that is, r = f1 / f2. When r is less than 10, the server determines that the target foreground image block is one of the M foreground image blocks whose sharpness ratio is less than the second threshold; when r is greater than or equal to 10, the server determines that the target foreground image block is not one of the M foreground image blocks whose sharpness ratio is less than the second threshold.

[0101] S307. Determine the ratio of the number of N to M. If the ratio is greater than or equal to the third threshold, then determine the focus evaluation result of the image to be detected as the first focus evaluation result. The first focus evaluation result is used to indicate that the foreground object in the image to be detected is in focus and blurred.

[0102] In this embodiment, if the number of foreground image blocks in the image to be detected whose sharpness ratio is greater than or equal to the second threshold satisfies the quantity condition (that is, the ratio of N to M is greater than or equal to the third threshold), it indicates that the proportion of the image region with relatively blurred focus in the image to be detected is large, and the proportion threshold has been met. At this time, the server can determine that the focus state of the image to be detected is that the foreground object is blurred.

[0103] In one embodiment, the first focus evaluation result can be in the form of an image focus effect score (e.g., the image focus effect score ranges from [0, 100], the better the image focus effect, the closer the image focus effect score is to 100; the worse the image focus effect, the closer the image focus effect score is to 0); the first focus evaluation result can also be in the form of an image focus effect level (e.g., image focus effect levels include level one, level two, level three, level four, and level five, the better the image focus effect, the closer the image focus effect level is to level five; the worse the image focus effect, the closer the image focus effect level is to level one). This method improves the flexibility of setting the focus evaluation result, thereby enriching the data format of the evaluation result.

[0104] S308. If the quantity ratio is less than the third threshold, the focus evaluation result of the image to be detected is determined as the second focus evaluation result. The second focus evaluation result is used to indicate that the foreground object in the image to be detected is in focus.

[0105] In this embodiment, if the number of foreground image blocks in the image to be detected whose sharpness ratio is greater than or equal to the second threshold does not meet the quantity condition (i.e., the ratio of N to M is less than the third threshold), it indicates that the proportion of the image region with relatively blurred focus in the image to be detected is small, and the proportion threshold is not met. In this case, the server can determine that the focus state of the image to be detected is that the foreground object is in sharp focus. The server determines the image to be detected as blurred if the proportion of the image region with relatively blurred focus is large, and as long as the proportion of the image region with relatively blurred focus is small, the image to be detected is determined to be in sharp focus. Through the above method, the focus effect evaluation of the image is automated, and the efficiency of focus effect evaluation is improved.

[0106] The format of the second focus evaluation result is the same as that of the first focus evaluation result mentioned above, and will not be repeated here.

[0107] Please see Figure 4 , Figure 4 This is a flowchart of a focusing effect evaluation process provided in an embodiment of this application. The server first performs foreground object recognition processing on the image to be detected to obtain a target region image; then, it performs image block processing on the target region image to obtain foreground image blocks (M blocks); the server then performs Gaussian blur processing on each foreground image block to obtain blurred image blocks (M blocks); the server performs sharpness calculation on the foreground image blocks (including Fourier transform processing, high-pass filtering processing, and inverse Fourier transform processing) to obtain the sharpness f1 of each foreground image block, and performs sharpness calculation on the blurred image blocks to obtain the sharpness f2 of each blurred image block; the sharpness ratio r (r = f1 / f2) is calculated for the sharpness of any foreground image block and the sharpness of the corresponding blurred image block. If r is less than a threshold, then any foreground image block is determined to be in focus and blurred; if r is greater than or equal to the threshold, then any foreground image block is determined to be in focus and sharp. The above method can be used to determine the focus evaluation results of each foreground image block obtained by dividing the image to be detected into blocks. When the server determines that the number of blurry foreground image blocks meets the condition of the total number of foreground image blocks, it can determine that the image to be detected is blurry; otherwise, it can determine that the image to be detected is sharp.

[0108] The focus effect evaluation method provided in this application, when applied to image processing, first requires acquiring multiple images uploaded by the object, and then transmitting these images to the focus effect evaluation algorithm (including...) via an interface. Figure 4The algorithm (corresponding to each processing step in the process) processes the input image to determine the focus effect of each image; finally, it returns the focus effect evaluation results of all images in the form of a JSON file through an interface. The technical solution of this application focuses on images of objects taken at close range, and can automatically determine whether the object of interest is in focus without manual processing. The algorithm based on traditional FFT has universality for various scenes and objects; the method based on the comparison of texture intensity before and after Gaussian blur ensures the universality of the judgment on different types of texture surfaces, thereby improving the applicability of the focus effect evaluation method provided in this application.

[0109] Based on the above embodiments, the beneficial effects of this application are as follows: This application proposes to determine the sharpness ratio of each foreground image block and its corresponding blurred image block. When the ratio of the number of foreground image blocks with a sharpness ratio less than a second threshold to the total number of foreground image blocks is greater than or equal to a third threshold, the image to be detected is determined to be in focus and blurred; otherwise, the image to be detected is determined to be in focus and sharp. Through the above method, the server can estimate the focus evaluation result of the global image based on the focus evaluation information obtained from the local image, ensuring the reliability and accuracy of the focus evaluation result. This application also proposes to flexibly set multiple data formats for the focus evaluation result, enriching the data format of the evaluation result.

[0110] Please see Figure 5 This figure is a schematic block diagram of an image processing apparatus provided in an embodiment of this application. Specifically, the image processing apparatus may include:

[0111] The acquisition module 501 is used to determine a target region image from the image to be detected, wherein the target region image includes a foreground object, and the foreground object is the focus object when the image to be detected is captured.

[0112] Processing module 502 is used to perform image block processing on the above-mentioned target area image to obtain multiple candidate image blocks;

[0113] The aforementioned processing module 502 is further configured to perform image block filtering processing on the aforementioned multiple candidate image blocks to obtain M foreground image blocks, and determine the sharpness of each of the aforementioned foreground image blocks, where M is a positive integer;

[0114] The aforementioned processing module 502 is further configured to perform image blurring processing on each of the aforementioned foreground image blocks to obtain M blurred image blocks, and to determine the sharpness of each of the aforementioned blurred image blocks.

[0115] Evaluation module 503 is used to determine the focus evaluation result of the image to be detected based on the sharpness of each of the foreground image blocks and the sharpness of each of the blurred image blocks. The focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

[0116] Optionally, when the processing module 502 performs image block filtering on the plurality of candidate image blocks to obtain M foreground image blocks, it is specifically used for:

[0117] For any candidate image block among the above multiple candidate image blocks, the variance of the pixel values ​​of each pixel included in the above candidate image block is calculated to obtain the variance value of the above candidate image block.

[0118] Based on the variance value of each candidate image block, image block filtering processing is performed on the above multiple candidate image blocks to obtain M foreground image blocks; wherein, the above foreground image blocks are candidate image blocks whose variance value is greater than or equal to a first threshold among the above multiple candidate image blocks.

[0119] Optionally, when determining the sharpness of each of the aforementioned foreground image blocks, the processing module 502 is specifically used for:

[0120] For any one of the M foreground image blocks mentioned above, perform Fourier transform processing on any one of the foreground image blocks to obtain the spectrum of any one of the foreground image blocks.

[0121] High-pass filtering is performed on the spectrogram of any of the foreground image blocks, and inverse Fourier transform is performed on the spectrogram after high-pass filtering to obtain the reconstructed image block of any of the foreground image blocks.

[0122] The sharpness of any of the foreground image blocks is determined based on the reconstructed image blocks described above.

[0123] Optionally, when the processing module 502 determines the sharpness of any of the foreground image blocks based on the reconstructed image blocks, it specifically performs the following:

[0124] The pixel values ​​of each pixel in the above reconstructed image block are processed according to the set processing rules to obtain the processed pixel values ​​of each pixel.

[0125] The average value of the processed pixel values ​​of each pixel is calculated, and the sharpness of any foreground image block is determined based on the calculated average value.

[0126] Optionally, when the processing module 502 processes the pixel values ​​of each pixel in the reconstructed image block according to a set processing rule to obtain the processed pixel values ​​of each pixel, it is specifically used for:

[0127] For any pixel in the reconstructed image block, determine the absolute value of the pixel value of that pixel;

[0128] Perform a logarithmic calculation on the absolute values ​​above, and determine the resulting logarithmic value as the processed pixel value of any of the above pixels.

[0129] Optionally, when the evaluation module 503 determines the focus evaluation result of the image to be detected based on the sharpness of each of the foreground image blocks and the sharpness of each of the blurred image blocks, it is specifically used for:

[0130] Determine the sharpness ratio between the sharpness of the target foreground image block and the sharpness of the target blurred image block, wherein the target foreground image block is any one of the M foreground image blocks and the target blurred image block is the blurred image block that matches the target foreground image block among the M blurred image blocks.

[0131] Determine the number N of the above M foreground image blocks whose sharpness ratio is less than the second threshold, where N is a natural number;

[0132] Determine the ratio of N to M, and based on this ratio, determine the focus evaluation result of the image to be detected.

[0133] Optionally, when the evaluation module 503 is used to determine the focus evaluation result of the image to be detected based on the aforementioned quantity ratio, it is specifically used for:

[0134] If the above quantity ratio is greater than or equal to the third threshold, the focus evaluation result of the above image to be detected is determined as the first focus evaluation result. The first focus evaluation result is used to indicate that the foreground object in the above image to be detected is in focus and blurred.

[0135] If the above-mentioned quantity ratio is less than the above-mentioned third threshold, then the focus evaluation result of the above-mentioned image to be detected is determined as the second focus evaluation result, and the second focus evaluation result is used to indicate that the above-mentioned foreground object in the above-mentioned image to be detected is in focus.

[0136] Optionally, the acquisition module 501 described above is also used for:

[0137] Obtain the original image;

[0138] The original image is converted to grayscale to obtain the image to be detected.

[0139] It should be noted that the functions of each functional module of the image processing device in this application embodiment can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can be referred to the relevant descriptions in the above method embodiments, which will not be repeated here.

[0140] Please see Figure 6This figure is a schematic block diagram of a computer device provided in an embodiment of this application. As shown in the figure, the smart terminal in this embodiment may include: a processor 601, a storage device 602, and a communication interface 603. The processor 601, the storage device 602, and the communication interface 603 can interact with each other.

[0141] The aforementioned storage device 602 may include volatile memory, such as random-access memory (RAM); the storage device 602 may also include non-volatile memory, such as flash memory, solid-state drive (SSD), etc.; the aforementioned storage device 602 may also include a combination of the above types of memory.

[0142] The processor 601 described above may be a central processing unit (CPU). In one embodiment, the processor 601 may also be a graphics processing unit (GPU). The processor 601 may also be a combination of a CPU and a GPU. In one embodiment, the storage device 602 is used to store program instructions, and the processor 601 can invoke these program instructions to perform the following operations:

[0143] A target region image is determined from the image to be detected, wherein the target region image includes a foreground object, which is the focus object when the image to be detected was captured.

[0144] The target region image is divided into multiple candidate image blocks.

[0145] Image block filtering is performed on the above candidate image blocks to obtain M foreground image blocks, and the sharpness of each of the above foreground image blocks is determined, where M is a positive integer;

[0146] The above-mentioned foreground image blocks are subjected to image blurring processing to obtain M blurred image blocks, and the sharpness of each of the above-mentioned blurred image blocks is determined.

[0147] Based on the sharpness of each of the aforementioned foreground image blocks and the sharpness of each of the aforementioned blurred image blocks, the focus evaluation result of the aforementioned image to be detected is determined, and the focus evaluation result is used to indicate the focus effect of the aforementioned foreground object in the aforementioned image to be detected.

[0148] Optionally, when the processor 601 performs image block filtering on the plurality of candidate image blocks to obtain M foreground image blocks, it is specifically used for:

[0149] For any candidate image block among the above multiple candidate image blocks, the variance of the pixel values ​​of each pixel included in the above candidate image block is calculated to obtain the variance value of the above candidate image block.

[0150] Based on the variance value of each candidate image block, image block filtering processing is performed on the above multiple candidate image blocks to obtain M foreground image blocks; wherein, the above foreground image blocks are candidate image blocks whose variance value is greater than or equal to a first threshold among the above multiple candidate image blocks.

[0151] Optionally, when determining the sharpness of each of the aforementioned foreground image blocks, the processor 601 specifically performs the following:

[0152] For any one of the M foreground image blocks mentioned above, perform Fourier transform processing on any one of the foreground image blocks to obtain the spectrum of any one of the foreground image blocks.

[0153] High-pass filtering is performed on the spectrogram of any of the foreground image blocks, and inverse Fourier transform is performed on the spectrogram after high-pass filtering to obtain the reconstructed image block of any of the foreground image blocks.

[0154] The sharpness of any of the foreground image blocks is determined based on the reconstructed image blocks described above.

[0155] Optionally, when the processor 601 determines the sharpness of any of the foreground image blocks based on the reconstructed image blocks, it specifically performs the following:

[0156] The pixel values ​​of each pixel in the above reconstructed image block are processed according to the set processing rules to obtain the processed pixel values ​​of each pixel.

[0157] The average value of the processed pixel values ​​of each pixel is calculated, and the sharpness of any foreground image block is determined based on the calculated average value.

[0158] Optionally, when the processor 601 processes the pixel values ​​of each pixel in the reconstructed image block according to a set processing rule to obtain the processed pixel values ​​of each pixel, it specifically performs the following:

[0159] For any pixel in the reconstructed image block, determine the absolute value of the pixel value of that pixel;

[0160] Perform a logarithmic calculation on the absolute values ​​above, and determine the resulting logarithmic value as the processed pixel value of any of the above pixels.

[0161] Optionally, when the processor 601 determines the focus evaluation result of the image to be detected based on the sharpness of each of the foreground image patches and the sharpness of each of the blurred image patches, it is specifically used for:

[0162] Determine the sharpness ratio between the sharpness of the target foreground image block and the sharpness of the target blurred image block, wherein the target foreground image block is any one of the M foreground image blocks and the target blurred image block is the blurred image block that matches the target foreground image block among the M blurred image blocks.

[0163] Determine the number N of the above M foreground image blocks whose sharpness ratio is less than the second threshold, where N is a natural number;

[0164] Determine the ratio of N to M, and based on this ratio, determine the focus evaluation result of the image to be detected.

[0165] Optionally, when the processor 601 determines the focus evaluation result of the image to be detected based on the aforementioned quantity ratio, it is specifically used for:

[0166] If the above quantity ratio is greater than or equal to the third threshold, the focus evaluation result of the above image to be detected is determined as the first focus evaluation result. The first focus evaluation result is used to indicate that the foreground object in the above image to be detected is in focus and blurred.

[0167] If the above-mentioned quantity ratio is less than the above-mentioned third threshold, then the focus evaluation result of the above-mentioned image to be detected is determined as the second focus evaluation result, and the second focus evaluation result is used to indicate that the above-mentioned foreground object in the above-mentioned image to be detected is in focus.

[0168] Optionally, the processor 601 described above is also used for:

[0169] Obtain the original image;

[0170] The original image is converted to grayscale to obtain the image to be detected.

[0171] In specific implementation, the processor 601, storage device 602, and communication interface 603 described in the embodiments of this application can execute the embodiments of this application. Figure 2 or Figure 3 The implementation methods described in the relevant embodiments of the provided image processing method can also be used to execute the embodiments of this application. Figure 5 The implementation methods described in the relevant embodiments of the provided image processing apparatus will not be repeated here.

[0172] In the several embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, and systems can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and other division methods may exist in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0173] Furthermore, it should be noted that this application embodiment also provides a computer-readable storage medium storing a computer program executed by the aforementioned image processing apparatus, and the computer program includes program instructions. When the processor executes the aforementioned program instructions, it can execute the aforementioned... Figure 2 , Figure 3 The methods described in the corresponding embodiments will not be repeated here. Furthermore, the beneficial effects of using the same methods will also not be repeated. For technical details not disclosed in the computer-readable storage medium embodiments related to this application, please refer to the description of the method embodiments of this application. As an example, program instructions can be deployed on a computer device, or executed on multiple computer devices located in one location, or executed on multiple computer devices distributed across multiple locations and interconnected via a communication network. These multiple computer devices distributed across multiple locations and interconnected via a communication network can constitute a blockchain system.

[0174] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned... Figure 2 , Figure 3 The methods described in the corresponding embodiments are therefore not repeated here.

[0175] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0176] The above-disclosed embodiments are merely some of the embodiments of this application, and should not be construed as limiting the scope of this application. Those skilled in the art can understand that implementing all or part of the above embodiments and making equivalent changes in accordance with the claims of this application still fall within the scope of the invention.

Claims

1. An image processing method, characterized in that, The method includes: A target region image is determined from the image to be detected, wherein the target region image includes a foreground object, which is the focus object when the image to be detected was captured; The target region image is divided into multiple candidate image blocks. Image block filtering is performed on the multiple candidate image blocks to obtain M foreground image blocks, and the sharpness of each foreground image block is determined, where M is a positive integer; Each of the foreground image blocks is subjected to image blurring processing to obtain M blurred image blocks, and the sharpness of each blurred image block is determined; the sharpness is used to measure the clarity of the texture of the image block; Determine the sharpness ratio between the sharpness of the target foreground image block and the sharpness of the target blurred image block, wherein the target foreground image block is any one of the M foreground image blocks, and the target blurred image block is the blurred image block that matches the target foreground image block among the M blurred image blocks; Determine the number N of the M foreground image blocks whose sharpness ratio is less than the second threshold, where N is a natural number; The ratio of N to M is determined, and the focus evaluation result of the image to be detected is determined based on the ratio. The focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

2. The method according to claim 1, characterized in that, The image block filtering process, which involves selecting multiple candidate image blocks to obtain M foreground image blocks, includes: For any candidate image block among the plurality of candidate image blocks, the variance of the pixel values ​​of each pixel point included in the candidate image block is calculated to obtain the variance value of the candidate image block. Based on the variance value of each candidate image block, image block filtering processing is performed on the plurality of candidate image blocks to obtain M foreground image blocks; wherein, the foreground image blocks are candidate image blocks whose variance value is greater than or equal to a first threshold among the plurality of candidate image blocks.

3. The method according to claim 1, characterized in that, Determining the sharpness of each of the foreground image blocks includes: For any one of the M foreground image blocks, perform Fourier transform processing on the foreground image block to obtain the spectrum of the foreground image block; A high-pass filter is applied to the spectrogram of any foreground image block, and an inverse Fourier transform is applied to the spectrogram after high-pass filtering to obtain a reconstructed image block of any foreground image block. The sharpness of any foreground image block is determined based on the reconstructed image block.

4. The method according to claim 3, characterized in that, Determining the sharpness of any foreground image patch based on the reconstructed image patch includes: The pixel values ​​of each pixel in the reconstructed image block are processed according to the set processing rules to obtain the processed pixel values ​​of each pixel. The average value of each processed pixel is calculated, and the sharpness of any foreground image block is determined based on the calculated average value.

5. The method according to claim 4, characterized in that, The step of processing the pixel values ​​of each pixel in the reconstructed image block according to the set processing rules to obtain the processed pixel values ​​of each pixel includes: For any pixel in the reconstructed image block, determine the absolute value of the pixel value of that pixel; Perform a logarithmic calculation on the absolute value, and determine the calculated logarithmic value as the processed pixel value of any pixel.

6. The method according to any one of claims 1-5, characterized in that, Determining the focus evaluation result of the image to be detected based on the quantity ratio includes: If the quantity ratio is greater than or equal to the third threshold, the focus evaluation result of the image to be detected is determined to be the first focus evaluation result, which is used to indicate that the foreground object in the image to be detected is in focus and blurred. If the ratio of the number is less than the third threshold, the focus evaluation result of the image to be detected is determined to be the second focus evaluation result, which is used to indicate that the foreground object in the image to be detected is in focus.

7. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain the original image; The original image is converted to grayscale to obtain the image to be detected.

8. An image processing apparatus, characterized in that, The device includes: An acquisition module is used to determine a target region image from an image to be detected, wherein the target region image includes a foreground object, and the foreground object is the focus object when the image to be detected is captured; The processing module is used to perform image block processing on the target region image to obtain multiple candidate image blocks; The processing module is further configured to perform image block filtering processing on the plurality of candidate image blocks to obtain M foreground image blocks, and determine the sharpness of each foreground image block, where M is a positive integer; The processing module is further configured to perform image blurring processing on each of the foreground image blocks to obtain M blurred image blocks, and determine the sharpness of each blurred image block; the sharpness is used to measure the clarity of the texture of the image block; An evaluation module is used to determine the sharpness ratio between the sharpness of a target foreground image patch and the sharpness of a target blurred image patch, wherein the target foreground image patch is any one of the M foreground image patches, and the target blurred image patch is the blurred image patch that matches the target foreground image patch among the M blurred image patches; The evaluation module is also used to determine the number N of foreground image blocks whose sharpness ratio is less than the second threshold among the M foreground image blocks, where N is a natural number; The evaluation module is further configured to determine the ratio of N to M, and determine the focus evaluation result of the image to be detected based on the ratio. The focus evaluation result is used to indicate the focus effect of the foreground object in the image to be detected.

9. A computer device, characterized in that, include: The processor, the communication interface, and the storage device are interconnected, wherein the storage device stores executable program code, and the processor is used to call the executable program code to implement the image processing method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that are executed by a processor to implement the image processing method as described in any one of claims 1-7.

11. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, are used to implement the image processing method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • An image focusing method and related equipment thereof

    CN109635800A

  • Focusing method and device, electronic device and storage medium

    CN110278383A