A method and apparatus for image quality assessment
Patent Information
- Application Number
- CN202311318297.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2043-10-11
AI Technical Summary
但是,在对现有技术的研究和实践过程中,本申请的发明人发现,现有的评估方法对于证件照均不太适用,比如,基于结构相似性的图像质量评估方法是基于图像像素间的相关性构造出参考图像与待评图像之间的结构相似性(其结构相似度越大,图像质量越好),因此该评价方法需要一张质量较佳的图片作为参考图片,而这对结构性不明显或者非结构性的质量不佳的图片,比如质量不佳的证件照,其有效性会大打折扣甚至失效
[0039]本申请实施例可以获取待评估证件照的亮度图像,将该亮度图像分割为头发区域的亮度图和肤色区域的亮度图,然后,分别根据头发区域和肤色区域的亮度图计算这两个区域的亮度均值,以及计算这两个区域的亮度均值的比值(即第一比值),基于这两个区域的亮度均值和比值对该待评估证件照的质量进行评估,比如,当头发区域的亮度均值大于预设的头发亮度阈值时,确定该待评估证件照为灰蒙图像,当头发区域的亮度均值小于等于预设头发亮度阈值,且第一比值大于预设的比值阈值时,确定该待评估证件照为正常图像,等等;由于该方案对图像的结构性要求不高,因此,对于非结构的图像、或轻微灰蒙、模糊的证件照也能准确地进行评估,而且,由于无需设置相应的高质量参考图像或采集大量多样性的训练样本,因此,实现也较为简单。此外,由于在评估时充分考虑了证件照的特性,利用光线在不同物体表面上反射和散射的不同,将头发和肤色这两个区域的亮度均值的特点和彼此之间的关系等多重因素作为评估依据,因此,可以大大提高评估的准确性,改善评估效果,进而降低制证时废本的概率。
Smart Images

Figure CN117372362B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more particularly to an image quality assessment method and apparatus. Background Technology
[0002] A portrait ID photo, also known as a passport photo or simply an ID photo, refers to a portrait photograph used for identity verification purposes such as passports, visas, ID cards, driver's licenses, and medical insurance. Given the special purpose of ID photos, their image quality requirements are generally high. For example, ID photos used for making ID cards need to meet the requirements of the Digital Photographic Technology Standard (GA461-2004), which requires the portrait photo to be clear, with rich detail, a natural expression, no obvious distortion, and consistent angle, pose, and color. However, in actual shooting, due to dust on the lens or lighting issues, the resulting portrait photos often suffer from quality problems such as haziness and blurriness. If these problems are not detected during the document production process, the produced document can easily become unusable due to its substandard quality. Therefore, image quality assessment of ID photos is essential.
[0003] In existing technologies, image quality assessment mainly includes several methods, one of which is based on structural similarity, and another is based on machine learning. However, during the research and practice of existing technologies, the inventors of this application found that existing assessment methods are not very suitable for ID photos. For example, image quality assessment methods based on structural similarity construct the structural similarity between the reference image and the image to be evaluated based on the correlation between image pixels (the greater the structural similarity, the better the image quality). Therefore, this evaluation method requires a high-quality image as a reference image. However, for images with unclear structure or poor quality due to lack of structure, such as poor-quality ID photos, its effectiveness is greatly reduced or even fails. Furthermore, because machine learning-based image quality assessment methods are highly dependent on the quantity and diversity of training samples, collecting a sufficient number of diverse real training samples is extremely difficult in reality. Therefore, insufficient training often occurs, which reduces the robustness of the model to image quality assessment. In other words, existing methods for assessing the image quality of ID photos are not only difficult to implement, but also prone to misjudgment of slightly gray or blurry ID photos, resulting in poor assessment results and the production of defective ID cards. Summary of the Invention
[0004] The main objective of this invention is to provide an image quality assessment method and apparatus that can be applied to the image quality assessment of ID photos. It is not only simple to implement, but also greatly improves the accuracy of the assessment, enhances the assessment effect, and reduces the probability of rejecting ID photos during production.
[0005] To achieve the above objectives, embodiments of the present invention provide an image quality assessment method, comprising:
[0006] Obtain the brightness image of the ID photo to be evaluated;
[0007] The brightness image is segmented into a brightness map of the hair region and a brightness map of the skin region;
[0008] Calculate the mean brightness of the hair region based on the brightness map of the hair region, and calculate the mean brightness of the skin region based on the brightness map of the skin region;
[0009] Calculate the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain the first ratio;
[0010] When the average brightness of the hair area is greater than the preset hair brightness threshold, the ID photo to be evaluated is determined to be a grayscale image;
[0011] When the average brightness of the hair area is less than or equal to a preset hair brightness threshold, and the first ratio is greater than a preset ratio threshold, the ID photo to be evaluated is determined to be a normal image.
[0012] In the image quality assessment method of the present invention, when the first ratio is less than or equal to a preset ratio threshold, the average edge intensity of the ID photo to be evaluated is obtained.
[0013] If the average edge intensity is greater than the preset edge intensity threshold, then the ID photo to be evaluated is determined to be a normal image;
[0014] If the average edge intensity is less than or equal to a preset edge intensity threshold, then the feature value of the center position of the histogram peak of the brightness image is obtained.
[0015] If the feature value of the center position of the histogram peak is greater than or equal to the preset position threshold, then the ID photo to be evaluated is determined to be a normal image;
[0016] If the feature value of the center position of the histogram peak is less than the preset position threshold, then the ID photo to be evaluated is determined to be a grayscale image.
[0017] In the image quality assessment method of the present invention, after segmenting the brightness image into a brightness map of the hair region and a brightness map of the skin region, the method further includes:
[0018] The number of pixels with non-zero brightness values in the hair region is counted based on the brightness map of the hair region, and the proportion of the number of pixels with non-zero brightness values in the hair region in the brightness image is calculated.
[0019] If the percentage is less than a preset empirical value, the average edge intensity of the ID photo to be evaluated is obtained; if the average edge intensity is greater than a preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image; if the average edge intensity is less than or equal to the preset edge intensity threshold, the feature value of the center position of the histogram peak of the brightness image is obtained; if the feature value of the center position of the histogram peak is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image; if the feature value of the center position of the histogram peak is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0020] If the percentage is greater than or equal to a preset empirical value, then the steps of calculating the average brightness of the hair region based on the brightness map of the hair region and calculating the average brightness of the skin region based on the brightness map of the skin region are performed.
[0021] In the image quality assessment method of the present invention, if it is impossible to segment the brightness image into a brightness map of the hair region and a brightness map of the skin region, then the average edge intensity of the ID photo to be evaluated is obtained.
[0022] If the average edge intensity is greater than the preset edge intensity threshold, then the ID photo to be evaluated is determined to be a normal image;
[0023] If the average edge intensity is less than or equal to a preset edge intensity threshold, then the feature value of the center position of the histogram peak of the brightness image is obtained.
[0024] If the feature value of the center position of the histogram peak is greater than or equal to the preset position threshold, then the ID photo to be evaluated is determined to be a normal image;
[0025] If the feature value of the center position of the histogram peak is less than the preset position threshold, then the ID photo to be evaluated is determined to be a grayscale image.
[0026] In the image quality assessment method of the present invention, obtaining the average edge intensity of the ID photo to be assessed includes:
[0027] The photo of the ID card to be evaluated is converted into a grayscale image, and the edge image of the grayscale image is calculated;
[0028] Remove the false edges from the edge image to obtain the adjusted edge image;
[0029] The variance of the adjusted edge image is calculated to obtain the average edge intensity of the ID photo to be evaluated.
[0030] In the image quality assessment method of the present invention, after determining that the ID photo to be assessed is a grayscale image, the method further includes:
[0031] The photo to be evaluated is processed using a preset image restoration transformation function to obtain the processed photo.
[0032] The brightness and details of the processed ID photo are restored by using a preset dynamic upscaling factor to obtain the restored ID photo.
[0033] Accordingly, embodiments of this application also provide an image quality assessment device, including:
[0034] The acquisition unit is used to acquire the brightness image of the ID photo to be evaluated;
[0035] A segmentation unit is used to segment the brightness image into a brightness map of the hair region and a brightness map of the skin region;
[0036] A brightness calculation unit is used to calculate the average brightness of the hair region based on the brightness map of the hair region, and to calculate the average brightness of the skin region based on the brightness map of the skin region.
[0037] The ratio calculation unit is used to calculate the ratio of the average brightness of the hair region to the average brightness of the skin region, and obtain the first ratio.
[0038] The evaluation unit is used to determine that the ID photo to be evaluated is a gray image when the average brightness of the hair area is greater than a preset hair brightness threshold; and to determine that the ID photo to be evaluated is a normal image when the average brightness of the hair area is less than or equal to the preset hair brightness threshold and the first ratio is greater than a preset ratio threshold.
[0039] This application embodiment can acquire a brightness image of the ID photo to be evaluated, segment the brightness image into a brightness map of the hair region and a brightness map of the skin region, and then calculate the average brightness of the two regions based on the brightness maps of the hair region and the skin region, as well as the ratio of the average brightness of the two regions (i.e., the first ratio). The quality of the ID photo to be evaluated is evaluated based on the average brightness of the two regions and the ratio. For example, when the average brightness of the hair region is greater than a preset hair brightness threshold, the ID photo to be evaluated is determined to be a gray image; when the average brightness of the hair region is less than or equal to the preset hair brightness threshold and the first ratio is greater than a preset ratio threshold, the ID photo to be evaluated is determined to be a normal image, and so on. Since this scheme does not have high requirements for the structure of the image, it can accurately evaluate unstructured images or slightly gray or blurry ID photos. Moreover, since there is no need to set up corresponding high-quality reference images or collect a large number of diverse training samples, the implementation is also relatively simple. Furthermore, because the characteristics of ID photos are fully considered during the evaluation, and multiple factors such as the characteristics of the average brightness of the hair and skin areas and their relationship are used as evaluation criteria, the accuracy of the evaluation can be greatly improved, the evaluation effect can be enhanced, and the probability of rejecting ID cards can be reduced. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 This is a flowchart of the image quality assessment method provided in the embodiments of this application;
[0042] Figure 2 This is an example diagram of the histogram of the ID photo sample in the embodiments of this application;
[0043] Figure 3 This is an example diagram of the histogram of the ID photo to be evaluated in the embodiments of this application;
[0044] Figure 4 This is another example diagram of the histogram of the ID photo to be evaluated in the embodiments of this application;
[0045] Figure 5 Another flowchart of the image quality assessment method provided in the embodiments of this application;
[0046] Figure 6 This is a framework diagram of the image quality assessment method in the embodiments of this application;
[0047] Figure 7 This is a schematic diagram of the image quality assessment device provided in an embodiment of this application. Detailed Implementation
[0048] 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 skilled in the art without creative effort are within the scope of protection of this application.
[0049] This application provides an image quality assessment method and apparatus, which will be described in detail below.
[0050] This embodiment will be described from the perspective of an image quality assessment device, which can be integrated into network devices, such as servers or terminals.
[0051] An image quality assessment method includes: acquiring a brightness image of a passport photo to be assessed; segmenting the brightness image into a brightness map of a hair region and a brightness map of a skin region; calculating the average brightness of the hair region based on the brightness map of the hair region, and calculating the average brightness of the skin region based on the brightness map of the skin region; calculating the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain a first ratio; determining the passport photo to be assessed as a grayscale image when the average brightness of the hair region is greater than a preset hair brightness threshold; and determining the passport photo to be assessed as a normal image when the average brightness of the hair region is less than or equal to the preset hair brightness threshold and the first ratio is greater than a preset ratio threshold.
[0052] like Figure 1 As shown, the specific process of this image quality assessment method can be as follows:
[0053] 101. Obtain the brightness image of the ID photo to be evaluated.
[0054] For example, the brightness value of each pixel in the ID photo to be evaluated can be obtained separately, and then a brightness image of the ID photo to be evaluated can be generated based on the obtained pixel brightness values.
[0055] There are several ways to obtain the brightness value of each pixel in the ID photo to be evaluated. For example, it can be done as follows:
[0056] Obtain the red channel value (R, Red), green channel value (G, Green), and blue channel value (B, Blue) of each pixel in the ID photo to be evaluated, and select the maximum value among the three as the brightness value of the pixel.
[0057] In other words, the formula for extracting the brightness of a pixel can be as follows:
[0058] bI(x,y)=max(R,G,B);
[0059] Wherein, R, G, and B are the red, green, and blue channels of the ID photo (color image) to be evaluated, (x,y) is the coordinate value of the image pixel in the image coordinate system, max(R,G,B) is the maximum value of R, G, and B of the pixel point (x,y) in the image coordinate system as the brightness value of the pixel point, and bI(x,y) is the brightness image.
[0060] 102. Divide the brightness image into a brightness map of the hair region and a brightness map of the skin region; for example, it can be done as follows:
[0061] Obtain preset hair segmentation thresholds, skin segmentation high thresholds, and skin segmentation low thresholds; determine the regions in the brightness image whose brightness is greater than the hair segmentation thresholds to obtain non-hair regions, and adjust the brightness values of the non-hair regions in the brightness image to 0 to obtain the brightness map of the hair regions; determine the regions in the brightness image whose brightness is less than or equal to the skin segmentation high threshold and greater than the skin segmentation low threshold to obtain skin regions, and adjust the brightness values of all regions in the brightness image except for the skin regions to 0 to obtain the brightness map of the skin regions. This can be expressed by the following formula:
[0062]
[0063]
[0064] Wherein, bI(x,y) is the brightness image of the ID photo to be evaluated, hBI(x,y) is the brightness map of the hair region, sBI(x,y) is the brightness map of the skin region, hSegTH is the hair segmentation threshold, sSegTHl is the low threshold for skin segmentation, and sSegTHh is the high threshold for skin segmentation. Since the brightness map of the hair region is the same size as the brightness image bI(x,y) in this embodiment, the brightness map of the hair region can be obtained simply by setting the brightness values of non-hair regions to 0. Similarly, since the brightness map of the skin region is the same size as the brightness image bI(x,y), the brightness map of the skin region can be obtained simply by setting the brightness values of non-skin regions to 0.
[0065] The hair segmentation threshold, high skin segmentation threshold, and low skin segmentation threshold can be preset according to the needs of actual applications. This is because, during the imaging process, light reflects and scatters differently on different object surfaces. In other words, the emission and scattering of light on human hair and skin are different, resulting in significant differences in their brightness components in the image. Therefore, the hair region and the skin region can be distinguished based on the average brightness value. Specifically, multiple high-quality ID photo samples can be collected, and then the average brightness values of these ID photo samples in these two regions can be statistically analyzed. Based on these average brightness values, various segmentation thresholds can be set to segment the portrait in the ID photo into the skin region and the hair region. That is, before the step "obtaining the preset hair segmentation threshold, high skin segmentation threshold, and low skin segmentation threshold", this image quality assessment method may also include S1 to S3, as follows:
[0066] S1. Collect multiple ID photo samples, including positive samples, which are normal images.
[0067] S2. Obtain the average brightness of the hair area and the average brightness of the skin area of the multiple ID photo samples.
[0068] It should be noted that, due to the histogram of a normal ID photo... Figure 1 Generally, these patterns exhibit a relatively large distance between them and show two distinct waveforms on the left and right sides. Therefore, this characteristic can be used to obtain the average brightness of the hair and skin areas. For example, it can be done as follows:
[0069] Obtain the histogram of the ID photo sample. The histogram includes a left waveform and a right waveform. The left waveform is the waveform where the dark area peaks (the hair area of the portrait is darker), and the right waveform is the waveform where the bright area peaks (the skin area of the portrait is brighter). Determine the right boundary point of the left waveform, the left boundary point of the right waveform, and the right boundary point of the right waveform. Calculate the mean of the sum of the right boundary points of the left waveform and the left boundary points of the right waveform to obtain the mean brightness of the hair area of the multiple ID photo samples. Calculate the mean of the right boundary point of the right waveform to obtain the mean brightness of the skin area of the multiple ID photo samples.
[0070] Optionally, the step "determine the right boundary point of the left waveform, the left boundary point of the right waveform, and the right boundary point of the right waveform" may specifically include:
[0071] In this histogram, a first straight line parallel to the horizontal axis is set. This first straight line gradually moves upward along the vertical axis until it intersects with the falling edge of the left waveform, the rising edge of the right waveform, and the falling edge of the right waveform, thus obtaining the intersection line. The horizontal coordinate value corresponding to the intersection point of the intersection line with the falling edge of the left waveform is determined to obtain the right boundary point of the left waveform. The horizontal coordinate value corresponding to the intersection point of the intersection line with the rising edge of the right waveform is determined to obtain the left boundary point of the right waveform. The horizontal coordinate value corresponding to the intersection point of the intersection line with the falling edge of the right waveform is determined to obtain the right boundary point of the right waveform.
[0072] Optionally, the abscissa value corresponding to the intersection point of the intersecting line and the rising edge of the left waveform can be determined to obtain the left boundary point of the left waveform.
[0073] In this histogram, a two-dimensional coordinate system is used. The horizontal axis x represents different levels of pixel brightness, which usually corresponds to values from 0 to 255 from left to right, also known as color levels. The vertical axis y represents the number of pixels v corresponding to different color levels.
[0074] For example, such as Figure 2 As shown, this figure is an example of a histogram of a sample ID photo. Figure 2 As can be seen, the histogram has two distinct waveforms, one on the left and one on the right. Therefore, a straight line f = v can be set in the histogram. For ease of description, in this embodiment, it is referred to as the first straight line. Here, v is a threshold variable. Increasing the value of v causes the straight line f = v to slide upwards along the vertical axis until it intersects with the falling edge of the left waveform, the rising edge of the right waveform, and the falling edge of the right waveform (i.e., until both waveforms are obtained). The value of v at this point is recorded as histTh, meaning that the straight line at this point is f = histTh (i.e., the intersection line mentioned above). Figure 2 It can be seen that f = histTh has an intersection point L1 with the rising edge of the left waveform, an intersection point L2 with the falling edge of the left waveform, an intersection point R1 with the rising edge of the right waveform, and an intersection point R2 with the falling edge of the right waveform. The x-coordinate value corresponding to L2 is the right boundary point of the left waveform, the x-coordinate value corresponding to R1 is the left boundary point of the right waveform, and the x-coordinate value corresponding to R2 is the right boundary point of the right waveform.
[0075] S3. Set the average brightness of the hair region of the multiple ID photo samples as the hair segmentation threshold and the low threshold for skin color segmentation, and set the average brightness of the skin color region of the multiple ID photo samples as the high threshold for skin color segmentation.
[0076] This can be expressed as a formula:
[0077]
[0078] Where hSegTH is the hair segmentation threshold, sSegTHl is the low threshold for skin segmentation, sSegTHh is the high threshold for skin segmentation, lpeak_r is the right boundary point of the left waveform on the histogram, rpeak_l is the left boundary point of the right waveform on the histogram, and rpeak_r is the right boundary point of the right waveform on the histogram.
[0079] 103. Calculate the average brightness of the hair region based on the brightness map of the hair region, and calculate the average brightness of the skin region based on the brightness map of the skin region.
[0080] For example, you can obtain the dimensions of the brightness map of the hair region, such as its length and width, and then calculate the average brightness of the hair region based on the brightness map and dimensions. Similarly, you can obtain the dimensions of the brightness map of the skin region, such as its length and width, and then calculate the average brightness of the skin region based on the brightness map and dimensions, and so on.
[0081] Alternatively, the average brightness can be calculated using the following formula:
[0082]
[0083] Where vI(x,y) is the input brightness image, which can be the brightness image bI(x,y) of the ID photo to be evaluated, or the brightness image hBI(x,y) of the hair region or the brightness image sBI(x,y) of the skin region; vH and vW are the height and width of the brightness image, respectively, and bmean is the brightness mean. When the input image is the brightness image hBI(x,y) of the hair region, the brightness mean hBmean of the hair region is obtained; when the input image is the brightness image sBI(x,y) of the skin region, the brightness mean sBmean of the skin region is obtained. The formulas for the brightness mean hBmean of the hair region and the brightness mean sBmean of the skin region are as follows:
[0084]
[0085]
[0086] 104. Calculate the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain the first ratio, which can be expressed by the following formula:
[0087]
[0088] Where hsRatio is the first ratio, hBmean is the mean brightness of the hair region, and sBmean is the mean brightness of the skin region.
[0089] 105. When the average brightness of the hair area is greater than the preset hair brightness threshold, the ID photo to be evaluated is determined to be a grayscale image.
[0090] 106. When the average brightness of the hair area is less than or equal to the preset hair brightness threshold, and the first ratio is greater than the preset ratio threshold, the ID photo to be evaluated is determined to be a normal image.
[0091] The hair brightness threshold and ratio threshold can be preset according to the needs of actual applications. For example, multiple normal ID photo samples and gray ID photo samples can be collected separately. Then, the average brightness of these normal and gray ID photo samples can be calculated separately, and the hair brightness threshold and ratio threshold can be set based on these average brightness values. Optionally, in step S1 of 102, the collected ID photo samples can include negative samples in addition to positive samples, where the negative samples are gray images.
[0092] Then at this time:
[0093] The step "obtain the average brightness of the multiple ID photo samples in the hair area and the average brightness of the multiple ID photo samples in the skin area" can specifically include: obtaining the average brightness of multiple positive samples in the hair area, the average brightness of multiple positive samples in the skin area, and the average brightness of multiple negative samples in the hair area; optionally, the average brightness of multiple negative samples in the skin area can also be obtained.
[0094] After the step "obtaining the average brightness of the multiple ID photo samples in the hair region and the average brightness of the multiple positive samples in the skin region", the image quality assessment method may further include: setting a hair brightness threshold and a ratio threshold based on the average brightness of the multiple positive samples in the hair region, the average brightness of the multiple positive samples in the skin region, and the average brightness of the multiple negative samples in the hair region. For example, it may be as follows:
[0095] A preset clustering algorithm is used to calculate the average brightness of multiple positive samples in the hair region, obtaining the cluster center value of the positive sample hair region. The same clustering algorithm is used to calculate the average brightness of multiple positive samples in the skin region, obtaining the cluster center value of the positive sample skin region. The same clustering algorithm is used to calculate the average brightness of multiple negative samples in the hair region, obtaining the cluster center value of the negative sample hair region. Then, the average value of the cluster center values of the positive sample hair region and the negative sample hair region is set as the hair brightness threshold, and the ratio of the cluster center value of the positive sample hair region to the cluster center value of the positive sample skin region is set as the ratio threshold.
[0096] Optionally, when setting the hair brightness threshold and ratio threshold, the average brightness of multiple negative samples in the skin color region can also be considered as one of the factors. Specifically, the clustering algorithm can be used to calculate the average brightness of multiple negative samples in the skin color region to obtain the cluster center of the skin color region of multiple negative samples. Then, when setting the hair brightness threshold and ratio threshold, the cluster center of the skin color region of multiple negative samples can be used as a reference factor, and so on. These details will not be elaborated here.
[0097] The clustering algorithm can be configured according to the needs of the actual application. For example, the following formula can be used:
[0098]
[0099] Among them, C n Let C1 be the sample space, and n takes values in the range [1,2]. When n=1, it represents a positive sample (i.e., a normal ID photo sample). In other words, C1 is the sample space of normal ID photos and is called the positive sample space. When n=2, it represents a negative sample (i.e., a gray ID photo sample). In other words, C2 is the sample space of gray ID photos and is called the negative sample space.
[0100] P nk C n The mean brightness of the sample in the hair region and skin region in space, i.e., when n=1, k takes values of 1 and 2 respectively, P 11 and P 12 Let P be the average brightness of the samples in the hair region and skin color region of the positive sample space C1, respectively. When n = 2, and k takes values of 1 and 2, respectively, P... 21 and P 22 P represents the average brightness of the samples in the hair and skin regions of the negative sample space C2, respectively. nk (m) is C n The mean brightness of a sample m in the hair or skin region of space, for example, P. 11 (m) represents the mean brightness of a sample m in the hair region within the C1 space, P 12 (m) represents the mean brightness of a sample m in the skin-colored region in the C1 space, P 21 (m) represents the mean brightness of a sample m in the hair region within the C2 space, P 22 (m) represents the average brightness of a sample m in the skin color region in the C2 space, and so on.
[0101] E n Let E1 be the clustering error, where E1 is the clustering error in the positive sample space C1 when n = 1, and E2 is the clustering error in the negative sample space C2 when n = 2. n C n The number of samples in the space, m is M nSpecific samples in the text.
[0102] O nk The center point of the cluster is where, when n = 1 and k = 1, O 11 Let $k$ be the cluster center of the hair region of a sample in the positive sample space C1 (i.e., the cluster center value of the hair region of the positive sample). When $n = 1$ and $k = 2$, $O$ 12 For the cluster centers of skin color regions in the positive sample space C1 (i.e., the cluster center values of skin color regions in the positive samples), when n = 2 and k = 1, O 21 For the cluster centers of the hair regions of samples in the C2 sample space of the gray image (i.e., the cluster center values of the hair regions of negative samples), when n=2 and k takes 2, O 22 The cluster center of the skin color region of the sample in the C2 sample space of the gray image is (i.e., the cluster center value of the skin color region of the negative sample).
[0103] In the clustering loop iteration, when the clustering error E n When it no longer changes, take O. nk The value of O is used as the center value for the two classes, hair region and skin color region. That is, when E1 no longer changes, the value of O at this point is taken. 11 The value is used as the center value of the cluster "hair region of positive samples", and the value of O at this time is taken. 12 The value is used as the center value of the cluster "skin color region of positive samples". In other words, the cluster center value O of the hair region of the positive samples (i.e., these multiple normal ID photo samples) can be obtained at this time. 11 And obtain the cluster center value O of the skin color region of the positive samples (i.e., these multiple normal ID photo samples), and obtain the cluster center value O of the skin color region. 12 Similarly, when E2 no longer changes, we take the value of O at this point. 21 The value is used as the center value of the cluster "hair region of negative samples", and the value of O at this time is taken. 22 The value is used as the center value of the cluster "skin color region of negative samples". In other words, the cluster center value O of the hair region of the negative samples (i.e., these multiple gray ID photo samples) can be obtained at this time. 21 And obtain the cluster center value O of the skin color region of the negative samples (i.e., these multiple gray ID photo samples). 22 .
[0104] The cluster center value O of the positive sample hair region is obtained. 11 Cluster center value O for positive skin color regions 12 The average O of the cluster centers of the negative sample hair regions 21 Then, the cluster center values O of the positive sample hair regions can be calculated. 11 The average O of the cluster centers of the negative sample hair regions 21Set the hair brightness threshold hsMeanTh, and set the cluster center value O of the positive sample hair region. 11 Cluster center value O of the skin color region of the positive sample 12 The ratio is set as the ratio threshold hsRatioTh, which can be expressed by the following formula:
[0105]
[0106] Optionally, when the first ratio is less than or equal to a preset ratio threshold, the quality of the ID photo can be evaluated based on the presence or absence of hair to extract texture edge intensity features, or based on the histogram peak center position features. Alternatively, the image quality evaluation method may also include:
[0107] When the first ratio is less than or equal to a preset ratio threshold, the average edge intensity of the ID photo to be evaluated is obtained; if the average edge intensity is greater than the preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image; otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, the feature value of the center position of the histogram peak of the brightness image is obtained; if the feature value of the center position of the histogram peak is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image; if the feature value of the center position of the histogram peak is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0108] It should be noted that if the person in the ID photo is bald, or has hair color similar to their skin tone (e.g., gray hair), it may be difficult to accurately segment the hair and skin areas. Alternatively, the proportion of non-zero brightness pixels in the hair area brightness image may be lower than the empirical value. Therefore, in such cases, the quality of the ID photo can be evaluated by extracting texture edge intensity features or by using histogram peak center position features. For example, these situations can be specifically addressed as follows:
[0109] (1) The percentage of pixels with non-zero brightness in the brightness image of the hair region is less than the empirical value;
[0110] After segmenting the brightness image into a brightness map of the hair region and a brightness map of the skin region, the number of pixels with non-zero brightness values in the hair region can be counted based on the brightness map of the hair region, and the proportion of such pixels in the brightness image can be calculated. If the proportion is less than a preset empirical value, the quality of the ID photo is evaluated by extracting texture edge intensity features or by using histogram peak center position features. Otherwise, if the proportion is greater than or equal to the preset empirical value, the quality of the ID photo is evaluated based on the average brightness of the hair region and the average brightness of the skin region. Optionally, after step "segmenting the brightness image into a brightness map of the hair region and a brightness map of the skin region (i.e., step 102)," the image quality evaluation method may further include:
[0111] Based on the brightness map of the hair region, count the number of pixels with non-zero brightness values in the hair region, and calculate the proportion of such pixels in the overall brightness image. This can be expressed by the following formula:
[0112]
[0113]
[0114] Where bI(x,y) is the brightness image of the ID photo to be evaluated, (x,y) is the coordinate value of the image pixel in the image coordinate system, noZeroNum is the number of pixels with non-zero brightness values in the hair region, H and W are the height and width of the brightness image, respectively, and numRatio is the proportion of the number of pixels with non-zero brightness values in the hair region in the brightness image.
[0115] If the numRatio is less than a preset empirical value, the average edge intensity of the ID photo to be evaluated is obtained. If the average edge intensity is greater than a preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image. Otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, the feature value of the center position of the histogram peak of the brightness image is obtained. If the feature value of the center position of the histogram peak is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image. If the feature value of the center position of the histogram peak is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0116] If the ratio numRatio is greater than or equal to a preset empirical value, then the steps of calculating the average brightness of the hair region based on the brightness map of the hair region and calculating the average brightness of the skin region based on the brightness map of the skin region (i.e., step 103) are executed. For details, please refer to the previous embodiments, which will not be repeated here.
[0117] This empirical value can be set based on needs, experiments, or practical experience. For example, by collecting multiple ID photo samples, such as positive samples, and then by statistically analyzing the proportion of non-zero brightness pixels in the hair area of these positive samples in their brightness images, and calculating the average of these proportions, the value can be set based on this average, and so on. This will not be elaborated on here.
[0118] (2) Unable to separate hair and skin areas;
[0119] If the brightness image cannot be segmented into brightness maps for the hair region and skin region, the quality of the ID photo can be assessed by extracting texture edge intensity features or based on histogram peak center location features. Alternatively, the image quality assessment method may also include:
[0120] If the brightness image cannot be segmented into brightness maps of the hair region and skin region, the average edge intensity of the ID photo to be evaluated is obtained. If the average edge intensity is greater than a preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image; otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, the histogram peak center position feature value of the brightness image is obtained. If the histogram peak center position feature value is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image; if the histogram peak center position feature value is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0121] The edge intensity threshold and position threshold can be set based on requirements, experiments, or practical experience. For example, the edge intensity threshold can be set by collecting multiple ID photo samples, such as positive samples, calculating the average edge intensity of each positive sample, and then calculating the mean of these average edge intensities. Similarly, the position threshold can be set by calculating the histogram peak center position feature values of the brightness images of these positive samples and then calculating the mean of these histogram peak center position feature values. These methods will not be elaborated upon here.
[0122] Optionally, in (1) and (2), the step "obtaining the average edge intensity of the ID photo to be evaluated" may include:
[0123] The photo to be evaluated is converted into a grayscale image, and the edge image of the grayscale image is calculated. False edges in the edge image are removed to obtain an adjusted edge image. The variance of the adjusted edge image is then calculated to obtain the average edge intensity of the photo to be evaluated.
[0124] For example, the edge image of the grayscale image can be calculated using the following formula:
[0125]
[0126] Where gI(x,y) is the grayscale image, eI(x,y) is the edge image, and (x,y) is the coordinate value of the image pixel in the image coordinate system.
[0127] After obtaining the edge image, false edges caused by noise points can be removed. For example, a small threshold can be used to remove edges with intensity values less than that threshold, resulting in an adjusted edge image. Then, the variance of this adjusted edge image can be calculated. The standard deviation of the calculated edge image is the average edge intensity of the ID photo being evaluated. For example, the average edge intensity of the ID photo being evaluated can be calculated using the following formula:
[0128]
[0129] Where eIvar is the standard deviation of the edge image eI(x,y), emean is the mean of the edge image eI(x,y), (x,y) is the coordinate value of the image pixel in the image coordinate system, and H and W are the height and width of the brightness image, respectively.
[0130] Optionally, in (1) and (2), the step "obtaining the feature value of the center position of the histogram peak of the brightness image" may include:
[0131] The horizontal position of the maximum value of the histogram of the brightness image in the coordinate system is taken as the position of the peak center point (i.e., the characteristic value of the histogram peak center position, which can be expressed by the following formula):
[0132] w_c = Loc(max(Hist(i)));
[0133] Where w_c is the feature value of the center position of the peak of the histogram, Hist(i) is the histogram, max(Hist(i)) is the maximum value of the histogram, and Loc(·) takes the horizontal position of the histogram where the maximum value is located.
[0134] Optionally, to better process the image and reduce the probability of rejecting documents during document production, after determining that the document photo to be evaluated is a grayscale image, it can be repaired. Specifically, after determining that the document photo to be evaluated is a grayscale image, the image quality assessment method can further include:
[0135] The photo to be evaluated is processed using a preset image restoration transformation function to obtain the processed photo.
[0136] Optionally, since the preceding processing may cause slight changes in the image's brightness and detail, a dynamic upscaling factor can be set to improve the image's brightness and detail in order to enhance the image restoration effect. Alternatively, after the step "processing the ID photo to be evaluated using a preset image restoration transformation function to obtain the processed ID photo," the image quality assessment method may further include:
[0137] The brightness and details of the processed ID photo are restored using a preset dynamic upscaling factor to obtain the restored ID photo.
[0138] The image restoration transformation function and dynamic stretching factor can be set based on the feature values of the left and right waveforms of the histogram of the ID photo to be evaluated. Specifically, the feature values of the left waveform can include the left and right boundary points of the left waveform, and the feature values of the right waveform can include the left and right boundary points of the right waveform.
[0139] For example, taking the histogram of the ID photo to be evaluated as including the left waveform and the right waveform as an example, the image restoration transformation function and dynamic stretching factor can be set according to the left boundary point, the right boundary point, the left boundary point, and the right boundary point of the left waveform of the histogram of the ID photo to be evaluated.
[0140] For example, if the histogram of the ID photo to be evaluated includes a clear waveform, such as the right waveform or the left waveform, then the other waveform can be considered as 0 (i.e. it does not exist or can be ignored). Specifically, the image restoration transformation function and dynamic stretching factor can be set according to the left and right boundary points of the waveform, and so on.
[0141] Before the step "processing the ID photo to be evaluated using a preset image restoration transformation function to obtain the processed ID photo", the image quality assessment method may also include:
[0142] Obtain the histogram of the ID photo to be evaluated. The histogram includes a left waveform and a right waveform. The left waveform represents the peak value in the dark areas, and the right waveform represents the peak value in the bright areas. Determine the left and right boundary points of the left waveform. Calculate the variance of the left waveform based on these points to obtain its left endpoint. Determine the left and right boundary points of the right waveform. Calculate the variance of the right waveform based on these points to obtain its right endpoint. Set the image restoration transformation function based on the left and right endpoints of the left and right waveforms. Optionally, a dynamic upscaling factor can also be set based on the left and right endpoints of the left and right waveforms.
[0143] For example, the image restoration transformation function can be as follows:
[0144]
[0145] Where δl is the left endpoint of the left waveform, δr is the right endpoint of the right waveform, I(x,y) is the ID photo to be evaluated with the quality of "grayish image", d(x,y) is the image restored by the image restoration transformation function (i.e., the processed ID photo), e(〃) is the natural index, and the parameters α and β are the dynamic factors of image restoration. The so-called "dynamic" means that the values of the parameters α and β are different depending on the image to be restored (i.e., the ID photo to be evaluated with the quality of "grayish image"). (For different ID photos to be evaluated, the values of δl and δr will also change accordingly, so the values of α and β will also change accordingly.)
[0146] For example, the dynamic boosting factor can be specifically as follows:
[0147]
[0148] Where δl is the left endpoint of the left waveform, δr is the right endpoint of the right waveform, and r is the dynamic stretching factor.
[0149] Optionally, to reduce computational load and image processing time, a mapping table can be generated based on the dynamic upscaling factor. This mapping table allows for the quick generation of a restored ID photo simply by inputting the processed ID photo. The relationship between this mapping table and the dynamic upscaling factor is shown in the following formula:
[0150]
[0151] Where δl is the left endpoint of the left waveform, δr is the right endpoint of the right waveform, r is the dynamic stretching factor, and list(i) is the mapping table.
[0152] The repaired ID photo will look like this:
[0153] outI(x,y) = list[d(x,y)]
[0154] Where outI(x,y) is the repaired ID photo, d(x,y) is the processed ID photo, and list(i) is the mapping table.
[0155] By adjusting the dynamic upscaling factor, not only can the brightness and details of the processed ID photo be restored to a large extent, but it can also correct slight color casts in the ID photo, and improve images of normal quality as well.
[0156] It should be noted that if there is only one obvious waveform in the histogram, such as a bald head, there may only be one right waveform (the waveform where the bright part peaks are located). In this case, the left waveform can be considered non-existent or can be ignored, that is, the values of the left and right endpoints of the left waveform are set to 0. Similarly, if there is only one left waveform (the waveform where the dark part peaks are located), such as a person with dark skin, the right waveform can be considered non-existent or can be ignored, that is, the values of the left and right endpoints of the right waveform are set to 0, and so on.
[0157] It should also be noted that the method for determining the left boundary point, right boundary point, left boundary point, and right boundary point of the histogram of the ID photo to be evaluated can be the same as the method for determining the left boundary point, right boundary point, left boundary point, and right boundary point of the histogram of the ID photo sample.
[0158] For example, such as Figure 3As shown, taking the histogram of the ID photo for evaluation as an example, which shows two distinct waveforms, the left waveform is called the left waveform, and the right waveform is called the right waveform. A straight line f = v (the first straight line) is set in the histogram, where v is a threshold variable. Increasing the value of v causes the line f = v to slide upwards along the vertical axis until it intersects with the rising edge, falling edge, rising edge, and falling edge of the left waveform (i.e., until both left and right waveforms are obtained). The value of v at this point is recorded as waveThr, meaning the first straight line at this point is y = waveThr. Figure 3 It can be seen that y = waveThr has an intersection point L1 with the rising edge of the left waveform, an intersection point L2 with the falling edge of the left waveform, an intersection point R1 with the rising edge of the right waveform, and an intersection point R2 with the falling edge of the right waveform. The horizontal axis coordinate value corresponding to L1 is the left boundary point of the left waveform, the horizontal axis coordinate value corresponding to L2 is the right boundary point of the left waveform, the horizontal axis coordinate value corresponding to R1 is the left boundary point of the right waveform, and the horizontal axis coordinate value corresponding to R2 is the right boundary point of the right waveform.
[0159] For example, such as Figure 4 As shown, taking the histogram of the ID photo for evaluation as an example, there is a clear waveform. Since this waveform is where the bright peak is located, it can be considered the right waveform. The left waveform does not exist or can be ignored (i.e., considered as 0). Therefore, the left and right endpoints of the left waveform can be considered as 0. Similarly, a straight line f = v (i.e., the first straight line) can be set in the histogram, where v is a threshold variable. Increasing the value of v makes the straight line f = v slide upward along the vertical axis until it intersects both the rising and falling edges of the right waveform (i.e., until a clear waveform is obtained). Record the value of v at this time as waveThr. That is, at this time, the first straight line is y = waveThr. Figure 3 It can be seen that y = waveThr has an intersection point R1 with the rising edge of the right waveform and an intersection point R2 with the falling edge of the right waveform. The horizontal axis coordinate value corresponding to R1 is the left boundary point of the right waveform, and the horizontal axis coordinate value corresponding to R2 is the right boundary point of the right waveform.
[0160] After obtaining the left and right boundary points of each waveform, the left endpoint δl of the left waveform δ interval and the right endpoint δr of the right waveform δ interval can be determined accordingly.
[0161] Optionally, since the distribution of each waveform in the histogram is close to the normal distribution function, the left endpoint δl of the left waveform δ interval and the right endpoint δr of the right waveform δ interval can be determined according to the 3δ rule (three sigma criterion) in the normal distribution function, where δ is the variance of the normal function.
[0162] Optionally, the step "calculate the variance of the left waveform based on the left boundary point and the right boundary point of the left waveform to obtain the left endpoint of the left waveform" may include: determining the left endpoint δl of the δ interval of the left waveform using the 3δ rule in the normal distribution function based on the left boundary point and the right boundary point of the left waveform. In this embodiment of the invention, the left endpoint δl of the δ interval of the left waveform is simply referred to as the left endpoint of the left waveform.
[0163] Similarly, the step "calculate the variance of the right waveform based on the left boundary point and the right boundary point of the right waveform, and obtain the right endpoint of the right waveform" may include: determining the right endpoint δr of the right waveform δ interval using the 3δ rule in the normal distribution function based on the left boundary point and the right boundary point of the right waveform. In this embodiment of the invention, the right endpoint δr of the right waveform δ interval is simply referred to as the right endpoint of the right waveform.
[0164] The method for determining the left endpoint of the left waveform and the right endpoint of the right waveform using the 3δ rule in the normal distribution function can be as follows:
[0165] According to the 3δ rule in the normal distribution function, although the normal variable in the normal function is (-≦, ≦), its value has a 99.7% probability of falling within the interval (u-3δ, u+3δ), where u is the mean of the normal variable. Therefore, the probability of a value not falling within the interval (u-3δ, u+3δ) can be determined to be (1-0.997). Since there are two waveforms, left and right, the probability wTH of a point on each waveform not falling within the interval (u-3δ, u+3δ) is:
[0166] wTH = (1 - 0.997) / 2 = 0.0015;
[0167] Traverse from the left boundary point of a waveform to its right boundary point. Stop when the cumulative number of pixels equals or for the first time exceeds wTH (i.e., 0.0015) of the area enclosed by the waveform and the y = waveThr line (y is the vertical axis of the histogram) on the histogram (because it is not necessarily exactly equal to 0.0015 of the area enclosed by the waveform and the y = waveThr line). The position value of this point is the left endpoint of the δ interval, which can be expressed by the formula:
[0168]
[0169] Where subHist(i) is the waveform in the histogram, S peak_l represents the sum of the number of pixels on waveform subHist(i) in the histogram when traversing from the left boundary point to the right boundary point of the waveform; lPos represents the left boundary point of waveform subHist(i) in the histogram; rPos represents the right boundary point of waveform subHist(i) in the histogram; tn represents the cumulative sum of pixel counts when traversing the histogram; when the cumulative tn does not meet the condition tn peak_l When *wTH is used, Loc(〃) takes the value of i at this time as the left endpoint δl of the δ interval.
[0170] Similarly, traversing from the right boundary point of a waveform to its left boundary point, stopping when the cumulative number of pixels equals or exceeds for the first time the area wTH (i.e., 0.0015) enclosed by the waveform and the y = waveThr line on the histogram, the position value of this point is the right endpoint of the δ interval, expressed by the formula:
[0171]
[0172] Where subHist(i) is the waveform in the histogram, S peak _r represents the sum of the number of pixels on waveform subHist(i) in the histogram when traversing from the left boundary point to the right boundary point of the waveform; lPos represents the left boundary point of waveform subHist(i) in the histogram; rPos represents the right boundary point of waveform subHist(i) in the histogram; tn represents the cumulative sum of pixel counts when traversing the histogram; if the cumulative tn does not meet the condition tn peak_r When *wTH is used, Loc(〃) takes the value of i at this time as the right endpoint δr of the δ interval.
[0173] Optionally, after obtaining the processed ID photo, if the processed ID photo is an 8-bit portrait bitmap, to prevent pixel value overflow, the pixel value range within the image matrix can be limited to between 0 and 255. For example, pixel values exceeding 255 can be adjusted to 255, and pixel values less than 0 can be set to 0, etc. That is, after the step "processing the ID photo to be evaluated using a preset image restoration transformation function to obtain the processed ID photo", the image quality assessment method may further include:
[0174] The pixel values within the image matrix of the processed ID photo are limited to the range of 0 to 255 to obtain the adjusted ID photo.
[0175] At this point, the step "using a preset dynamic upscaling factor to repair the brightness and details of the processed ID photo to obtain a repaired ID photo" specifically means: using a preset dynamic upscaling factor to repair the brightness and details of the adjusted ID photo to obtain a repaired ID photo.
[0176] The method of using a preset dynamic upscaling factor to restore the brightness and details of the adjusted ID photo is the same as the method of restoring the processed ID photo, as detailed in the previous description, and will not be repeated here.
[0177] As can be seen from the above, this embodiment can acquire the brightness image of the ID photo to be evaluated, segment the brightness image into a brightness map of the hair region and a brightness map of the skin region, and then calculate the average brightness of the two regions based on the brightness maps of the hair region and the skin region, as well as the ratio of the average brightness of the two regions (i.e., the first ratio). The quality of the ID photo to be evaluated is evaluated based on the average brightness of the two regions and the ratio. For example, when the average brightness of the hair region is greater than a preset hair brightness threshold, the ID photo to be evaluated is determined to be a gray image; when the average brightness of the hair region is less than or equal to the preset hair brightness threshold, and the first ratio is greater than a preset ratio threshold, the ID photo to be evaluated is determined to be a normal image, and so on. Since this scheme does not have high requirements for the structure of the image, it can accurately evaluate unstructured images or slightly gray or blurry ID photos. Moreover, since there is no need to set up corresponding high-quality reference images or collect a large number of diverse training samples, the implementation is also relatively simple. Furthermore, because the characteristics of ID photos are fully considered during the evaluation, and multiple factors such as the characteristics of the average brightness of the hair and skin areas and their relationship are used as evaluation criteria, the accuracy of the evaluation can be greatly improved, the evaluation effect can be enhanced, and the probability of rejecting ID cards can be reduced.
[0178] Based on the methods described in the above embodiments, the following examples will provide further explanation.
[0179] In this embodiment, the image quality assessment device will be specifically integrated into a network device as an example for explanation.
[0180] like Figure 5 and Figure 6 As shown, an image quality assessment method can be described in the following steps:
[0181] 201. The network device acquires the photo of the document to be evaluated and obtains the brightness image of the photo.
[0182] For example, after obtaining the ID photo to be evaluated, the R, G, and B values of each pixel in the photo can be obtained. The maximum value among these values is selected as the brightness value for that pixel, thus obtaining the brightness value of each pixel in the photo. Then, a brightness image of the ID photo to be evaluated is generated based on the obtained pixel brightness values. This can be expressed by the formula:
[0183] bI(x,y)=max(R,G,B);
[0184] Wherein, R, G, and B are the red, green, and blue channels of the ID photo (color image) to be evaluated, (x,y) is the coordinate value of the image pixel in the image coordinate system, max(R,G,B) is the maximum value of R, G, and B of the pixel point (x,y) in the image coordinate system as the brightness value of the pixel point, and bI(x,y) is the brightness image.
[0185] 202. The network device segments the brightness image into a brightness map of the hair region and a brightness map of the skin region; for example, it can be as follows:
[0186] The network device acquires preset hair segmentation thresholds, skin color segmentation high thresholds, and skin color segmentation low thresholds, determines regions in the brightness image whose brightness is greater than the hair segmentation threshold, obtains non-hair regions, adjusts the brightness values of non-hair regions in the brightness image to 0, and obtains the brightness map of the hair region; it then determines regions in the brightness image whose brightness is less than or equal to the skin color segmentation high threshold and greater than the skin color segmentation low threshold, obtains skin color regions, and adjusts the brightness values of all regions in the brightness image except for the skin color regions to 0, and obtains the brightness map of the skin color regions.
[0187] The hair segmentation threshold, the high threshold for skin segmentation, and the low threshold for skin segmentation can be preset according to the actual application requirements. For details, please refer to the previous embodiments, which will not be repeated here.
[0188] Optionally, if the brightness image cannot be segmented into a brightness map of the hair region and a brightness map of the skin region, it indicates that the person in the ID photo to be evaluated may be bald or have hair color similar to skin color, such as white hair. In this case, step 208 can be performed.
[0189] 203. The network device counts the number of pixels with non-zero brightness values in the hair region based on the brightness map of the hair region, and calculates the proportion of the number of pixels with non-zero brightness values in the hair region in the brightness image. If the proportion is greater than or equal to a preset empirical value, then step 204 is executed; otherwise, if the proportion is less than the preset empirical value, then step 208 is executed.
[0190] This empirical value can be set based on needs, experiments, or practical experience. For example, by collecting multiple ID photo samples, such as positive samples, and then by statistically analyzing the proportion of non-zero brightness pixels in the hair area of these positive samples in their brightness images, and calculating the average of these proportions, the value can be set based on this average, and so on. This will not be elaborated on here.
[0191] 204. The network device calculates the average brightness of the hair region based on the brightness map of the hair region, and calculates the average brightness of the skin region based on the brightness map of the skin region, and then executes step 205.
[0192] For example, the length and width of the brightness map of the hair region can be obtained, and then the average brightness of the hair region can be calculated based on the brightness map of the hair region and its length and width. Similarly, the length and width of the brightness map of the skin region can be obtained, and then the average brightness of the skin region can be calculated based on the brightness map of the skin region and its length and width. For details, please refer to the previous embodiments, which will not be repeated here.
[0193] 205. The network device calculates the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain the first ratio, and then executes step 206.
[0194] 206. The network device determines whether the average brightness of the hair area is greater than the preset hair brightness threshold. If it is greater than the preset hair brightness threshold, the ID photo to be evaluated is determined to be a gray image; otherwise, if it is less than or equal to the preset hair brightness threshold, step 207 is executed.
[0195] 207. The network device determines whether the first ratio is greater than the preset ratio threshold. If yes, it determines that the ID photo to be evaluated is a normal image. If no, it proceeds to step 208.
[0196] The hair brightness threshold and ratio threshold can be preset according to the actual application requirements. For specific setting methods, please refer to the previous embodiments, which will not be repeated here.
[0197] It should be noted that step 206 can be executed first, followed by step 205. That is, when the average brightness of the hair area is determined to be less than or equal to the preset hair brightness threshold, the first ratio is calculated, and then step 207 is executed. The specific execution order can be determined according to the actual application requirements and is not limited here.
[0198] 208. The network device obtains the average edge intensity of the ID photo to be evaluated. If the average edge intensity is greater than the preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image; otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, step 209 is executed.
[0199] For example, the network device can convert the ID photo to be evaluated into a grayscale image, calculate the edge image of the grayscale image, remove the false edges in the edge image to obtain the adjusted edge image, and then perform variance calculation on the adjusted edge image to obtain the average edge intensity of the ID photo to be evaluated. For details, please refer to the previous embodiments, which will not be repeated here.
[0200] 209. The network device obtains the feature value of the center position of the histogram peak of the brightness image. If the feature value of the center position of the histogram peak is greater than or equal to the preset position threshold, the ID photo to be evaluated is determined to be a normal image. If the feature value of the center position of the histogram peak is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0201] For example, the network device can specifically use the horizontal position of the maximum value of the histogram of the brightness image in the coordinate system as the position of the center point of the peak, as follows:
[0202] w_c = Loc(max(Hist(i)));
[0203] Where w_c is the feature value of the center position of the peak of the histogram, Hist(i) is the histogram, max(Hist(i) is the maximum value of the histogram, and Loc(·) takes the horizontal position of the histogram where the maximum value is located.
[0204]
[0205] Where w_cTh is a preset position threshold. When quality = 1, the ID photo to be evaluated is determined to be a normal image. When quality = 0, the ID photo to be evaluated is determined to be a gray image.
[0206] The edge strength threshold and location threshold can be set according to requirements, experiments or practical experience. For specific setting methods, please refer to the previous embodiments, which will not be repeated here.
[0207] After assessing the quality of the ID photo to be evaluated, appropriate actions can be taken based on the assessment results. For example, if the image is normal, the ID card production process can be allowed, while if the image is grayed out, the user can be reminded to adjust the ID photo to be evaluated or to retake it, etc.
[0208] Optionally, in order to better process the image and reduce the probability of rejecting the document during the production process, when it is determined that the document photo to be evaluated is a gray image, the document photo to be evaluated can also be repaired, that is, step 210 can also be performed.
[0209] 210. The network device uses a preset image restoration transformation function to process the ID photo to be evaluated, and obtains the processed ID photo.
[0210] 211. The network device uses a preset dynamic upscaling factor to restore the brightness and details of the processed ID photo, resulting in a restored ID photo.
[0211] The specific methods for setting the image restoration transformation function and the dynamic stretching factor can be found in the previous embodiments, and will not be repeated here.
[0212] As can be seen from the above, after obtaining the ID photo to be evaluated, this embodiment can acquire the brightness image of the ID photo, then segment the brightness image into a hair region and a skin region, and calculate the average brightness of these two regions and the ratio of their average brightness values. Based on this, the quality of the ID photo is evaluated. If the brightness image cannot be segmented into a brightness image of the hair region and a brightness image of the skin region, such as in cases of a bald head or hair color similar to skin color, the quality of the ID photo is evaluated by extracting texture edge intensity features or by using histogram peak center position features. Because this scheme fully considers the characteristics of ID photos during evaluation, utilizing the differences in light reflection and scattering on different object surfaces, and taking multiple factors such as the characteristics of the average brightness of the hair and skin regions and their relationship as evaluation criteria, it can greatly improve the accuracy and effectiveness of the evaluation. Moreover, for ID photos with a grayed-out evaluation result, it can also be repaired, thus further reducing the probability of rejecting ID photos during production.
[0213] Furthermore, since this scheme does not have high requirements for the structure of images, it can accurately evaluate unstructured images or slightly gray or blurry ID photos. Moreover, since there is no need to set up corresponding high-quality reference images or collect a large number of diverse training samples, it is relatively simple to implement.
[0214] To better implement the above methods, embodiments of this application also provide an image quality assessment apparatus, such as... Figure 7 As shown, the image quality assessment device includes an acquisition unit 301, a segmentation unit 302, a brightness calculation unit 303, a ratio calculation unit 304, and an assessment unit 305, as detailed below:
[0215] The acquisition unit 301 is used to acquire the brightness image of the ID photo to be evaluated.
[0216] The segmentation unit 302 is used to segment the brightness image into a brightness map of the hair region and a brightness map of the skin region.
[0217] The brightness calculation unit 303 is used to calculate the average brightness of the hair region based on the brightness map of the hair region, and to calculate the average brightness of the skin region based on the brightness map of the skin region.
[0218] The ratio calculation unit 304 is used to calculate the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain the first ratio.
[0219] The evaluation unit 305 is used to determine that the ID photo to be evaluated is a gray image when the average brightness of the hair area is greater than a preset hair brightness threshold; and to determine that the ID photo to be evaluated is a normal image when the average brightness of the hair area is less than or equal to the preset hair brightness threshold and the first ratio is greater than the preset ratio threshold.
[0220] For example, segmentation unit 302 can be used to obtain preset hair segmentation threshold, skin color segmentation high threshold, and skin color segmentation low threshold; determine the region in the brightness image whose brightness is greater than the hair segmentation threshold to obtain the non-hair region; adjust the brightness value of the non-hair region in the brightness image to 0 to obtain the brightness map of the hair region; determine the region in the brightness image whose brightness is less than or equal to the skin color segmentation high threshold and greater than the skin color segmentation low threshold to obtain the skin color region; adjust the brightness value of the region in the brightness image other than the skin color region to 0 to obtain the brightness map of the skin color region.
[0221] The hair segmentation threshold, high skin segmentation threshold, and low skin segmentation threshold can be preset according to the needs of actual applications, i.e., they are selectable. The image quality assessment device may also include:
[0222] A threshold setting unit is used to collect multiple ID photo samples, wherein the ID photo samples include positive samples, which are normal images. The unit acquires the average brightness of the multiple ID photo samples in the hair region and the average brightness of the multiple ID photo samples in the skin region. The unit sets the average brightness of the multiple ID photo samples in the hair region as the hair segmentation threshold and the low threshold for skin segmentation, and sets the average brightness of the multiple ID photo samples in the skin region as the high threshold for skin segmentation.
[0223] Optionally, the threshold setting unit can also be used to set hair brightness thresholds and ratio thresholds. For example, the ID photo samples collected by the threshold setting unit may include negative samples in addition to positive samples, where the negative samples are grayscale images. After collecting multiple ID photo samples, the threshold setting unit can obtain the average brightness of multiple positive samples in the hair region, the average brightness of multiple positive samples in the skin region, and the average brightness of multiple negative samples in the hair region. Optionally, it can also obtain the average brightness of multiple negative samples in the skin region, and then set the hair brightness threshold and ratio threshold based on the average brightness of multiple positive samples in the hair region, the average brightness of multiple positive samples in the skin region, and the average brightness of multiple negative samples in the hair region.
[0224] Optionally, when the person in the ID photo is bald, or has hair color similar to their skin tone (e.g., white hair), it may be difficult to accurately segment the hair and skin areas. Alternatively, the proportion of pixels with non-zero brightness in the hair area brightness image may be less than the empirical value. Therefore, in these two cases, the quality of the ID photo can also be evaluated by extracting texture edge intensity features or based on the histogram peak center position features. That is:
[0225] The evaluation unit 305 can be specifically used to, after segmenting the brightness image into a brightness map of the hair region and a brightness map of the skin region, count the number of pixels with non-zero brightness values in the hair region based on the brightness map of the hair region, and calculate the proportion of the number of pixels with non-zero brightness values in the hair region in the brightness image. If the proportion is less than a preset empirical value, the average edge intensity of the ID photo to be evaluated is obtained. If the average edge intensity is greater than a preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image. Otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, the feature value of the center position of the histogram peak of the brightness image is obtained. If the feature value of the center position of the histogram peak is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image. If the feature value of the center position of the histogram peak is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image. If the proportion is greater than or equal to a preset empirical value, the operations of calculating the average brightness of the hair region based on the brightness map of the hair region and calculating the average brightness of the skin region based on the brightness map of the skin region are performed.
[0226] The evaluation unit 305 can also be used to, if the brightness image cannot be segmented into a brightness map of the hair region and a brightness map of the skin region, obtain the average edge intensity of the ID photo to be evaluated. If the average edge intensity is greater than a preset edge intensity threshold, the ID photo to be evaluated is determined to be a normal image; otherwise, if the average edge intensity is less than or equal to the preset edge intensity threshold, the histogram peak center position feature value of the brightness image is obtained. If the histogram peak center position feature value is greater than or equal to a preset position threshold, the ID photo to be evaluated is determined to be a normal image; if the histogram peak center position feature value is less than the preset position threshold, the ID photo to be evaluated is determined to be a gray image.
[0227] The edge strength threshold and the location threshold can be set by the threshold setting unit based on requirements, experiments, or practical experience.
[0228] Optionally, in order to better process the image and reduce the probability of rejecting documents during document production, after determining that the document photo to be evaluated is a grayscale image, the document photo to be evaluated can also be repaired. That is, the image quality evaluation device can also include a repair unit, as follows:
[0229] The repair unit is used to process the ID photo to be evaluated using a preset image restoration transformation function to obtain a processed ID photo, and then uses a preset dynamic upscaling factor to restore the brightness and details of the processed ID photo to obtain a repaired ID photo.
[0230] The image restoration transformation function and the dynamic stretching factor can be set by the threshold setting unit based on the characteristic values of the left and right waveforms of the histogram of the ID photo to be evaluated.
[0231] For details on the implementation of each of the above units, please refer to the preceding method embodiments; they will not be repeated here.
[0232] It should be noted that, in practical implementation, the above units can be arbitrarily combined and integrated into one or more modules, or implemented as independent entities. Furthermore, the above units can be implemented in hardware or as software functional modules. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The aforementioned storage medium can be a read-only memory, a hard disk, or an optical disk, etc.
[0233] The image quality assessment device provided in this embodiment is not only simple to implement, but also greatly improves the accuracy of the assessment, enhances the assessment effect, and reduces the probability of rejecting certificates during the certificate production process.
[0234] The above provides a detailed description of an image quality assessment method and apparatus provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An image quality assessment method, characterized in that, include: Obtain the brightness image of the ID photo to be evaluated; The brightness image is segmented into a brightness map of the hair region and a brightness map of the skin region; Calculate the mean brightness of the hair region based on the brightness map of the hair region, and calculate the mean brightness of the skin region based on the brightness map of the skin region; Calculate the ratio of the average brightness of the hair region to the average brightness of the skin region to obtain the first ratio; When the average brightness of the hair area is greater than the preset hair brightness threshold, the ID photo to be evaluated is determined to be a grayscale image; When the average brightness of the hair area is less than or equal to a preset hair brightness threshold, and the first ratio is greater than a preset ratio threshold, the ID photo to be evaluated is determined to be a normal image. The step of segmenting the brightness image into a brightness map of the hair region and a brightness map of the skin region includes: Collect multiple ID photo samples, including positive samples, which are normal images; Obtain the average brightness of the hair area and the average brightness of the skin area in the multiple ID photo samples; Set the average brightness value in the hair region as the hair segmentation threshold and the low threshold for skin color segmentation; Set the average brightness value in the skin-colored region as the high threshold for skin-colored segmentation; The region in the brightness image whose brightness is greater than the hair segmentation threshold is identified as the non-hair region. The brightness value of the non-hair region in the brightness image is adjusted to 0 to obtain the brightness map of the hair region. The region in the brightness image whose brightness is less than or equal to the high threshold of skin color segmentation and greater than the low threshold of skin color segmentation is determined to obtain the skin color region. The brightness value of the region in the brightness image other than the skin color region is adjusted to 0 to obtain the brightness map of the skin color region. The step of obtaining the average brightness of the hair region and the average brightness of the skin region in the multiple ID photo samples includes: Obtain the histogram of the ID photo sample. The histogram includes a left waveform and a right waveform. The left waveform is the waveform where the peak value of the dark part is located, and the right waveform is the waveform where the peak value of the bright part is located. Determine the right boundary point of the left waveform, the left boundary point of the right waveform, and the right boundary point of the right waveform; Calculate the mean of the sum of the right boundary point of the left waveform and the left boundary point of the right waveform to obtain the mean brightness of the hair region in the multiple ID photo samples. Calculate the mean value of the right boundary point of the right waveform to obtain the mean brightness value of the multiple ID photo samples in the skin color area.
2. The method according to claim 1, characterized in that, The process of obtaining the brightness image of the ID photo to be evaluated includes: Obtain the brightness value of each pixel in the ID photo to be evaluated; A brightness image of the ID photo to be evaluated is generated based on the obtained brightness values of the pixels.
3. The method according to claim 2, characterized in that, The step of obtaining the brightness value of each pixel in the ID photo to be evaluated includes: Obtain the red, green, and blue channel values of each pixel in the ID photo to be evaluated; Choose the maximum value from the red, green, and blue channel values of a pixel as the pixel's brightness value.
4. The method according to claim 1, characterized in that, The ID photo sample also includes negative samples, which are grayscale images; The step of obtaining the average brightness of the multiple ID photo samples in the hair area and the average brightness of the multiple ID photo samples in the skin area includes: obtaining the average brightness of multiple positive samples in the hair area, the average brightness of multiple positive samples in the skin area, and the average brightness of multiple negative samples in the hair area, respectively. After obtaining the average brightness values of the hair region and the average brightness values of the skin region of the multiple ID photo samples, the method further includes: setting a hair brightness threshold and a ratio threshold based on the average brightness values of the hair region of the multiple positive samples, the average brightness values of the skin region of the multiple positive samples, and the average brightness values of the hair region of the multiple negative samples.
5. The method according to claim 4, characterized in that, The setting of hair brightness threshold and ratio threshold based on the average brightness of multiple positive samples in the hair region, the average brightness of multiple positive samples in the skin region, and the average brightness of multiple negative samples in the hair region includes: A preset clustering algorithm is used to calculate the average brightness of the hair region in multiple positive samples, and the cluster center value of the hair region of the positive samples is obtained. The clustering algorithm described above is used to calculate the average brightness of the skin color region in multiple positive samples, and the cluster center value of the skin color region of the positive samples is obtained. The clustering algorithm described above is used to calculate the mean brightness of the hair region in multiple negative samples, thereby obtaining the cluster center value of the hair region of the negative samples; The average of the cluster center values of the positive sample hair region and the cluster center values of the negative sample hair region is set as the hair brightness threshold; Set the ratio of the cluster center value of the positive sample hair region to the cluster center value of the positive sample skin color region as the ratio threshold.
6. The method according to claim 1, characterized in that, Determining the right boundary point of the left waveform, the left boundary point of the right waveform, and the right boundary point of the right waveform includes: In the histogram, a first straight line parallel to the horizontal axis is set. The first straight line gradually moves upward along the vertical axis until it intersects with the falling edge of the left waveform, the rising edge of the right waveform, and the falling edge of the right waveform, thus obtaining an intersection line. The right boundary point of the left waveform is obtained by determining the x-coordinate value corresponding to the intersection point of the intersecting line and the falling edge of the left waveform. The left boundary point of the right waveform is obtained by determining the x-coordinate value corresponding to the intersection point of the intersecting line and the rising edge of the right waveform. The right boundary point of the right waveform is obtained by determining the x-coordinate value corresponding to the intersection point of the intersecting line and the falling edge of the right waveform.
7. An image quality assessment device, characterized in that, include: The acquisition unit is used to acquire the brightness image of the ID photo to be evaluated; A segmentation unit is used to segment the brightness image into a brightness map of the hair region and a brightness map of the skin region; A brightness calculation unit is used to calculate the average brightness of the hair region based on the brightness map of the hair region, and to calculate the average brightness of the skin region based on the brightness map of the skin region. The ratio calculation unit is used to calculate the ratio of the average brightness of the hair region to the average brightness of the skin region, and obtain the first ratio. An evaluation unit is used to determine that the ID photo to be evaluated is a grayscale image when the average brightness of the hair area is greater than a preset hair brightness threshold. When the average brightness of the hair area is less than or equal to a preset hair brightness threshold, and the first ratio is greater than a preset ratio threshold, the ID photo to be evaluated is determined to be a normal image. The segmentation unit is specifically used to collect multiple ID photo samples, including positive samples, which are normal images; to obtain the average brightness of the multiple ID photo samples in the hair region and the average brightness of the hair region; to set the average brightness of the hair region as the hair segmentation threshold and the low threshold of the hair segmentation; and to set the average brightness of the hair region as the high threshold of the skin segmentation. The region in the brightness image whose brightness is greater than the hair segmentation threshold is identified as the non-hair region. The brightness value of the non-hair region in the brightness image is adjusted to 0 to obtain the brightness map of the hair region. The region in the brightness image whose brightness is less than or equal to the skin color segmentation high threshold and greater than the skin color segmentation low threshold is identified as the skin color region. The brightness value of the region in the brightness image other than the skin color region is adjusted to 0 to obtain the brightness map of the skin color region. The brightness calculation unit is specifically used to obtain the histogram of the ID photo sample, the histogram including a left waveform and a right waveform, the left waveform being the waveform where the dark part peak is located, and the right waveform being the waveform where the bright part peak is located; determine the right boundary point of the left waveform, the left boundary point of the right waveform, and the right boundary point of the right waveform; calculate the mean of the sum of the right boundary points of the left waveform and the left boundary points of the right waveform to obtain the mean brightness of the multiple ID photo samples in the hair area; Calculate the mean value of the right boundary point of the right waveform to obtain the mean brightness value of the multiple ID photo samples in the skin color area.
Citation Information
Patent Citations
Identification method and identification device for dangerous targets in power monitoring system
CN102496030A
Method and device for regulating image brightness and contrast ratio
CN104486606A
Vehicle identification recognition method and system
CN105160292A
Foreground image segmentation method and device based on space structure, equipment and medium
CN116468736A
Method for evaluating an image quality of an image
WO2014191290A1