Question

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

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top