The present invention relates to a method for repairing a portrait photo, and more particularly to a method applied to an electronic image-capturing device for automatically calculating a location of a plurality of feature points in a mouth region of a portrait photo, when detecting and determining that the mouth region is in the stiff state, and executing an image warping process to the location of the feature points to ensure that the processed portrait photo is in a repaired smile state showing a slightly opened mouth and slightly raised corners.
Presently, with the advance of digital photographic technologies, various of electronic devices (such as digital cameras, digital video cameras, notebook computers, and mobile phones and etc.) having digital image-capturing elements are continuously developed and improved. There is a trend to enhance the photographic quality of the electronic devices, minimize the volume thereof, and lower the selling price thereof. Therefore, electronic image-capturing devices are more and more popular in the market. As a result, it is important for related manufacturers of the electronic image-capturing devices to develop and design an electronic image-capturing device having an intelligent image capturing function for satisfying basic photographic functions needed by most users and overcoming the insufficient photographic skill thereof.
Generally, most of various photos captured by a traditional electronic image-capturing device operated by a user are portrait photos. When capturing a portrait photo, the user usually continues to seek for a suitable transient scene, in order to capture a portrait photo, which can show a best appearance of the captured person. However, what kind of the appearance is the best one which can be agreed and accepted by the most users? The answer is an appearance showing a smile face of the captured person during his/her mouth is slightly opened and corners of the mouth are slightly raised. Thus, when capturing a portrait photo, the captured person usually hopes that a photographer can capture a portrait photo when the captured person transiently shows his/her smile face. However, in fact, it is unfortunate that the captured person generally can not have a timely communication or a sufficient consensus with the photographer, such that the captured person can not be precisely aware of the best transience when the photographer presses a shutter button. As a result, when the photographer presses the shutter button, the captured person may unwittingly close his/her mouth, resulting in generating an unnatural or stiff face. Even, after the photographer told the captured person to keep smiling and be ready for taking a photo, the captured person still can not continuously keep the same smile face. As a result, the captured person may close his/her mouth at the transient moment of pressing the shutter button. In other words, the original smile face of the captured person may suddenly become the unnatural or stiff face. The foregoing unexpected conditions cause the portrait photo captured by the photographer only shows the unnatural or unbeautiful face, which may not be satisfied or accepted by the captured person. Especially, when the photographer takes a photo of many people or children, the portrait photo inevitably shows closed mouths of the captured people. Specifically, if the photographer can not take a photo having smile faces of all captured people in a memorable or a rememberable day, it will be very regrettable. As a result, it is important for related manufacturers of electronic image-capturing devices to develop and design an image correction technology for improving the electronic image-capturing devices to be capable of detecting if the mouth of the captured portrait photo is in a closed stiff state and automatically repairing the mouth when the mouth is determining to be closed, so as to automatically repair the mouth to be in a smile state having a slightly opened mouth and slightly raised corners, thereby enhancing the portrait photo more natural and more esthetic, and substantially increasing the successful ratio of taking good portrait photos.
It is therefore tried by the inventor(s) to develop a method for detecting a facial expression and repairing a smile face of a portrait photo to solve the problems existing in the traditional electronic image-capturing device that can not precisely determine if the mouth of the captured person is in an unnatural or stiff state at the transient moment of pressing the shutter button, resulting in only capturing a portrait photo captured by the photographer, which can not be satisfied or accepted by the captured person, as described above.
A primary object of the present invention is to provide a method for detecting a facial expression and repairing a smile face of a portrait photo, which is applied to an electronic image-capturing device and comprises the steps of: detecting a location and a range of a mouth region in a captured portrait photo; capturing a patch in the mouth region and a predetermined peripheral range thereof, wherein the patch is able to fully show various facial expressions in the mouth region and the predetermined peripheral range; executing a comparison process to a smile state or a stiff state of the mouth region in the patch by a mouth state classifier; executing a calculation process to a repaired region of the mouth region when the mouth region is determined to be in the stiff state, in order to calculate a location of a plurality of feature points in the repaired region of the mouth region; and executing an image warping process to the location of the feature points and adjacent pixels thereof, in order to ensure that the processed portrait photo is in a repaired smile state showing a slightly opened mouth and slightly raised corners.
A secondary object of the present invention is to provide a method for detecting a facial expression and repairing a smile face of a portrait photo, which is applied to a photo processing device and comprises the steps of: detecting a location and a range of a mouth region in an inputted portrait photo; capturing a patch in the mouth region and a predetermined peripheral range thereof; executing a comparison process to a smile state or a stiff state of the mouth region in the patch by a mouth state classifier; executing a calculation process to a repaired region of the mouth region when the mouth region is determined to be in the stiff state, in order to calculate a location of a plurality of feature points in the repaired region of the mouth region; and executing an image warping process to the location of the feature points and adjacent pixels thereof, for generating a portrait photo showing a smile state.
The structure and the technical means adopted by the present invention to achieve the above and other objects can be best understood by referring to the following detailed description of the preferred embodiments and the accompanying drawings, wherein
In a first preferred embodiment of the present invention, the method for detecting a facial expression and repairing a smile face of a portrait photo is applied to an electronic image-capturing device. The electronic image-capturing device is preferably selected from various electronic devices having a digital image-capturing element (such as a CCD element or a CMOS element). For example, the electronic image-capturing device can be selected from a digital camera, a digital video camera, a notebook computer, a mobile phone, and etc. When the electronic image-capturing device detects and determines that a captured portrait photo has a mouth region in a closed stiff state, including the mouth region and a peripheral range thereof, which is used to fully show a facial expression, will be repaired. Thus, the repaired portrait photo will provide the mouth region showing with a repaired smile state. In the preferred embodiment of the present invention, when a user takes a portrait photo by the electronic image-capturing device, the method of the present invention executes the following steps via the electronic image-capturing device, as shown in
In step 101: capturing a current photo via a digital image-capturing element.
In step 102: executing a face detection process to the photo, wherein various algorithms for the face detection are disclosed in many publications, such as according to the OpenCV portrait detection software designed by the Adaboost algorithm, the Haar-like feature, and other related recognition technologies. The detection software is provided with a portrait state classifier trained according to a predetermined number of portrait photo samples, i.e. a classifier capable of determining if the objects in a photo is a portrait feature or not. In the present invention, the portrait state classifier is used to detect and quickly recognize a portrait feature in a photo. Due to the detection algorithms are prior arts and not subject matters of the present invention, the detailed description thereof will be omitted.
In step 103: determining if the photo has a portrait feature; if yes, go to step 104; and if not, go back to the step 101.
In step 104: marking a location and a range of the portrait feature in the photo, and then detecting a location and a range of a mouth region of the portrait feature, wherein an algorithm for detecting the mouth region is also disclosed in many publications, as described above, and can be selected from a mouth state classifier trained according to a predetermined number of mouth photo samples, i.e. a classifier capable of determining if the objects in a photo has a mouth feature or not. Due to the mouth state classifier is a prior art and not a subject matter of the present invention, the detailed description thereof will be omitted.
In step 105: determining if the photo has a mouth feature; if yes, go to step 106; and if not, go back to the step 101.
In step 106: marking the location and the range of a mouth region of the portrait photo, and then expanding a to-be-recognized range of the mouth region with a predetermined ratio, i.e. a small frame 21 as shown in
In step 107: detecting a smile state or stiff state of the mouth region in the patch (i.e. a facial expression showed by the mouth region), wherein an algorithm for detecting the facial expression is described hereinbefore, and can be selected from a mouth state classifier based on the Adaboost algorithm and trained according to a predetermined number of mouth photo samples 30 and 31 in a smile state or a stiff state, as shown in
In step 108: determining if the mouth region in the patch is in the stiff state or the smile state; if the mouth region is in the smile state, go to step 109; otherwise if the mouth region is in the stiff state, as shown in
In step 109: saving the current photo into a memory unit or a storage unit (such as a hard disk or a memory card and etc.) of the electronic image-capturing device, then go back to the step 101.
In step 110: saving the current photo into the memory unit or the storage unit of the electronic image-capturing device.
In step 111, calculating the location of the plurality of feature points 50 of the mouth region in the repaired region, as shown in
In step 112: calculating the repaired region of the mouth region, as shown in
d
w
=W
i/5.
d
d
=H
i/4; and
d
u
=H
i/2
In step 113, executing an image warping process to the location of the feature points and adjacent pixels thereof, so as to generate a portrait photo showing a smile state (having a slightly open mouth and slightly raised corners thereof), as shown in
{Li1}={(xi,yi)|0<=i<=M−1}; and
{Li0}={(ui,vi)|0<=i<=M−1};
In step 114, showing a signal on a display, wherein the signal represents if selecting to save the repaired portrait photo; if selecting to save the repaired portrait photo, go to step 115; otherwise, if selecting not to save the repaired portrait photo, go back to the step 101.
In step 115, saving the repaired portrait photo into the memory unit or the storage unit of the electronic image-capturing device, for ensuring that the facial expression of the portrait photo processed by the electronic image-capturing device can be maintained in an optimized esthetic state. Then, go back to the step 101.
In a second preferred embodiment of the present invention, the method for detecting a facial expression and repairing a smile face of a portrait photo is further applied to a photo processing device. The photo processing device can be an electronic device selected from the group consisting of a notebook computer, a personal digital assistant (PDA), a digital camera, or a mobile phone, etc. In the second preferred embodiment, the photo processing device is unnecessary to provide any digital image-capturing element. After the electronic devices read in an inputted portrait photo, some steps similar to the steps of the first preferred embodiment will be executed. The second preferred embodiment comprises the steps of: detecting the location and the range of a mouth region in the inputted portrait photo; capturing a patch in the mouth region and a predetermined peripheral range thereof; executing a comparison process to a smile state or a stiff state of the mouth region in the patch by a mouth state classifier; executing a calculation process to a repaired region of the mouth region when the mouth region is determined to be in a stiff state, in order to calculate the location of a plurality of feature points in the repaired region of the mouth region; and executing an image warping process to the location of the feature points and adjacent pixels thereof. As a result, the method will ensure that the mouth region of the repaired portrait photo is in a smile state.
The present invention has been described with a preferred embodiment thereof and it is understood that many changes and modifications to the described embodiment can be carried out without departing from the scope and the spirit of the invention that is intended to be limited only by the appended claims.