Method of cropping an image, an apparatus for cropping an image, a program and a storage medium
10861128 · 2020-12-08
Assignee
Inventors
Cpc classification
G06V10/25
PHYSICS
G06T3/04
PHYSICS
International classification
Abstract
A method of cropping an image containing an image of a human face includes detecting a region occupied by the image of the human face within the image, evaluating a plurality of candidate crops of the image, and selecting a crop of the image from the plurality of candidate crops of the image based on the results of the evaluation. The evaluating step includes applying a penalty to a candidate crop of the image in which the detected region occupied by the image of the human face is excluded or only partially included.
Claims
1. A method of cropping an original image containing an image of a human face comprising: detecting a region occupied by the image of the human face within the original image; evaluating a plurality of candidate cropped images generated from the original image; by: calculating, for each candidate cropped image of the plurality of cropped images, a basic score based on a measure of luminance, a measure of entropy, and a measure of sharpness averaged across the candidate cropped image; multiplying, for each candidate cropped image of the plurality of cropped images, the basic score by a corresponding value of a penalty function to generate a final score value, wherein the penalty function imposes a penalty to a candidate cropped image in which the detected region occupied by the image of the human face is excluded or only partially included; and selecting a single candidate cropped image as a cropped image from the plurality of candidate cropped images based on the corresponding final score values.
2. The method according to claim 1 wherein if the image contains a plurality of images of human faces, the method comprises applying a penalty for each face that is excluded or only partially included in the candidate cropped image.
3. The method according to claim 2, wherein the penalty applied for each candidate cropped image is weighted in accordance with a feature of the region of the image face in respect of which the penalty is being applied.
4. The method according to claim 1 wherein applying a penalty comprises applying a penalty function for every face in the candidate cropped image.
5. The method according to claim 1 wherein the penalty reduces the likelihood that the candidate cropped image will be selected as the cropped image.
6. A non-transitory computer-readable storage medium storing a program that, when executed by a computer, causes the computer to perform the steps of the method of claim 1.
7. The non-transitory computer-readable storage medium according to claim 6 wherein if the image contains a plurality of images of human faces, the method comprises applying a penalty for each face that is excluded or only partially included in the candidate cropped image.
8. The non-transitory computer-readable storage medium according to claim 7, wherein the penalty applied for each candidate cropped image is weighted in accordance with a feature of the region of the image face in respect of which the penalty is being applied.
9. The non-transitory computer-readable storage medium according to claim 6 wherein applying a penalty comprises applying a penalty function for every face in the candidate cropped image.
10. The non-transitory computer-readable storage medium according to claim 6 wherein the penalty reduces the likelihood that the candidate cropped image will be selected as the cropped image.
11. An apparatus for cropping an original image containing an image of a human face comprising: detecting means for detecting a region occupied by the image of the human face within the original image; evaluating means for evaluating a plurality of candidate cropped images generated from the original image; by: calculating, for each candidate cropped image of the plurality of cropped images, a basic score based on a measure of luminance, a measure of entropy, and a measure of sharpness averaged across the candidate cropped image; multiplying, for each candidate cropped image of the plurality of cropped images, the basic score by a corresponding value of a penalty function to generate a final score value, wherein the penalty function imposes a penalty to a candidate cropped image in which the detected region occupied by the image of the human face is excluded or only partially included; and selecting a single candidate cropped image as a cropped image from the plurality of candidate cropped images based on the corresponding final score values.
12. The apparatus according to claim 11 wherein if the image contains a plurality of images of human faces, the apparatus further comprises an applying means for applying a penalty for each face that is excluded or only partially included in the candidate cropped image.
13. The apparatus according to claim 12, wherein the penalty applied for each candidate cropped image is weighted in accordance with a feature of the region of the image face in respect of which the penalty is being applied.
14. The apparatus according to claim 11 wherein applying a penalty comprises applying a penalty function for every face in the candidate cropped image.
15. The apparatus according to claim 11 wherein the penalty reduces the likelihood that the candidate cropped image will be selected as the cropped image.
16. An apparatus for cropping an original image containing an image of a human face comprising: a processor; a memory; a code portion adapted to detect a region occupied by the image of the human face within the original image; a code portion adapted to evaluate a plurality of candidate cropped images generated from the original image; by: calculating, for each candidate cropped image of the plurality of cropped images, a basic score based on a measure of luminance, a measure of entropy, and a measure of sharpness averaged across the candidate cropped image; multiplying, for each candidate cropped image of the plurality of cropped images, the basic score by a corresponding value of a penalty function to generate a final score value; wherein the penalty function imposes a penalty to a candidate cropped image in which the detected region occupied by the image of the human face if excluded or only partially included; and selecting a single candidate cropped image as a cropped image from the plurality of candidate cropped images based on the corresponding final score values.
17. The apparatus according to claim 16 wherein if the image contains a plurality of images of human faces, the apparatus further comprises an applying means for applying a penalty for each face that is excluded or only partially included in the candidate cropped image.
18. The apparatus according to claim 17, wherein the penalty applied for each candidate cropped image is weighted in accordance with a feature of the region of the image face in respect of which the penalty is being applied.
19. The apparatus according to claim 16 wherein applying a penalty comprises applying a penalty function for every face in the candidate cropped image.
20. The apparatus according to claim 16 wherein the penalty reduces the likelihood that the candidate cropped image will be selected as the cropped image.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Embodiments of the present invention will now be described, by way of example only, with reference to the accompanying figures in which:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
DETAILED DESCRIPTION OF THE EMBODIMENTS
(15)
(16) The first embodiment is concerned with cropping an image stored in the SSD 10 for display on a portion of the monitor 14. The steps of the method are carried out by a computer program running on the PC 1. For the purposes of the first embodiment, the program is an image browser. However, many types of program can be used to display images including web browsers, image editing programs, etc.
(17) The steps of the first embodiment are described with reference to the flowchart shown in
(18) In step S21, the aspect ratio of the image to be displayed is compared with the aspect ratio of the display area in order to determine a cropping axis. The ratio of the pixel count of image in the horizontal direction, x.sub.i, to the pixel count of the image in the vertical direction, y.sub.i, is compared with the ratio of the pixel resolution of the monitor 14 in the horizontal direction, x.sub.m, to the pixel resolution of the monitor 14 in the vertical direction, y.sub.m. The possible results are as follows:
(19)
Cropping required along horizontal, x, axis of image
(20)
No cropping required
(21)
Cropping required along vertical, y, axis of image
(22)
(23) In step S22, a step size calculation may optionally be performed. As can be seen from
(24) In step S23 for each candidate crop a score is calculated. Step S23 is explained in more detail in
(25) For images in the R, G, B color space, the luminance of a pixel is calculated as follows:
Y=0.2126R+0.7152G+0.0722B
(26) So for an image with 8 bits per color channel, the luminance of a pixel Y can take a value between 0 and 255. The value of the luminance is averaged across the candidate cropped image and then normalized by dividing by 255. This results in a normalized value of luminance for the candidate cropped image, L, which will be referred to below.
(27) Determining the sharpness of the candidate cropped images is more difficult, as there is no standard measure of sharpness. Many approaches are possible, but in the first possible measure of sharpness is measured using the FISH algorithm described in A fast wavelet-based algorithm for global and local image sharpness estimation by P Vu and D Chandler IEEE signal processing letters, 2012. The sharpness is calculated for each of the candidate cropped images using the FISH algorithm and then normalized based on the resulting values so that the sharpness, S, of the candidate cropped images can vary between 0 and 1. A second option, used in the first embodiment, is to use variance of the Laplacian as described in Diatom autofocusing in brightfield microscopy: a comparative study by Pech-Pacheco et al 2000 ICPR.
(28) The entropy for each candidate cropped image is determined by using the Shannon entropy. There are various known algorithms for calculating the Shannon entropy of an image, such as the entropy function in MatLab, that will return the entropy of a grayscale image. The entropy of the cropped images is normalized, E, so as to vary between 0 and 1.
(29) The basic scores are then calculated based on the following formulae:
score=.sub.L*L+0.5*.sub.E*E+.sub.S*S if S<
score=.sub.L*L+.sub.E*E+.sub.S*S if S
(30) The value is a value set for determining whether an image is blurry or not. The value may be set by trial and error by applying the sharpness algorithm to various blurry and sharp images and selecting a suitable value. The first formula is used if the candidate cropped image is considered to be relatively blurry (S<). This formula halves the value of the entropy imposing a relative penalty on cropped images that are relatively blurry because the crop is less likely to include the relevant part of the image that was in focus and of interest to the user. The second formula is used if S. The values .sub.L, .sub.E, .sub.S are weight values that may be set according to requirements depending on the image sets being considered.
(31)
(32) In step S32 a penalty function is applied. The penalty function is shown in
(33) The scores after application of (multiplication by) the penalty function are shown in
(34) In step S24 the candidate cropped image with the highest score value is selected as the cropped image. Looking at
(35) The image is cropped according to the selected candidate cropped image and the cropped image is then displayed in the display area on the monitor 14.
Embodiment 2
(36) The first embodiment dealt with an image that included only a single face. In the second embodiment, an example will be considered in which a plurality of faces is present in the image.
(37) The method of the second embodiment follows the steps of the first embodiment described above with respect to
(38) The problem solved by the second embodiment is illustrated in
(39) The basic score is calculated at S31 in the same way as the first embodiment. However, the application of the penalty function in S32 differs from the first embodiment as follows.
(40) The combined penalty function to be applied is calculated as a linear sum of individual penalty functions for each of the faces detected in the image. The individual penalty functions follow the same form illustrated in the first embodiment: if the face is completely included the function has a value of 1, if the face is completely excluded the function has a value of 0.1 and the function falls linearly depending on the amount of the face that is partially excluded. The two children and male included in the image are relatively central in the image and are not partially or completely excluded in any of the candidate crops. Accordingly, the value of their penalty functions would be 1 for all candidate crops, which is to say that they make no adjustment to the basic score. Accordingly, the following description will focus on the ladies at the right and left sides of the images who are excluded from the image in one or more candidate cropped images. However, it is to be understood that all the faces in the image are considered, but only those that are completely or partially excluded in the candidate crops will contribute to the combined penalty function applied to the basic score.
(41) The penalty function can be understood by considering the individual penalty functions for each of the lady on the right-hand side of
(42) The linear sum that makes up the combined penalty function is calculated as follows:
penalty function=1+2
(43) Where f1 and f2 are as described above and illustrated in
(44)
(45) In the example shown in
(46) The rest of the method is the same as the first embodiment. The basic scores are multiplied by the combined penalty function shown in
(47) The second embodiment has been described with luminance and sharpness as the two factors used to generate weighting factors and . However, in another embodiment, size of the region of the face within the image may be used as a factor. When using the method described in ref. 3 or otherwise, the sliding window may be applied to the image at different scales (i.e. different sized windows). This will result in multiple detections of a face in different overlapping windows. The set of windows that detect a particular face can be combined to obtain a single detection of a face and the corners of the bounding region can be, for example, the average of the corners of the windows of all the windows within that set. The size of the bounding region can then be used to generate the weighting factors so that the penalty function more heavily penalizes excluding larger face regions from the image than smaller face regions.
(48) Embodiments of the present invention have been described above. Further embodiments of the present invention can also be realized by apparatuses or systems that read out and execute programs recorded on a memory device to perform the functions of the above-described embodiment(s), and by a method, the steps of which are performed by, for example, reading out and executing a program recorded on a memory device to perform the functions of the above-described embodiment(s). For this purpose, the program may be provided to the image processing apparatus or image processing system, for example via a network or from a recording medium of various types serving as the memory device (e.g., computer-readable medium).