I remember we can use "imread" to read .PGM file in matlab. If you
want to read PGM file in C environment, I suggest you can use matlab's
interface in VC++.
Second, RBG to Gray, in matlab, the function "rgb2gray" can complete
this work, as to the parameter, you can see the help of function. In
Opencv, there are same
function to realize RGB to GRAY. I don't think OpenCV is best for face
recognition. But the library that provided by OpenCV can be used in
pattern recognition or machine learning, avoid we code new function.