От: OpenCV - Help
Окей
Ето и програмата:
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#define CV_IMWRITE_JPEG_QUALITY 1
int main(int argc, char *argv []) {
int p[3];
IplImage* cvLoadImage("baby.jpg");
p[0] = CV_IMWRITE_JPEG_QUALITY;
p[1] = 10;
p[2] = 0;
IplImage* img=0;
IplImage* img_bw=0;
printf ("Hello\n");
if (argv [1] != 0) {
img = cvLoadImage ( argv[1], 1) ; // 0−BW
cvSaveImage ( "image.bmp", img,0);
cvSaveImage ( "image.png", img,0 );
cvSaveImage ( "image1.jpg",img,p);
p[1] = 10;
cvSaveImage ( "image2.jpg" , img,p);
img_bw = cvCreateImage (cvGetSize(img) ,IPL_DEPTH_8U,1);
cvCvtColor(img,img_bw,CV_RGB2GRAY);
cvSaveImage( "image2bw.jpg",img_bw,p);
}
else
printf("Enter filename\n");
if(img != 0) {
cvNamedWindow("Display", CV_WINDOW_AUTOSIZE);
cvShowImage ("Display", img);
cvWaitKey (0);
cvDestroyWindow("Display");
}
else
printf("File not found\n") ;
return 0;
}