patrikhuber / superviseddescent

C++11 implementation of the supervised descent optimisation method
http://patrikhuber.github.io/superviseddescent/
Apache License 2.0
404 stars 188 forks source link

Details about calculating the mean #21

Closed Mark0Sertic closed 8 years ago

Mark0Sertic commented 9 years ago

Hello patrihhuber,

I have a question about your code. I am pretty new to this field and I am quite amazed with your implementation of SDM,

I have read articles about SDM and I am wondering how you generated "mean_ibug_lfpw_68.txt" file. I have read question in solved issues How to calculate the mean-face ? but I didn't understand the answer quite well.

Can you explain me in more details or give me some pseudo code or the code which generated that file. Can you tell me what are the steps, for example, if I have 100 pictures and 100 files which have landmark positions, what I must do to generate "mean_ibug_lfpw_68.txt". In article that I have read this step is mentioned but I haven't found explanation how to do it, so if you could provide me pseudo code on how to generate "mean_ibug_lfpw_68.txt" or the code which you have used i would be very thankful :)

patrikhuber commented 9 years ago

Hi Marko,

Thanks for the praise!

First of all a small detail: the mean and median are not the same, I adjusted the title.

Calculating the mean face is really not that interesting or important, so don't think too much about it! In the simplest way, it's really easy: You can just average all landmarks. Without normalisation or anything. Just load your 100 files, and average each landmark's x and y over all 100 landmarks. You can directly plot that result, for example with OpenCV or Matlab, and it has to look like a mean face. It's really too easy to even give sample code! It's just loading all x and y's and calling cv::mean() or you can also do it in Matlab. What you can do after is for example rescale the points to (-0.5, 0.5) x (-0.5, 0.5) - I think I did that.

You can do more fancy stuff like Procrustes before averaging but it's really not worth spending time on it.

I hope that helps!