This non-provisional application claims priority under 35 U.S.C. §119(a) on Patent Application No(s). 096150364 filed in Taiwan, R.O.C. on Dec. 26, 2007 the entire contents of which are hereby incorporated by reference.
1. Field of Invention
The present invention relates to an image processing method, and more particularly to an image processing method for adjusting a scale of a face in an image.
2. Related Art
Currently, digital cameras are provided with functions such as auto-focusing of the shooting environment, environment brightness detection, and shooting mode switching for shooting a scene. Besides, some cameras are capable of performing digital processing on the shot images, for example, image post-processing like red eye removal and image frame addition. Some of the cameras are even provided with special effect processing functions to make human figures shot in a frame “become slim” or “become fat”, such that the human figures in the image may not look too fat or bony. Actually, when such a digital camera is used to perform special effect processing on an image (for example, to make a human figure look slimmer or fatter), the human face in the image is not zoomed in or out. Since, most of the users are accustomed to placing human figures in a middle portion of an image while shooting, the pixels in the middle portion of the image are shrunk, and those on the left and right sides are expanded, thereby achieving the effect of zooming in/out the face of a human figure.
However, the special effect processing may easily cause image distortion.
Accordingly, the present invention is directed to an image processing method for adjusting a scale of a face. When the a scale of a face in an image is to be zoomed in/out, only the zoom block where the face is located is zoomed in/out, and meanwhile two sides of the zoom block are adjusted to repair the pixels altered by the zoom block, so as to avoid the image distortion.
In order to achieve the above objective, an image processing method for adjusting a scale of a face is provided. The method includes the following steps. First, a face detection is performed on the image to find out a face in the image. Next, a zoom block is set according to the position of the face. Then, a zoom proportion is set, and the zoom block is adjusted with constrain proportions according to the zoom proportion. Thereafter, two sides of the zoom block are adjusted with constrain proportions according to the zoom proportion, so as to maintain a total number of pixels of the image.
In the image processing method for adjusting a scale of a face according to a preferred embodiment of the present invention, the face detection further includes the following steps. First, an edge detection is performed on the image to obtain an edge image. Next, the edge image is compared with multiple face features in a face database, so as to find out a face in the edge image that conforms to the face features in the database. Then, the position of the face is recorded.
In the image processing method for adjusting a scale of a face according to a preferred embodiment of the present invention, the zoom block is an entire row of the position of the face.
In the image processing method for adjusting a scale of a face according to a preferred embodiment of the present invention, the zoom block is an entire column of the position of the face.
In the image processing method for adjusting a scale of a face according to a preferred embodiment of the present invention, a man-machine interface is further provided for a user to set/adjust the zoom proportion. The zoom proportion is a length percentage of the zoom block after adjustment taking up the zoom block before adjustment. In addition, the zoom proportion on the two sides of the zoom block (i.e., the relationship between the two sides of the zoom block before and after adjustment) is represented by the following mathematical expressions:
γ′=γ+γ*X/(γ+δ);
δ′=δ+δ*X/(δ+δ);
where, γ is a total number of columns/rows of the pixels on one side of the zoom block before adjustment, γ′ is a total number of columns/rows of the pixels on one side of the zoom block after adjustment, δ is a total number of columns/rows of the pixels on the other side of the zoom block before adjustment, δ′ is a total number of columns/rows of the pixels on the other side of the zoom block after adjustment, and X is a total number of columns/rows of the adjusted pixels of the zoom block.
In view of the above, the image processing method for adjusting a scale of a face selects a zoom block according to the position of the face, such that only the zoom block is adjusted instead of zooming in/out the whole image when the scale of the face in the image is to be adjusted. Further, after the zoom block is zoomed in/out, the two sides of the zoom block are adjusted with constrain proportions, thereby repairing the image, so as to achieve the purpose of adjusting the scale of the face in the image, and avoiding the image distortion caused by the adjustment.
The present invention will become more fully understood from the detailed description given herein below for illustration only, and thus are not limitative of the present invention, and wherein:
The objective and method of the present invention are described in detail below with preferred embodiments, and the concept of the present invention may also be applied to other scopes. The embodiments below are only used to illustrate the objective and method of the present invention, instead of limiting the scope of the same.
Thus, in order to precisely adjust the scale of the face in an image, the position of the face must be first found out in the image, i.e., a face detection is performed on the image to find out a face in the image. The face detection includes the following steps. First, an image is input, and an edge detection is performed to obtain an edge image (Step 1). In this embodiment, for example, an edge image is obtained by a Gradient Magnitude method. That is, a matrix of all pixels of the image is multiplied by a horizontal gradient magnitude
and a vertical gradient magnitude
and thus an edge image can be drawn according to the obtained matrix. Other methods like Laplacian, Tengengrad, and 1D Horizontal Filter may also be used to achieve the same purpose, which is not limited herein. After the edge image is obtained (Step 2), the edge image is compared with multiple face features in a face database, so as to find out the face in the image, and the information about the position of the face is recorded (Step 3).
After the face is found in the image, the scale of the face is adjusted. However, to avoid the cases that the human figure shot in the image looks “top-heavy” or “bottom-heavy” (i.e., the proportions of body of the human figure is abnormal), in this embodiment, a zoom block is selected, and the zoom block is adjusted with constrain proportions, so as to avoid body disproportion caused by the adjustment of only the face. Entire columns or rows of the position of the face in the image are selected as a zoom block according to the laying of the human figure in the image, i.e., whether the human figure is laid vertically (perpendicular to the horizon line) or transversely (parallel to the horizon line). If the human figure in the image is laid vertically, the entire columns of the position of the face are selected as the zoom block. On the contrary, if the image is placed transversely, the entire rows of the position of the face are selected as the zoom block.
A user may set the zoom proportion of the zoom block through a man-machine interface. In some embodiments, the man-machine interface is, for example, physical keys on the digital camera or virtual keys on the screen (touch screen) of the digital camera. After a microprocessor (or DSP chip) of the digital camera receives a zoom proportion input by the user, the zoom block is adjusted according to the zoom proportion. The zoom proportion is a length percentage of the zoom block after adjustment taking up the zoom block before adjustment. The total number of columns/rows of the pixels requiring for adjustment in the zoom block is represented by the following mathematical expression: the total number of columns/rows of the adjusted pixels of the zoom block=the total number of columns/rows of the pixels of the zoom block*(1−zoom proportion).
It must be noted that if the human figure in the frame stands upright, the entire columns of the zoom block are adjusted, i.e., the entire columns of pixels are added/deleted to make the face in the frame become fatter/slimmer. On the contrary, if the human figure in the frame is laid transversely, the entire rows of the zoom block are adjusted, i.e., the entire rows of pixels are added/deleted to make the face in the frame become fatter/slimmer.
In an embodiment, the human figure in the frame stands upright. If the width of the zoom block is set to be 100 pixels, and a zoom proportion set by the user is 80%, when the zoom block is adjusted, the total number of columns of the pixels requiring for adjustment in the zoom block is first calculated. After a result of calculation of the microprocessor of the digital camera is that 20 columns of pixels need to be deleted from the zoom block with constrain proportions, the extra pixels are deleted from left to right at equal intervals (i.e. an entire column of pixels is deleted every other five pixels). Afterwards, the remaining 80 columns of pixels are integrated into a zoom block after adjustment. The width of the zoom block after adjustment is 80 pixels, and thus the face in the image looks slimmer. Since the body of the human figure is also circled to be the zoom block, after the scale of the face is adjusted, the human figure in the image is not unnatural. Accordingly, if the user intends to make the face in the image look plump, the zoom proportion may be set to be 120%, and the width of the zoom block after adjustment turns to be 120 pixels.
In order to maintain the original size of the image to make the image look more natural, after the zoom block is zoomed out (compressed inwardly), the image on the two sides of the zoom block needs to be zoomed in with constrain proportions, so as to repair the lacked pixels after the adjustment (inward compression) of the zoom block. Accordingly, if the zoom block is zoomed out by 20 columns of pixels, the two sides of the zoom block must be added with 20 columns of pixels. The zoom proportion on the two sides of the zoom block is represented by the following mathematical expressions:
γ′=γ+γ*X/(γ+δ;
δ′=δ+δ*X/(γ+δ;
where γ is a total number of columns/rows of the pixels on one side of the zoom block before adjustment, γ′ is a total number of columns/rows of the pixels on one side of the zoom block after adjustment, δ is a total number of columns/rows of the pixels on the other side of the zoom block before adjustment, δ′ is a total number of columns/rows of the pixels on the other side of the zoom block after adjustment, and X is a total number of columns/rows of the adjusted pixels of the zoom block. Accordingly, if the pixel width on the left side of the zoom block is 200 pixels, and the pixel width on the right side of the zoom block is 300 pixels, 8 columns of pixels are added on the left side of the zoom block, and 12 columns of pixels are added on the right side of the zoom block. In detail, a column of pixels are added every other 25 columns from left to right on the left side of the zoom block (the value of each pixel in the added column is a mean value of its adjacent pixels), and a column of pixels are added every other 25 columns from left to right on the right side of the zoom block. As such, the image will maintain the original size and look more natural.
In another embodiment, the human figure in the frame is transversely laid. In order to adjust the scale of the face in the frame, a process similar to the above adjustment of an upright human figure in a frame must be performed. First, a zoom proportion is set by the user. Then, the position of the face is found in the frame. The entire rows of the position of the face are set to be a zoom block. Afterwards, the entire rows of pixels in the zoom block are adjusted with constrain proportions. Finally, two sides (the upper and lower sides thereof) of the zoom block are adjusted, so as to make the image maintain its original size. The process has already been illustrated in detail in the above embodiments, and will not be repeated herein again.
In order to clarify this embodiment, the image processing method for adjusting a scale of a face is illustrated below with the accompanying drawings.
In view of the above, the present invention determines the position of a face through the face detection, and sets entire columns/rows of the position of the face to be a block to be adjusted. Therefore, the block is adjusted to adjust the whole proportion of the human figure, so as to make the body be in harmony with the face. Further, after the zoom block where the face is located is adjusted, the two sides of the zoom block are adjusted with constrain proportions, such that the pixels altered due to the adjustment of the face image (the entire columns of pixels added/deleted) are repaired, thereby avoiding the image distortion caused by the adjustment of the scale of the face.
Number | Date | Country | Kind |
---|---|---|---|
096150364 | Dec 2007 | TW | national |