Use the imwrite function. If the image is cv::Mat image, you can save it by using
imwrite ( filename, image );