Monday, June 23, 2014

What's the Best Pose for a Selfie?


Everyone loves taking selfies! However, sometimes it is not easy to take satisfactory ones. It is well-known that the posing of the face significantly affects the perceived appearance. Lots of guidelines and tips could found on the internet that teach you how to strike a nice. For examples, 
This video clip clearly demonstrates how pose can change the perceived appearances.


These guidelines and rules are useful heuristics to help non-models to pose like pro. To complement them, we take a data-driven approach to see how famous people on facebook pose while they take selfies and hope that we could get some insights from the observations. We take the following three people as examples


The reasons for taking these models as examples are two-fold. First, all three of them are very popular on facebook in Taiwan (with hundreds of thousands followers), suggesting that many people really enjoy reading their facebook status updates (photo updates in particular). Second, they consistently upload selfies in a wide variety of environments, providing sufficient data samples (on the order of several thousands samples) for analysis.


Data Collection and Processing

To understand how people pose on facebook, we need to estimate their relative pose with respect to the camera.

  • First, we use a free software for downloading publicly available photos in batch mode from their facebook profile pages. 
  • Second, we use the Viola-Jones face detector in OpenCV to localize faces with more than 40 x 40 pixels.
  • Third, we use off-the-shelf face alignment method (IntraFace from CMU) to align the facial landmarks and estimate the 3D pose.


Note that the 3D poses are expressed in terms of Pitch, Yaw, and Roll, as illustrated below with an airplane.

Image source: Link

Roughly speaking, the "Pitch" indicate whether the nose is down (Pitch > 0) or up (Pitch < 0).
The "Yaw" indicate whether the left (Yaw > 0) or right (Yaw < 0) face is toward the camera. The "Roll" indicate the face tilt angle on the image plane.


Marginal Distributions for Pitch, Yaw, and Roll Angles

Given a set of samples images crawled from facebook, we estimate the face pose in each image. We can then visualize the one-dimensional marginal distributions of Pitch, Yaw, and Roll for each person (estimated using the Kernel Density Estimation). Please see the figures below (on the left-hand side).

What can we learn from these marginal distributions? First, all of the pitch angle marginal distribution have strong peaks around 15 degrees. This observation agrees with the conventional wisdom that one should pose their faces a bit downward so that the face would appear slimmer. Here we give a quantitative estimation of the optimal Pitch angle is probably 15 degree.

Second, we can see the Yaw angles in posing differ from person to person. In Julie Chang (張齊郡)'s case, her right faces are toward the cameras most of the time. In contrast, 張香香 often put her left faces toward the cameras. We did not see a clear preference in Mika 黃杏蕙's case, one guess may be that many of her photos are not selfies (e.g., modeling for clothes). Therefore, it's the photographers who decide the pose. In both left and right faces, it seems that Yaw angles around 20 degrees are probably good choices. One should probably do a bit experiments to figure out best sign for them (i.e., whether left or right face is more attractive).

Third, we could see that the Roll distributions are centered at zero degrees with different variances for each person. This may be the bias of using Viola-Jones face detector, which mainly detects frontal faces. However, we could still see some interesting facts. For example, Julie Chang (張齊郡) uses larger roll angles in her selfies than others.


Pitch-Yaw Joint Distributions

As marginal distributions may not capture the true variations in the data, we visualizing the joint distributions of Pitch and Yaw variables on the right-hand-side. We can see somewhat interesting patterns in the joint distributions, motivating us to a more detailed look of the data.


From the joint distributions of Pitch-Yaw angles, we see that the distributions do not take a simple parametric form such as a Gaussian distribution. We use the Mean-Shift algorithm to detect the "modes" in the Pitch-Yaw-Roll 3D distributions. Here we show the clustering results (coded in different colors) in the 3D space. Note that we throw away clusters with less than 3 samples.




Julie Chang (張齊郡)                                   張香香                                  Mika 黃杏蕙


Discovering Visual Subcategories

With the detected modes, we can then compute the average to visualize the "prototypes" in the large photo collections. We show 12 visual subcategories visualization for each person. This gives us a rough idea of how they strike nice poses from these examples. They also provide visualizations on the statistics we observation. For examples, we could see from the set of prototypes that Julie Chang (張齊郡) often shows her right faces and has larger variations in Roll angles. We could also see that 張香香 prefer her left faces over right faces. 








Pose Changing Sequences

By organizing the poses (e.g., the Yaw angle) in decreasing or increasing order, we could create a photo sequence that the person appear to be slowly rotating their head, providing an interesting way to explore the personal photo collections.














The need of More Data

While the analysis of the selected three people's faces shows some interesting patterns, it is still far from being statistical significant. If you know other people who are good at taking selfies and have lots of photos available online, please let me know and I could try to include them as well. Thanks!


Thursday, June 5, 2014

Exposing Digital Forgeries by Detecting Inconsistent Geometry


On April 25, 2014, there was an conflict between the legislator Cheng-Yuan Tsai and several anti-nuclear protesters in front of the Legislative Yuan in Taiwan. You could find the background story of the event in Mr. Tsai's wikipage.

What causes my interest is the following image pair. The first one, posted by Cheng-Yuan Tsai, supports Tsai's claim that there was a man (presumably an anti-nuclear protester) who broke the windshield when he was about to leave the Legislative Yuan around 4:15 PM. 



In the evening (8:12 PM), the Chinatimes released several photos captured during the conflicts. Here I show one of photos below. You could see the visible highlights on the windshield. While the report did not mention the broken windshield, this photo seems to implicitly verify the claim by Mr. Cheng-Yuan Tsai. 


Image source: Chinatimes released at 8:12 PM on April 25

However, from the video below, it shows the contrary. This makes me wonder if the photo had been manipulated with the intention to cover the truth.



So, how to verify whether the image from Chinatimes is manipulated/photoshoped or not? My first attempt is to try Hany Farid's software izitru, which uses automated forensic analysis techniques (e.g., sensor pattern, JPEG ghost, double JPEG detection, and JPEG structure analysis) to certify unmodified digital camera images and give credibility to the captured photos. Yet, both of the images are flagged as "Potential file modification" because they have been re-saved since initial capture.

Well, let's try to address this problem from another perspective then. The main idea is that, if both photos are untouched, then there should be clear geometric relations between the two images (since they both captured the same car).

Thus, I check whether the spatial points between the two images satisfied the Epipolar constraint.


"Epipolar geometry is the geometry of stereo vision. When two cameras view a 3D scene from two distinct positions, there are a number of geometric relations between the 3D points and their projections onto the 2D images that lead to constraints between the image points.These relations are derived based on the assumption that the cameras can be approximated by the pinhole camera model." - Wikipedia


The figure below best illustrates the Epipolar geometry. Basically, a point in the left image must have its corresponding point somewhere on the line in the right image. Similarly, a point in the right image could find its correspondence point along a line in the left image. Such relationship could be captured compactly by   \mathbf{x}'^{\top}  \mathbf{F x} = 0.  for all pairs of corresponding points (x' and x), where F is the fundamental matrix.




You may be interested in learning more about it by listening to the Fundamental Matrix Song. XD



To estimate the fundamental matrix that relates points in this wide baseline stereo images, I first manually labeled a set of spatial correspondence pairs. I then solve the fundamental matrix using the off-the-shelf Normalized Eight-Point algorithm with robust estimation using the RANSAC algorithm. The figure below shows the inlier point matching between two frames.



Once we got the fundamental matrix, we could now verify whether the position of "highlight (presumably where the shield was hit)" satisfy the epipolar geometry constraint.


I first clicked on the position of the highlight in the left image (the red circle). Through the fundamental matrix, we get a red line in the right image. The red line suggests that where should we look for the corresponding point of the hole in the left image. If the right image was not manipulated, the red line should pass through the highlight position. Yet, you could see that there is slight inconsistency between the highlight positions in two images.

Similarly, we could click on the highlight position in the right image (the yellow circle). We show the yellow line in the left image to check if the corresponding point lies on the line. Again, there is a slight geometric inconsistency between the two images. 

So, from the analysis, could we say that the image from the Chinatimes is manipulated/photoshoped? Well, because the noisy manual labeling and the limited image resolution, nothing is absolutely certain. As for now, we could only say that it is very likely that the image had been manipulated. But, how likely? We will need to do more work on quantifying the input errors and and determine its the uncertainty as described in this paper. 



Anyway, it could have been much easier if Mr. Cheng-Yuan Tsai could provide the recordings from his vehicle video recorder. Orz