I tried to convert RGB image into grayscale, conversion is successfull and i can display it with imshow. Yet, i cannot write it with imwrite, imwrite function returns NULL. My original image is 1920*1080 JPEG file with UINT8. Here is the code
#include <opencv\cv.h>
#include <opencv\highgui.h>
using namespace cv;
int main(int argc, char** argv)
{
char* imageName = argv[1];
Mat image;
image = imread(imageName, 1);
if (argc != 2 || !image.data)
{
printf(" No image data \n ");
return -1;
}
Mat gray_image;
cvtColor(image, gray_image, CV_BGR2GRAY);
if (imwrite("../../images/Gray_Image.jpg", gray_image) ==NULL) {
printf( "Writing image is not successfull!");
}
namedWindow(imageName, CV_WINDOW_AUTOSIZE);
namedWindow("Gray image", CV_WINDOW_AUTOSIZE);
imshow(imageName, image);
imshow("Gray image", gray_image);
waitKey(0);
return 0;
}
Why imwrite returns NULL?
cv:imwriteisbool.