C++ How can I down bit level with using 'resize'?? or is there Dithering function exist?
Hi. I wanna resize image without changing DPI and bit level. So I use this code.
[
vector<int> params2;
params2.push_back(IMWRITE_TIFF_XDPI);
params2.push_back(XDPI); // XDPI is same with original's
params2.push_back(IMWRITE_TIFF_YDPI);
params2.push_back(YDPI); // YDPI is same with original's
resize(ori_image, resized_image, Size(ori_image.cols , ori_image.rows));
imwrite("resized_test_image.tif", resized_image, params2);
]
I solved DPI problem with IMWRITE'_TIFF_XDPI
But I dont know how to fix bit level.
There is IMWRITE_PNG_BILEVEL
in ImwriteFlag
s for Binary level PNG, 0 or 1, default is 0.
But it cannot use for tiff image.
Original image's bit level is 1 but resized image's bit level is 8. How can I fix bit level??
Or use other codes like dithering?
DPI is only used for printing, it does not play any role here, opencv will neither read nor write such info (it's all bogus)
resize() does not change the bitlevel. conversion to 8bit probably happened while reading it in.
(there is no internal 1bit format for cv::Mat)
i somehow doubt, that opencv is the correct library for your problem