1

I want to covert a .jpg image to a .pgm image.The image is being obtained from a tcp socket which has live streaming by a OPENCV program. In matlab I used the imread function to do it. How do I do it in cpp? I am working in linux platform. Is there any function to do it in OPENCV?

can anyone help?

regards, shiksha

wireless_lab
  • 177
  • 1
  • 4
  • 18
  • http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread – Haris Mar 19 '14 at 11:41

2 Answers2

3

Yes.

In OpenCV, you can use imread() to load the JPG image, and then use imwrite() it to the PGM image (by using the CV_IMWRITE_PXM_BINARY format flag).

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
2

please look at OpenCV documentation for HighGui library functions cv::imread and cv::imwrite. Read the jpg using cv::imread and resave it with cv::imsave using filename with proper extension.

vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80