Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Let me guide you in a simple way , it looks that you want to move from command line input to the input with in program (I don't know what to call it :) ) , you simple need to do the following in your code

Mat img = imread ("E:\\lena.jpg");       // input image
Mat gray_img;                           // image where result will save
cvtColor(img , gray_img ,CV_BGR2GRAY) ; // this line convert your image from BGR2GRAY

imwrite("E:\\gray_img.jpg" , gray_img);   // is used to save the image in your directory

imshow("img" , gray_img) ;   // this line show you the gray image as output

@berak already guide you about headers