You can try to increase the compression quality parameter, as shown in the OpenCV cv :: imwrite documentation :
cv::Mat img = cv::imread("dir/frogImage.jpg",-1); std::vector<int> compression_params; compression_params.push_back(CV_IMWRITE_JPEG_QUALITY); compression_params.push_back(100); cv::imwrite("dir/result.jpg",img, compression_params);
Without specifying the compression quality manually, 95% quality will be applied.
but 1. you donβt know what jpeg compression quality the original image has (maybe you can increase the image size) and 2. it (afayk) still introduces additional minor artifacts, because in the end it is a loss of the compression method.
UPDATE Your problem does not seem to be due to compression artifacts, but because of the image with the Adobe RGB 1998 color format. OpenCV interprets the color values ββas they are, but instead, it must scale the color values ββto match the βrealβ RGB color space. The browser and some image viewers correctly apply the color format, while others do not (for example, irfanView). I used GIMP for verification. Using GIMP, you can decide to launch how to interpret color values ββby format, or get what you want, or your βwashedβ image. OpenCV definitely does not care about such things, since it is not a photo editing library, therefore, neither reading nor writing, the color format will not be processed.
source share