c++ - how do I load a pure blackwhite image as qimage?
问题描述
QImage qimg;
qimg.load('blackWhite.jpg')
This method changes pixels. I'm getting pixels like(1,1,1) or (3,3,3). But I expected only (0,0,0) and (255, 255, 255). I have also tried the following method:
QImage image(bin.data, bin.cols, bin.rows,
static_cast<int>(bin.step),
QImage::Format_Mono);
Here bin is a Mat image(binary).This method is showing an image with half full black and half full white image.
Simply, I just want to load a binary image with QImage as a binary image with no change of any pixels.
解决方案
You are loading a jpeg image, that format is a lossy compression format, meaning the pixels will be approximated but not necessary equal to the originals. So if you are in need to load the image from file, you should use a format like png, bmp, etc. (Any lossless format will do)
推荐阅读
- c - Libgcrypt - 从 gcry_sexp_t 对象中提取 RSA 加密数据
- r - 从二进制相似矩阵生成(重叠)相互相似的元素集
- excel - MS Excel - 如果相应单元格在另一列中不为空,则向下填充一列单元格
- javascript - 在表单中使用 onsubmit 而不是 onchange 时无法获取图像
- python - Python TypeError: Employee() 没有争论
- javascript - Javascript / jQuery:检测每个图像何时加载
- gradle - 带有 gradle 的 Java 11:必须指定绝对路径,但是是 ${tools.jar}
- amazon-web-services - 需要在 AWS Centos 中将 CakePhp 应用程序从 php 5 迁移到 7
- python - 使用 python 从 CSV 文件中查询
- machine-learning - 解释特征交互与特征相关